Skip to content

Instantly share code, notes, and snippets.

@rfay
Created February 19, 2011 23:37
Show Gist options
  • Save rfay/835507 to your computer and use it in GitHub Desktop.
Save rfay/835507 to your computer and use it in GitHub Desktop.
Migration day code to requeue branch tests See http://drupal.org/node/1057146
<?php
/**
* On Git migration day we have to clean out the existing tests of
* testable branches so they can be tested again. The ones that will already be
* there on QA are all not testable.
*
* This is a translation of the pseudocode in
* http://drupal.org/node/1057146#comment-4073288
*
* It seems to work, and if I'm not mistaken it won't do any damage, but would
* appreciate review.
*
*/
module_load_include('cron.inc', 'pift');
$api_versions = pift_core_api_versions();
$result = db_query('SELECT p.uri, p.nid from {project_projects} p, {pift_project} pp where pp.pid = p.nid');
while ($row = db_fetch_array($result)) {
$projects[$row['nid']] = $row['uri'];
}
foreach ($projects as $nid => $shortname) {
if (!pift_project_enabled($nid)) {
continue;
}
$result = db_query('SELECT nid AS release_nid, tag FROM {project_release_nodes} WHERE pid = %d', $nid);
while ($row = db_fetch_array($result)) {
print "Processing release $shortname: " . $row['tag'] . "\n";
$node = node_load($row['release_nid']);
if (!empty($node)) {
$tids = array_keys($node->taxonomy);
if (array_key_exists($node->project_release['version_api_tid'], $api_versions)) {
$result = db_query('SELECT test_id, status, FROM_UNIXTIME(last_tested) AS last_tested FROM {pift_test} WHERE type = %d AND id = %d', PIFT_TYPE_RELEASE, $node->nid);
while ($row = db_fetch_array($result)) {
print " Requeueing {$row['test_id']} status={$row['status']} last_tested={$row['last_tested']}\n";
pift_test_requeue($row['test_id']);
}
}
}
}
}
@boombatower
Copy link

If joining pift_project then no need to run pift_project_enabled(). Don't have test environment setup, but looks good.

@rfay
Copy link
Author

rfay commented Feb 20, 2011

It's fast enough anyway, and seems to do the right job. I ran it on my local, and it got over to my local qa, and then ran 66 tests or something on my local testbot. So I think all is good.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment