I have a module, uc_dropdown_attributes (7.x-1.x), with tests that run locally and also run using run-tests.sh with no failures. However, when I try to run the tests on drupal.org the tests fail. It looks like ubercart is getting loaded from the log. The enabled modules step is red so it appears that is the problem. Since it fails at the beginning it is not likely to be due to being installed in a subdirectory or not having clean URLs. The fatal error is reported as

Call to undefined function uc_attribute_save()

but this is likely due to the error in enabling modules. uc_attribute is specified as a dependency in the .info file.

The error message in the log is:

FATAL UCDropdownAttributesTestCase: test runner returned a non-zero error code (255).

I have tried adding the modules from Ubercart into the setup function. The only successful test is if I just enable uc_store. If I put in rules it fails. If I switch the order of rules and uc_store it fails. If I copy the code from the setup function in Ubercart tests it fails. I have written tests for another module without this problem. Committing changes to git to try to debug this is tedious. Any suggestions on how to proceed?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rfay’s picture

Status: Active » Postponed (maintainer needs more info)

The test is http://qa.drupal.org/pifr/test/238834

The failure is on uc_attribute_save() - it's not found.

It looks to me like you're doing a very wrong thing in the function where the failure happens. A "public static function" is not going to have access to the actual test instance since it's static. My bet is that you have uc_attribute() enabled in your install (the test-runner install). And of course it's not enabled on the test runner on the testbot.

Anyway, move the stuff out of static functions. That's my opinion anyway.

  public static function createAttribute($data = array(), $save = TRUE) {
    $attribute = $data + array(
      'name' => DrupalWebTestCase::randomName(8),
      'label' => DrupalWebTestCase::randomName(8),
      'description' => DrupalWebTestCase::randomName(8),
      'required' => mt_rand(0, 1) ? TRUE : FALSE,
      'display' => mt_rand(0, 3),
      'ordering' => mt_rand(-10, 10),
    );
    $attribute = (object) $attribute;
    if ($save) {
      uc_attribute_save($attribute);
    }
    return $attribute;
  }
trobey’s picture

I removed the static declarations. These two functions were mostly copied from the uc_attribute tests which used the static declaration.

Same problem. Runs locally in the GUI and command line with no errors. Fails to run on drupal.org with the same errors. http://qa.drupal.org/pifr/test/238834.

rfay’s picture

Status: Postponed (maintainer needs more info) » Active

Could you please disable all ubercart modules on your local and try to run the tests locally?

rfay’s picture

I did that on the testbot; here are the files and database. It does in fact not work as configured on the testbot.

Drupal checkout files: http://dl.dropbox.com/u/7350603/tmp/uc_dropdown_attributes.files.tgz
Drupal checkout database: http://dl.dropbox.com/u/7350603/tmp/uc_dropdown_attributes.sql.gz

Admin is admin/drupal - easier to use drush uli for it though.

trobey’s picture

Here is a screen shot of the Ubercart tests using the tar ball and database you sent. This is of the lower part of the screen (taking the screen shot seems to scroll the window). Enabling the modules fails. All the permissions that are defined by Ubercart fail. It cannot find a class defined in one of the Ubercart modules. This is the same thing I am seeing (using the CLI):

Fail Other uc_dropdown_attri 25 UCDropdownAttributesTestCase->setUp
Enabled modules: uc_dropdown_attributes

I can get it to pass enabling the modules with just the uc_store module in the setup function but everything else I have tested fails.

rfay’s picture

Until you can get it to pass locally, this is not a testbot problem. I might take a look, but not sure I'll have time.

trobey’s picture

rfay: You have helped immensely by giving me those files. Now I have the ability to solve the problem although it will take a while. So do not feel you need to spend any time other than giving advice.

trobey’s picture

Attached is a patch which adds an additional test to check whether all the dependent modules exist. This assertion is similar to the assertion for testing whether an module is enabled and useful for finding problems such as in this issue. Attached are screen shots of the test ouptut before and after this patch.

rfay’s picture

Status: Needs review » Active

If you want to get this improved, you'll need to move it to drupal core in the simpletest component.

If the problem is that the wrong module is not available due to the testbot not loading a module, that's something we can fix on this end.

rfay’s picture

If you want to get this improved, you'll need to move it to drupal core in the simpletest component.

If the problem is that the wrong module is not available due to the testbot not loading a module, that's something we can fix on this end.

trobey’s picture

The patch has been moved to Drupal core.

The testbot is loading the uc_dropdown_attributes and Ubercart projects. uc_dropdown_attributes requires uc_attribute and uc_cart so this is why Ubercart is loaded. But all the modules that uc_attribute and uc_cart require are not loaded (such as Views, Rules and several others). I can put these chained dependencies into the uc_dropdown_attributes.info and wait a day and then the testbot will probably load them. I am not sure this is the best solution since the list of dependencies will be much longer, could suddenly stop working if other modules change their dependencies and adds complexity that would be better handled by computers than people.

rfay’s picture

Title: Dependency failure? » Improper dependencies generated for uc_dropdown_attributes
Project: Drupal.org Testbots » Project Dependency
Version: » 6.x-1.x-dev
Component: unexplained test failure » Code
Category: support » bug

The project dependency module's job is to find out the chain of dependencies required to test a module.
Currently, it shows only

[rfay@www2 htdocs]$ drush pdsd uc_dropdown_attributes 7.x-1.x-dev
PHP Warning:  PHP Startup: apc.shm_size now uses M/G suffixes, please update your ini files in Unknown on line 0
Array
(
    [1414324] => Array
        (
            [uri] => ubercart
            [version] => 7.x-3.0-rc4
            [tag] => 7.x-3.0-rc4
        )

)

However, we know that uc 3.x requires far more than that. So I'm about to rebuild the dependencies for ubercart 3.x.... And after rebuild they're fine.

[rfay@www2 htdocs]$ drush pdsd ubercart 7.x-3.x-dev
PHP Warning:  PHP Startup: apc.shm_size now uses M/G suffixes, please update your ini files in Unknown on line 0
Array
(
    [1485738] => Array
        (
            [uri] => rules
            [version] => 7.x-2.1
            [tag] => 7.x-2.1
        )

    [1337360] => Array
        (
            [uri] => entity
            [version] => 7.x-1.0-rc1
            [tag] => 7.x-1.0-rc1
        )

    [1451068] => Array
        (
            [uri] => views
            [version] => 7.x-3.3
            [tag] => 7.x-3.3
        )

    [1507412] => Array
        (
            [uri] => ctools
            [version] => 7.x-1.0
            [tag] => 7.x-1.0
        )

    [1108406] => Array
        (
            [uri] => google_analytics
            [version] => 7.x-1.2
            [tag] => 7.x-1.2
        )

)

So this *looks* like a flaw in project_dependency. It's odd that although uc_dropdown_attributes has a dependency on uc_cart and uc_attribute, that dependency chain does not (seem to) get followed correctly.

It's possible that the fact that there's not a module called "ubercart" triggers a particular bug.

Moving this to Project Dependency. It will take some careful database study to sort it out. Thanks for your patience in explaining this. I wish I'd understood earlier that the dependencies required weren't being loaded on the box.

trobey’s picture

I appreciate your time looking at this. The patch I submitted makes the problem more obvious. Without the patch it takes some digging to figure out.

rfay’s picture

Manual analysis of the attributes goes like this:

uc_dropdown_attributes -> uc_attribute -> uc_product -> uc_store -> [nothing]
                                      -> uc_cart -> uc_order -> uc_store
                                                                           -> rules
                                                                           -> views
                                                        -> uc_product

And of course Drupal says on the module page:
Requires: Cart (disabled), Order (disabled), Store (disabled), Rules (missing), Views (missing), Product (disabled), Image (enabled), File (enabled), Field (enabled), Field SQL storage (enabled), Product attributes (disabled)

So somehow we're not finding our way to uc_cart or uc_order's dependencies.

rfay’s picture

It's my belief that the problem is going to come down to the limit on recursion levels, see the attached patch. But I'm out of time for tonight, and can't get this patch to solve the problem.

As you see in the above, rules is 5 levels deep, depending on how you count.

It's obvious we need a better patch, with a variable; if we've had to increase it this time, it may have to be increased again.

Note also, that although I don't think it matters, we're using Ubercart 3.0, since that's the recommended release, not Ubercart 7.x-3.x

rfay’s picture

Status: Active » Needs work

Needs work for two reasons: The patch doesn't actually solve the problem, and it needs to use a variable_get()

trobey’s picture

I do not believe that a limit on recursion levels is necessary. It can be replaced with a check to see if projects have already been added to the dependencies. This will remove the possibility of circular dependencies and the need to limit recursion levels. If circular dependencies are eliminated then there is a finite limit to the number of projects. I would be willing to work on fixing this code. The function is called from the Project Release tests but I get an error that $this->createRelease cannot be found.

rfay’s picture

The tests are completely abandoned, from a much earlier rendition of this module.

rfay’s picture

@trobey I'd be delighted to have you work on this, and would be pleased as punch to help you. You probably need to apply for a sandbox, http://drupal.org/node/1018084. If you do, let me know and I'll push the button. Project Dependency needs to know a pile of info about projects to work, so you need a database.

trobey’s picture

trobey’s picture

It took some digging but here is what is happening. Using uc_dropdown_attributes which depends on uc_attribute and uc_cart, no other dependencies are found, such as uc_product which uc_attribute depends. Why isn't uc_product found? Here is a join of the project_dependency_dependency and project_dependency_component tables for uc_attribute:

*************************** 1. row ***************************
component_id: 331290
release_nid: 1424926
name: uc_attribute
title: Product attributes
description: Extends product content types to support product variations that customers may select before purchase.
dependency_id: 490698
component_id: 331290
dependency: uc_product
core_api: 7.x
external: 0
external_release_nid: 0
dependency_type: 0
1 row in set (0.01 sec)

The dependency field shows uc_product. Why is it not found? From the project_dependency.drupal.inc file at about line 495:

function project_dependency_find_external_dependencies($release_nid, $component_name) {
  $rows = array();
  $query = 'SELECT DISTINCT(pdc.component_id), name AS depender, dependency, release_nid FROM {project_dependency_dependency} pdd INNER JOIN {project_dependency_component} pdc
            ON pdd.component_id = pdc.component_id WHERE  pdc.name = "%s" AND pdc.release_nid = %d AND pdd.external = 1';

Note the "ADD pdd.external =1." Looking at the database the external field is 0. Both uc_attribute and uc_product are in the ubercart project so it is an internal dependency. We do not need internal dependencies do we? Well, actually we do as this case shows. Remove the "ADD pdd.external = 1" and we get the dependencies:

uc_attribute
uc_product
image
uc_store
uc_cart
uc_order
rules
entity
entity_token
views
ctools

This is with the recursion level set to 4.

Patch to soon follow. Then we will need to test it.

trobey’s picture

Here is the patch.

rfay’s picture

Status: Needs work » Needs review

Very nice work.

So what's happening is that a dependency module (component) *within* the same release node package doesn't get followed, right?

I'm a little worried that this will skew the results for other modules and end up adding redundant internal references in. But I think there's a line of code that automatically removes those anyway. Just have to take a look and see.

Nicely done! Thanks!

trobey’s picture

Yes, that is correct. A dependency component within the same release node does not get followed.

rfay’s picture

Here's #22 rolled as a git patch rooted in the project. No changes. Testing today.

@trobey, probably what you should have done on your sandbox was to clone project_dependency into the sites/all/modules/project_dependency directory and then your patch would have been correct.

rfay’s picture

Title: Improper dependencies generated for uc_dropdown_attributes » Internal dependencies not followed properly within a project (uc_dropdown_attributes doesn't get ubercart dependencies)
Status: Needs review » Reviewed & tested by the community

This looks great to me. Casual testing shows it resolves the OP, and I find no breakage with any other dependency generation.

Thanks!

rfay’s picture

Status: Reviewed & tested by the community » Fixed
Issue tags: +needs drupal.org deployment

Committed, http://drupalcode.org/project/project_dependency.git/commitdiff/8cc7a0b

Rolled into release: 6.x-1.0-beta2

Ready for d.o deployment.

rfay’s picture

Issue tags: -needs drupal.org deployment

Deployed on drupal.org.

Rebuilt the dependencies using jenkins and project_dependency_rebuild_project

The dependencies of uc_dropdown_attributes are now

drush pdsd uc_dropdown_attributes 7.x-1.x-dev
Array
(
    [1424926] => Array
        (
            [uri] => ubercart
            [version] => 7.x-3.0
            [tag] => 7.x-3.0
        )

    [1485738] => Array
        (
            [uri] => rules
            [version] => 7.x-2.1
            [tag] => 7.x-2.1
        )

    [1337360] => Array
        (
            [uri] => entity
            [version] => 7.x-1.0-rc1
            [tag] => 7.x-1.0-rc1
        )

    [1451068] => Array
        (
            [uri] => views
            [version] => 7.x-3.3
            [tag] => 7.x-3.3
        )

    [1507412] => Array
        (
            [uri] => ctools
            [version] => 7.x-1.0
            [tag] => 7.x-1.0
        )

)

Looks pretty good to me.

And it looks like success after a retest: http://qa.drupal.org/pifr/test/238834

Congrats and thanks, @trobey!

rfay’s picture

rfay’s picture

Status: Fixed » Needs work

Yeah, OG doesn't work right. It gets og listed as a dependency of itself. Odd that we don't have that problem with ubercart. Perhaps because Ubercart doesn't have a module named ubercart?

rfay’s picture

Title: Internal dependencies not followed properly within a project (uc_dropdown_attributes doesn't get ubercart dependencies) » "Failed to check out": Internal dependencies not followed properly within a project (extra dependency)
Priority: Normal » Critical

Moving to critical, as it appears this breaks many contrib modules. For Example, skinr is broken:

Skinr: http://qa.drupal.org/pifr/test/98689

Ubercart: http://qa.drupal.org/pifr/test/132134

I guess my testing must not have been adequate.

rfay’s picture

Priority: Critical » Normal

I reverted the deployment, so we're now back to 6.x-1.0-beta1 deployed on drupal.org, so this is no longer critical. We can work it at our leisure.

trobey’s picture

I will concentrate here on Organic Groups since it is one of the modules that had problems. For OG 7.x-2.x I get:

Array
(
    [1440836] => Array
        (
            [uri] => og
            [version] => 7.x-2.0-alpha1
            [tag] => 7.x-2.0-alpha1
        )

    [1337360] => Array
        (
            [uri] => entity
            [version] => 7.x-1.0-rc1
            [tag] => 7.x-1.0-rc1
        )

    [1438768] => Array
        (
            [uri] => entityreference
            [version] => 7.x-1.0-beta4
            [tag] => 7.x-1.0-beta4
        )

    [1507412] => Array
        (
            [uri] => ctools
            [version] => 7.x-1.0
            [tag] => 7.x-1.0
        )

    [1430758] => Array
        (
            [uri] => views_bulk_operations
            [version] => 7.x-3.0-rc1
            [tag] => 7.x-3.0-rc1
        )

    [1451068] => Array
        (
            [uri] => views
            [version] => 7.x-3.3
            [tag] => 7.x-3.3
        )

    [1425592] => Array
        (
            [uri] => entityreference_prepopulate
            [version] => 7.x-1.x-dev
            [tag] => 7.x-1.x
        )

    [1393112] => Array
        (
            [uri] => features
            [version] => 7.x-1.0-beta6
            [tag] => 7.x-1.0-beta6
        )

    [1409448] => Array
        (
            [uri] => panels
            [version] => 7.x-3.0
            [tag] => 7.x-3.0
        )

)

This should not include og since it is self referential. Here is the code from the project_dependency_get_external_release_dependencies().

function project_dependency_get_external_release_dependencies($depending_release_nid, $depending_components = array()) {
  module_load_include('inc', 'project_dependency', 'project_dependency.drupal');
  $excluded_dependencies = variable_get('project_dependency_excluded_dependencies', array('drupal', 'simpletest', 'leftandright'));

We want to follow the internal dependencies in OG but not include the og project in the results. So we want og to be part of the excluded dependencies. So add the following code.

  // Include the project for the release node as an excluded dependency.
  $sql = 'SELECT pp.uri AS uri FROM {project_release_nodes} prn
    INNER JOIN {project_projects} pp ON prn.pid=pp.nid WHERE prn.nid=%d';
  $uri = db_result(db_query($sql, $depending_release_nid));
  $excluded_dependencies[] = $uri;

This gives the dependencies as follows.

Array
(
    [1337360] => Array
        (
            [uri] => entity
            [version] => 7.x-1.0-rc1
            [tag] => 7.x-1.0-rc1
        )

    [1438768] => Array
        (
            [uri] => entityreference
            [version] => 7.x-1.0-beta4
            [tag] => 7.x-1.0-beta4
        )

    [1507412] => Array
        (
            [uri] => ctools
            [version] => 7.x-1.0
            [tag] => 7.x-1.0
        )

    [1430758] => Array
        (
            [uri] => views_bulk_operations
            [version] => 7.x-3.0-rc1
            [tag] => 7.x-3.0-rc1
        )

    [1451068] => Array
        (
            [uri] => views
            [version] => 7.x-3.3
            [tag] => 7.x-3.3
        )

    [1425592] => Array
        (
            [uri] => entityreference_prepopulate
            [version] => 7.x-1.x-dev
            [tag] => 7.x-1.x
        )

    [1393112] => Array
        (
            [uri] => features
            [version] => 7.x-1.0-beta6
            [tag] => 7.x-1.0-beta6
        )

    [1409448] => Array
        (
            [uri] => panels
            [version] => 7.x-3.0
            [tag] => 7.x-3.0
        )

)
trobey’s picture

Status: Needs work » Needs review
rfay’s picture

@trobey, I apologize for not getting this in. And now I'm traveling for the next week, so a very poor time to commit or deploy. But I'll at least try to look at it this week. Thanks so much for all your work on this.

rfay’s picture

#33 rerolled with proper root.

rfay’s picture

Status: Needs review » Fixed

Looks good to me. Committed, http://drupalcode.org/project/project_dependency.git/commitdiff/7611b97

Now, we need a new release and deployment. Created 6.x-1.0-beta3

I'm going to be out all morning, so won't deploy now, but may try deploying this afternoon.

Thanks so much, @trobey.

rfay’s picture

Deployment is in progress.

rfay’s picture

Doesn't seem to have broken og, skinr, or uc_dropdown_attributes. YAY!
@trobey++

Sorry for the terrible lapse on this. I had a 3 week interruption in my life.

I'd appreciate it if you'd consider comaintaining this module, since you obviously already have a good grasp of it.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.