summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-02-19 13:07:15 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-02-19 13:34:40 +0000
commit9e24500d13d6f3c0e10c519923b9d79bbdfd2031 (patch)
treeb36335553f0ad12768d202ae2075cd192f848ccb
parent99a73f040cef4d1d09054a1f03d690fd4f1333e3 (diff)
downloadsystem-tests-9e24500d13d6f3c0e10c519923b9d79bbdfd2031.tar.gz
Make tests be short and clear, and fix shared user data test
-rw-r--r--test_trove_upgrades.py80
1 files changed, 31 insertions, 49 deletions
diff --git a/test_trove_upgrades.py b/test_trove_upgrades.py
index 9cb7017..898383f 100644
--- a/test_trove_upgrades.py
+++ b/test_trove_upgrades.py
@@ -456,6 +456,25 @@ class BaseTestSuite(object):
class TestUpgrades(BaseTestSuite):
+ def upgrade_to_latest_trove(self, workspace_dir, instance):
+ branch = self.create_system_branch(workspace_dir, 'current')
+ upgrade = TroveUpgrade(branch)
+ upgrade.create_config(instance, upgrade_method='ssh-rsync',
+ version_label='trove-current')
+ upgrade.run_build()
+ upgrade.run_deploy(autostart=True)
+ self.wait_for_machine_to_boot(instance)
+
+ def rollback_system_to_factory(self, instance, version_label):
+ try:
+ instance.runcmd(['snapshot-mgr', 'set-default', version_label])
+ instance.runcmd(['reboot'])
+ except cliapp.AppException:
+ # Bit of a hack because we get disconnect before the command
+ # exits so SSH returns failure.
+ pass
+ self.wait_for_machine_to_boot(instance)
+
def get_lighttpd_version(self, instance, expected_start=None):
text = instance.runcmd(['lighttpd', '-v'])
version_string = text.split(' ')[0]
@@ -537,28 +556,12 @@ class TestUpgrades(BaseTestSuite):
with self.given_out_of_date_trove_instance(
fixture_dir, reuse=reuse_fixture) as instance:
- branch = self.create_system_branch(workspace_dir, 'current')
-
old_lighttpd_version = self.get_lighttpd_version(instance)
- upgrade = TroveUpgrade(branch)
- upgrade.create_config(instance, upgrade_method='ssh-rsync',
- version_label='trove-current')
- upgrade.run_build()
- upgrade.run_deploy(autostart=True)
-
- self.wait_for_machine_to_boot(instance)
+ self.upgrade_to_latest_trove(workspace_dir, instance)
new_lighttpd_version = self.get_lighttpd_version(instance)
- try:
- instance.runcmd(['snapshot-mgr', 'set-default', 'factory'])
- instance.runcmd(['reboot'])
- except cliapp.AppException:
- # Bit of a hack because we get disconnect before the command
- # exits so SSH returns failure.
- pass
-
- self.wait_for_machine_to_boot(instance)
+ self.rollback_system_to_factory(instance)
rollback_lighttpd_version = self.get_lighttpd_version(instance)
if config.VERBOSE:
@@ -566,8 +569,8 @@ class TestUpgrades(BaseTestSuite):
print "Upgraded system lighttpd version: %s" % new_lighttpd_version
print "Lighttpd version after rollback: %s" % rollback_lighttpd_version
- assert old_lighttpd_version == rollback_lighttpd_version
assert new_lighttpd_version > old_lighttpd_version
+ assert old_lighttpd_version == rollback_lighttpd_version
def get_linux_version(self, instance, expected_start=None):
text = instance.runcmd(['uname', '--kernel-release'])
@@ -619,35 +622,19 @@ 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
+ WHEN Bob rolls back to the old version of the system
THEN the Trove uses Linux 3.6
'''
with self.given_trove_instance_with_old_kernel(
fixture_dir, reuse=reuse_fixture) as instance:
- branch = self.create_system_branch(workspace_dir, 'current')
-
old_linux_version = self.get_linux_version(instance)
- upgrade = TroveUpgrade(branch)
- upgrade.create_config(instance, upgrade_method='ssh-rsync',
- version_label='trove-current')
- upgrade.run_build()
- upgrade.run_deploy(autostart=True)
-
- self.wait_for_machine_to_boot(instance)
+ self.upgrade_to_latest_trove(workspace_dir, instance)
new_linux_version = self.get_linux_version(instance)
- try:
- instance.runcmd(['snapshot-mgr', 'set-default', 'factory'])
- instance.runcmd(['reboot'])
- except cliapp.AppException:
- # Bit of a hack because we get disconnect before the command
- # exits so SSH returns failure.
- pass
-
- self.wait_for_machine_to_boot(instance)
+ self.rollback_system_to_factory(instance)
rollback_linux_version = self.get_linux_version(
instance, expected_start=='3.6')
@@ -686,22 +673,16 @@ class TestUpgrades(BaseTestSuite):
with self.given_out_of_date_trove_instance(
fixture_dir, reuse=reuse_fixture) as instance:
- branch = self.create_system_branch(workspace_dir, 'current')
-
for statedir in statedirs:
- cmd = 'echo "Test user data" > %s/TEST_FILE' % statedir
- instance.runcmd(['sh', 'c', cmd])
+ cmd = '\"echo \\"Test user data\\" > %s/TEST_FILE\"' % statedir
+ instance.runcmd(['sh', '-c', cmd])
- upgrade = TroveUpgrade(branch)
- upgrade.create_config(instance, upgrade_method='ssh-rsync')
- upgrade.run_build()
- upgrade.run_deploy()
+ self.upgrade_to_latest_trove(workspace_dir, instance)
for statedir in statedirs:
test_file = '%s/TEST_FILE' % statedir
content = instance.runcmd(['cat', test_file])
- assert content == "Test user data"
-
+ assert content == "Test user data\n"
class SimpleTestRunner(cliapp.Application):
'''
@@ -766,8 +747,9 @@ class SimpleTestRunner(cliapp.Application):
self.run_test()
def run_test(self):
- test = TestUpgrades().test_scenario_trove_upgrade
+ #test = TestUpgrades().test_scenario_trove_upgrade
#test = TestUpgrades().test_scenario_trove_kernel_upgrade
+ test = TestUpgrades().test_scenario_trove_upgrade_shared_user_data
if self.settings['reuse-fixture'] is not None:
fixture_dir = self.settings['reuse-fixture']