From feef45bb2f483ae2a2ccf37839833430b998d624 Mon Sep 17 00:00:00 2001 From: Sam Thursfield Date: Thu, 13 Feb 2014 19:24:58 +0000 Subject: Add test for shared user data --- test_trove_upgrades.py | 46 +++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/test_trove_upgrades.py b/test_trove_upgrades.py index b18eb93..55f4c08 100644 --- a/test_trove_upgrades.py +++ b/test_trove_upgrades.py @@ -554,8 +554,7 @@ class TestUpgrades(BaseTestSuite): old_lighttpd_output = remote_runcmd(test_url, ['lighttpd', '-v']) print "Lighttpd outout: %s" % old_lighttpd_output - upgrade = TroveUpgrade( - branch, vm_name) + upgrade = TroveUpgrade(branch, vm_name) upgrade.create_config(instance, upgrade_method='ssh-rsync') upgrade.run_build() upgrade.run_deploy() @@ -596,6 +595,47 @@ class TestUpgrades(BaseTestSuite): # check you can issue Gitano commands ... # perhaps crib from Gitano test suite + def test_scenario_trove_upgrade_shared_user_data( + self, vm_name, fixture_dir, workspace_dir, reuse_fixture=False): + ''' + Ensure that the user does not lose data when upgrading in the brave new + world of separating the base OS from the OS state and the user data. + + There are some holes at the moment: + - Anything the user puts in / directly will be lost on upgrade. + - Anything the user puts in /usr, /lib, /bin or /sbin will be + lost on upgrade. + + SCENARIO Bob upgrades his Trove + GIVEN a running an out-of-date Trove system + AND files in /opt, /srv, /home, /root and /var + WHEN Bob builds and upgrades to the current version of Trove with + AUTOSTART=1 + THEN the files are present in the new Trove + + ''' + statedirs = ['/home', '/opt', '/root', '/srv'] + + with self.given_out_of_date_trove_instance( + vm_name, fixture_dir, reuse=reuse_fixture) as instance: + branch = self.create_system_branch(workspace_dir, 'current') + + test_url = 'ssh://root@%s/' % vm_name + + for statedir in statedirs: + cmd = 'echo "Test user data" > %s/TEST_FILE' % statedir + remote_runcmd(test_url, ['sh', 'c', cmd]) + + upgrade = TroveUpgrade(branch, vm_name) + upgrade.create_config(instance, upgrade_method='ssh-rsync') + upgrade.run_build() + upgrade.run_deploy() + + for statedir in statedirs: + test_file = '%s/TEST_FILE' % statedir + content = remote_runcmd(test_url, ['cat', test_file]) + assert content == "Test user data" + class SimpleTestRunner(cliapp.Application): ''' @@ -660,7 +700,7 @@ class SimpleTestRunner(cliapp.Application): self.run_test() def run_test(self): - test = TestUpgrades().test_scenario_trove_upgrade + test = TestUpgrades().test_scenario_trove_upgrade_shared_user_data if self.settings['reuse-fixture'] is not None: fixture_dir = self.settings['reuse-fixture'] -- cgit v1.2.1