From 6038dcf085f3631fab3ff93afd91ed88bb1914e1 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Wed, 19 Feb 2014 12:27:17 +0000 Subject: Actually assert correct versions of components are there Also add rollback to stories. --- test_trove_upgrades.py | 85 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 51 insertions(+), 34 deletions(-) diff --git a/test_trove_upgrades.py b/test_trove_upgrades.py index 68b45ac..aed3a08 100644 --- a/test_trove_upgrades.py +++ b/test_trove_upgrades.py @@ -48,6 +48,7 @@ Helpful advice: import cliapp import contextlib +import distutils.version import os import shutil import socket @@ -453,6 +454,17 @@ class BaseTestSuite(object): class TestUpgrades(BaseTestSuite): + def get_lighttpd_version(self, test_url, expected_start=None): + text = remote_runcmd(test_url, ['lighttpd', '-v']) + version_string = text.split(' ')[0] + version = distutils.version.LooseVersion( + version_string[len('lighttpd-'):]) + if config.VERBOSE: + print "lighttpd output: %s (%s)" % (text, version.version) + if expected_start is not None: + assert text.startswith(expected_start) + return version + @contextlib.contextmanager def given_out_of_date_trove_instance(self, fixture_dir, reuse=False): ''' @@ -477,7 +489,9 @@ class TestUpgrades(BaseTestSuite): try: self.wait_for_machine_to_boot(instance) - + test_url = 'ssh://root@%s/' % instance.name + self.get_lighttpd_version( + test_url, expected_start='lighttpd-1.3.14') yield instance finally: # Should pass the .pub file really ... @@ -516,6 +530,8 @@ class TestUpgrades(BaseTestSuite): WHEN Bob upgrades to the current version of Trove and sets it to autostart immediately THEN the Trove uses a newer version of lightttpd than 1.3.14 + WHEN Bob rolls back to the old version of Trove + THEN the Trove uses lighttpd version 1.3.14 ''' with self.given_out_of_date_trove_instance( @@ -523,9 +539,7 @@ class TestUpgrades(BaseTestSuite): branch = self.create_system_branch(workspace_dir, 'current') test_url = 'ssh://root@%s/' % instance.name - - old_lighttpd_output = remote_runcmd(test_url, ['lighttpd', '-v']) - print "Lighttpd outout: %s" % old_lighttpd_output + old_lighttpd_version = self.get_lighttpd_version(test_url) upgrade = TroveUpgrade(branch) upgrade.create_config(instance, upgrade_method='ssh-rsync', @@ -534,8 +548,7 @@ class TestUpgrades(BaseTestSuite): upgrade.run_deploy(autostart=True) self.wait_for_machine_to_boot(instance) - - new_lighttpd_output = remote_runcmd(test_url, ['lighttpd', '-v']) + new_lighttpd_version = self.get_lighttpd_version(test_url) try: remote_runcmd(test_url, @@ -547,20 +560,24 @@ class TestUpgrades(BaseTestSuite): pass self.wait_for_machine_to_boot(instance) - rollback_lighttpd_output = remote_runcmd(test_url, ['lighttpd', '-v']) + rollback_lighttpd_version = self.get_lighttpd_version(test_url) - print "OLD Lighttpd outout: %s" % old_lighttpd_output - print "NEW Lighttpd outout: %s" % new_lighttpd_output - print "RBK Lighttpd output: %s" % rollback_lighttpd_output + if config.VERBOSE: + print "Base system lighttpd version: %s" % old_lighttpd_version + print "Upgraded system lighttpd version: %s" % new_lighttpd_version + print "Lighttpd version after rollback: %s" % rollback_lighttpd_version - # We have a machine! - # Initial tests to run: - # check system metadata against what should have been built - # Trove tests: - # check you can lorry something - # check you can 'git pull' something - # check you can issue Gitano commands ... - # perhaps crib from Gitano test suite + assert old_lighttpd_version == rollback_lighttpd_version + assert new_lighttpd_version > old_lighttpd_version + + def get_linux_version(self, test_url, expected_start=None): + text = remote_runcmd(test_url, ['uname', '--kernel-release']) + version = distutils.version.LooseVersion(text) + if config.VERBOSE: + print "uname output: %s (%s)" % (text, version.version) + if expected_start is not None: + assert text.startswith(expected_start) + return version @contextlib.contextmanager def given_trove_instance_with_old_kernel(self, fixture_dir, reuse=False): @@ -586,7 +603,7 @@ class TestUpgrades(BaseTestSuite): try: self.wait_for_machine_to_boot(instance) - + self.get_linux_version(test_url, expected_start='3.6') yield instance finally: # Should pass the .pub file really ... @@ -603,6 +620,8 @@ class TestUpgrades(BaseTestSuite): WHEN Bob builds and upgrades to the current version of Trove with AUTOSTART=1 THEN the Trove uses the standard version of Linux used Baserock master + WHEN Bob rolls back to the old version of Linux + THEN the Trove uses Linux 3.6 ''' @@ -611,10 +630,7 @@ class TestUpgrades(BaseTestSuite): branch = self.create_system_branch(workspace_dir, 'current') test_url = 'ssh://root@%s/' % instance.name - - old_uname_output = remote_runcmd( - test_url, ['uname', '--kernel-release']) - print "uname output: %s" % old_uname_output + old_linux_version = self.get_linux_version(test_url) upgrade = TroveUpgrade(branch) upgrade.create_config(instance, upgrade_method='ssh-rsync', @@ -623,10 +639,7 @@ class TestUpgrades(BaseTestSuite): upgrade.run_deploy(autostart=True) self.wait_for_machine_to_boot(instance) - - new_uname_output = remote_runcmd( - test_url, ['uname', '--kernel-release']) - print "uname output: %s" % new_uname_output + new_linux_version = self.get_linux_version(test_url) try: remote_runcmd(test_url, @@ -638,12 +651,16 @@ class TestUpgrades(BaseTestSuite): pass self.wait_for_machine_to_boot(instance) - rollback_uname_output = remote_runcmd( - test_url, ['uname', '--kernel-release']) + rollback_linux_version = self.get_linux_version( + test_url, expected_start=='3.6') + + if config.VERBOSE: + print "Base system linux version: %s" % old_linux_version + print "Upgraded system linux version: %s" % new_linux_version + print "Rollback linux version: %s" % rollback_linux_version - print "OLD uname outout: %s" % old_uname_output - print "NEW uname outout: %s" % new_uname_output - print "RBK uname output: %s" % rollback_uname_output + assert old_linux_version == rollback_linux_version + assert new_linux_version > old_linux_version def test_scenario_trove_upgrade_shared_user_data( self, fixture_dir, workspace_dir, reuse_fixture=False): @@ -754,8 +771,8 @@ class SimpleTestRunner(cliapp.Application): self.run_test() def run_test(self): - #test = TestUpgrades().test_scenario_trove_upgrade - test = TestUpgrades().test_scenario_trove_kernel_upgrade + test = TestUpgrades().test_scenario_trove_upgrade + #test = TestUpgrades().test_scenario_trove_kernel_upgrade if self.settings['reuse-fixture'] is not None: fixture_dir = self.settings['reuse-fixture'] -- cgit v1.2.1