Commit 49a32cdf authored by Steven Jones's avatar Steven Jones

Add a migrate test, and cleanup.

We now test migrating 6->7, and if possible 5->6->7. We also don't reference mig5 in the tests any more, for aesthetic reasons.
parent bc46c1d6
......@@ -23,7 +23,7 @@ function provision_tests_drush_command() {
'hosting',
),
);
return $items;
}
......@@ -31,36 +31,58 @@ function provision_tests_drush_command() {
* Drush command to run the provision tests.
*/
function drush_provision_tests_run() {
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
$drupal5_tests = TRUE;
}
else {
$drupal5_tests = FALSE;
drush_log(dt('Please note that because you are running PHP 5.3 or greater, you cannot test installing Drupal 5 on this machine.'), 'warning');
}
if (!drush_confirm(dt('This command should only be run on a clean Aegir install, and data may be lost! Do you want to continue?'))) {
return drush_user_abort();
}
// Disable the tasks queue, we run them manually instead.
// Todo: turn this back on after the tests have run.
provision_backend_invoke('@hostmaster', 'vset', array('hosting_queue_tasks_enabled', '0'));
$queue_status_initial = variable_get('hosting_queue_tasks_enabled', '0');
variable_set('hosting_queue_tasks_enabled', '0');
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
if ($drupal5_tests) {
drush_provision_tests_install_platform('drupal5');
}
drush_provision_tests_install_platform('drupal6');
drush_provision_tests_install_platform('drupal7');
drush_provision_tests_install_platform('openatrium');
// Install some sites.
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
drush_provision_tests_install_site('drupal5', 'default');
if ($drupal5_tests) {
drush_provision_tests_install_site('drupal5', 'drupal5-default', 'default');
}
drush_provision_tests_install_site('drupal6', 'default');
drush_provision_tests_install_site('drupal7', 'standard');
drush_provision_tests_install_site('openatrium', 'openatrium');
drush_provision_tests_install_site('drupal6', 'drupal6-default', 'default');
drush_provision_tests_install_site('drupal7', 'drupal7-standard', 'standard');
drush_provision_tests_install_site('drupal7', 'drupal7-minimal', 'minimal');
drush_provision_tests_install_site('openatrium', 'openatrium-openatrium', 'openatrium');
// Remove the sites.
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
drush_provision_tests_remove_site('drupal5', 'default');
if ($drupal5_tests) {
drush_provision_tests_remove_site('drupal5-default', 'default');
}
drush_provision_tests_remove_site('drupal6-default');
drush_provision_tests_remove_site('drupal7-standard');
drush_provision_tests_remove_site('drupal7-minimal');
drush_provision_tests_remove_site('openatrium-openatrium');
// Create some sites, and migrate them
if ($drupal5_tests) {
drush_provision_tests_install_site('drupal5', 'drupal5-migrate-drupal7', 'default');
drush_provision_tests_migrate_site('drupal5-migrate-drupal7', 'drupal6');
drush_provision_tests_migrate_site('drupal5-migrate-drupal7', 'drupal7');
drush_provision_tests_remove_site('drupal5-migrate-drupal7');
}
drush_provision_tests_remove_site('drupal6', 'default');
drush_provision_tests_remove_site('drupal7', 'standard');
drush_provision_tests_remove_site('openatrium', 'openatrium');
drush_provision_tests_install_site('drupal6', 'drupal6-migrate-drupal7', 'default');
drush_provision_tests_migrate_site('drupal6-migrate-drupal7', 'drupal7');
drush_provision_tests_remove_site('drupal6-migrate-drupal7');
// Clean up a little.
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
drush_provision_tests_remove_platform('drupal5');
......@@ -68,16 +90,22 @@ function drush_provision_tests_run() {
drush_provision_tests_remove_platform('drupal6');
drush_provision_tests_remove_platform('drupal7');
drush_provision_tests_remove_platform('openatrium');
// Restore the tasks queue status:
variable_set('hosting_queue_tasks_enabled', $queue_status_initial);
if (drush_get_error() != DRUSH_SUCCESS) {
return drush_set_error(drush_get_error(), 'Running tests failed');
}
drush_log(dt('Tests completed successfully'), 'success');
}
/**
* Helper function to install a platform.
*/
function drush_provision_tests_install_platform($platform_name) {
drush_log(dt('Building platform: @platform and adding to hostmaster.', array('@platform' => $platform_name)), 'ok');
$args = array(
PROVISION_TESTS_BUILDS_REPO . "/$platform_name.build",
"/var/aegir/platforms/$platform_name"
......@@ -97,6 +125,7 @@ function drush_provision_tests_install_platform($platform_name) {
* Helper function to remove a platform.
*/
function drush_provision_tests_remove_platform($platform_name) {
drush_log(dt('Removing platform: @platform.', array('@platform' => $platform_name)), 'ok');
provision_backend_invoke('@hostmaster', 'hosting-task', array("@platform_$platform_name", 'delete'), array('force' => TRUE));
drush_provision_tests_run_remaining_tasks();
}
......@@ -104,10 +133,11 @@ function drush_provision_tests_remove_platform($platform_name) {
/**
* Helper function to install a site.
*/
function drush_provision_tests_install_site($platform_name, $profile_name) {
function drush_provision_tests_install_site($platform_name, $site, $profile_name) {
drush_log(dt('Installing: @site on platform: @platform with profile: @profile.', array('@site' => "$site.aegir.example.com", '@platform' => $platform_name, '@profile' => $profile_name)), 'ok');
$args = array(
'uri' => "$platform_name.mig5.net",
"@$platform_name.mig5.net",
'uri' => "$site.aegir.example.com",
"@$site.aegir.example.com",
'context_type' => 'site',
'platform' => "@platform_$platform_name",
'profile' => $profile_name,
......@@ -115,7 +145,7 @@ function drush_provision_tests_install_site($platform_name, $profile_name) {
'root' => "/var/aegir/platforms/$platform_name",
);
drush_backend_invoke('provision-save', $args);
provision_backend_invoke("@$platform_name.mig5.net", 'provision-install');
provision_backend_invoke("@$site.aegir.example.com", 'provision-install');
provision_backend_invoke('@hostmaster', 'hosting-task', array("@platform_$platform_name", 'verify'), array('force' => TRUE));
drush_provision_tests_run_remaining_tasks();
}
......@@ -123,8 +153,31 @@ function drush_provision_tests_install_site($platform_name, $profile_name) {
/**
* Helper function to delete a site.
*/
function drush_provision_tests_remove_site($platform_name, $profile_name) {
provision_backend_invoke('@hostmaster', 'hosting-task', array("@$platform_name.mig5.net", 'delete'), array('force' => TRUE));
function drush_provision_tests_remove_site($site) {
drush_log(dt('Removing: @site.', array('@site' => "$site.aegir.example.com")), 'ok');
provision_backend_invoke('@hostmaster', 'hosting-task', array("@$site.aegir.example.com", 'delete'), array('force' => TRUE));
drush_provision_tests_run_remaining_tasks();
}
/**
* Migrates a site from one platform to another.
*
* @param $site
* The site to migrate.
* @param $target
* The target platform to migrate to.
*/
function drush_provision_tests_migrate_site($site, $target) {
drush_log(dt('Migrating: @site to platform: @platform.', array('@site' => "$site.aegir.example.com", '@platform' => $target)), 'ok');
// Do the migrate.
provision_backend_invoke("@$site.aegir.example.com", 'provision-migrate', array("@platform_$target",));
// Import the site into the frontend.
provision_backend_invoke('@hostmaster', 'hosting-import', array("@$site.aegir.example.com",));
// Verify the $target platform.
provision_backend_invoke('@hostmaster', 'hosting-task', array("@platform_$target", 'verify'), array('force' => TRUE));
// Import and verify the site.
provision_backend_invoke('@hostmaster', 'hosting-import', array("@$site.aegir.example.com",));
provision_backend_invoke('@hostmaster', 'hosting-task', array("@$site.aegir.example.com", 'verify'), array('force' => TRUE));
drush_provision_tests_run_remaining_tasks();
}
......@@ -137,9 +190,8 @@ function drush_provision_tests_run_remaining_tasks() {
while ($node = db_fetch_object($result)) {
$tasks[$node->nid] = node_load($node->nid);
}
foreach ($tasks as $task) {
provision_backend_invoke('@hostmaster', "hosting-task", array($task->nid), array('force' => TRUE));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment