summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2014-02-19 11:35:20 +0000
committerSam Thursfield <sam.thursfield@codethink.co.uk>2014-02-19 11:39:56 +0000
commitd0f2985ff1546f4d223fb4c52cf8bc297a19af03 (patch)
tree6481b226d1d9e95f314054e6769f09fc6ef4abbd
parent2f8e5403cd21d18e14eedf124bd2270516dcac61 (diff)
downloadsystem-tests-d0f2985ff1546f4d223fb4c52cf8bc297a19af03.tar.gz
Remove vm_name parameter and set it as config.DEPLOY_NAME instead
-rw-r--r--config.py4
-rw-r--r--test_trove_upgrades.py98
2 files changed, 52 insertions, 50 deletions
diff --git a/config.py b/config.py
index e53b66a..07ee819 100644
--- a/config.py
+++ b/config.py
@@ -16,6 +16,7 @@
'''Baserock system-test configuration.'''
import os
+import socket
# The test host must have passwordless access to this machine. The tests set
# set StrictHostKeyChecking=no for SSH connections so it does not need to be in
@@ -23,6 +24,9 @@ import os
DEPLOY_URL = 'kvm+ssh://sam@landfill.ducie.codethink.co.uk/'
DEPLOY_PATH = '/home/VIRT-IMAGES/'
+# This is the hostname and VM name of the machine that gets deployed.
+DEPLOY_NAME = 'brtests-%s' % (socket.gethostname())
+
# Seconds to wait for machine to appear on network before assuming it didn't
# boot or connect to network successfully.
BOOT_TIMEOUT=20
diff --git a/test_trove_upgrades.py b/test_trove_upgrades.py
index a6d940b..68b45ac 100644
--- a/test_trove_upgrades.py
+++ b/test_trove_upgrades.py
@@ -83,10 +83,9 @@ class Deployment(object):
so it's often necessary during development to comment out these steps
so that the edit-test cycle is not impossibly long.
'''
- def __init__(self, system_morph_name, deploy_morph_name, systembranch,
- vm_name):
+ def __init__(self, system_morph_name, deploy_morph_name, systembranch):
self.branch = systembranch
- self.vm_name = vm_name
+ self.name = config.DEPLOY_NAME
self.system_morph_name = system_morph_name
self.deploy_morph_name = deploy_morph_name
@@ -99,7 +98,7 @@ class Deployment(object):
def run_deploy(self, autostart=False):
autostart_param = \
- '%s.AUTOSTART=%s' % (self.vm_name, 'yes' if autostart else 'no')
+ '%s.AUTOSTART=%s' % (self.name, 'yes' if autostart else 'no')
run_morph(
['deploy', self.deploy_morph_name, autostart_param],
cwd=self.branch.branch_dir)
@@ -145,10 +144,9 @@ class TroveInitialDeployment(Deployment):
Attribute 'deploy_morph_name' contains a value to passed to 'morph deploy'.
'''
- def __init__(self, systembranch, vm_name):
+ def __init__(self, systembranch):
super(TroveInitialDeployment, self).__init__(
- 'trove-system-x86_64', 'trove-test-deploy', systembranch,
- vm_name)
+ 'trove-system-x86_64', 'trove-test-deploy', systembranch)
def create_config(self, initial_deploy_type='kvm'):
self.create_ssh_key('lorry')
@@ -158,8 +156,8 @@ class TroveInitialDeployment(Deployment):
if initial_deploy_type == 'kvm':
deploy_location = ''.join(
- [config.DEPLOY_URL, self.vm_name, config.DEPLOY_PATH,
- '%s.img' % self.vm_name])
+ [config.DEPLOY_URL, self.name, config.DEPLOY_PATH,
+ '%s.img' % self.name])
else:
raise NotImplementedError()
@@ -179,7 +177,7 @@ class TroveInitialDeployment(Deployment):
DISK_SIZE='3G',
VERSION_LABEL='trove-old',
INSTALL_FILES='%s-files/manifest' % self.deploy_morph_name,
- TROVE_ID=self.vm_name,
+ TROVE_ID=self.name,
TROVE_COMPANY='Codethink',
#UPSTREAM_TROVE='git.baserock.org'
#UPSTREAM_TROVE_USER='nobody'
@@ -201,7 +199,7 @@ class TroveInitialDeployment(Deployment):
dict(
morph=self.system_morph_name,
deploy={
- self.vm_name: trove_config
+ self.name: trove_config
}
)
]
@@ -215,14 +213,13 @@ class TroveInitialDeployment(Deployment):
class TroveUpgrade(Deployment):
- def __init__(self, systembranch, vm_name):
+ def __init__(self, systembranch):
super(TroveUpgrade, self).__init__(
- 'trove-system-x86_64', 'trove-test-upgrade', systembranch,
- vm_name)
+ 'trove-system-x86_64', 'trove-test-upgrade', systembranch)
def run_deploy(self, autostart=False):
autostart_param = \
- '%s.AUTOSTART=%s' % (self.vm_name, 'yes' if autostart else 'no')
+ '%s.AUTOSTART=%s' % (self.name, 'yes' if autostart else 'no')
run_morph(
['deploy', self.deploy_morph_name,
'--upgrade', autostart_param],
@@ -233,7 +230,7 @@ class TroveUpgrade(Deployment):
self.ensure_configure_extension_enabled('install-files')
if upgrade_method == 'ssh-rsync':
- location = 'root@%s' % self.vm_name
+ location = 'root@%s' % self.name
else:
raise NotImplementedError()
@@ -279,7 +276,7 @@ class TroveUpgrade(Deployment):
deploy_morph['name'] = self.deploy_morph_name
- system_config = deploy_morph['systems'][0]['deploy'][self.vm_name]
+ system_config = deploy_morph['systems'][0]['deploy'][self.name]
system_config['type'] = upgrade_method
system_config['location'] = location
system_config['VERSION_LABEL'] = version_label
@@ -350,7 +347,7 @@ class TestInitialDeployment(object):
'''
FIXME: this is out of date! Make it use the 'BaseTestSuite' class instead!
'''
- def initial_deploy(self, branch, vm_name, **deploy_kwargs):
+ def initial_deploy(self, branch, **deploy_kwargs):
'''
Initial deployment of trove-system-x86_64 to a newly-created VM.
@@ -371,7 +368,7 @@ class TestInitialDeployment(object):
trove_deploy = ReuseTroveDeploy(branch)
else:
- trove_deploy = TroveDeployment(branch, vm_name, **deploy_kwargs)
+ trove_deploy = TroveDeployment(branch, **deploy_kwargs)
def test_rawdisk_upgrade(self, workspace_dir):
branch = self.create_system_branch(workspace_dir, 'testbranch')
@@ -435,16 +432,16 @@ class BaseTestSuite(object):
def wait_for_machine_to_boot(self, instance):
wait_time = self.wait_for_hostname_to_appear(
- instance.vm_name, timeout=config.BOOT_TIMEOUT)
+ instance.name, timeout=config.BOOT_TIMEOUT)
if config.VERBOSE:
print "Host %s appeared after %0.1f seconds" % \
- (instance.vm_name, wait_time)
+ (instance.name, wait_time)
# Remove machine from 'known_hosts', as its identity has probably
# changed.
- cliapp.runcmd(['ssh-keygen', '-R', instance.vm_name])
+ cliapp.runcmd(['ssh-keygen', '-R', instance.name])
- test_url = 'ssh://root@%s/' % instance.vm_name
+ test_url = 'ssh://root@%s/' % instance.name
self.wait_for_ssh(
test_url, timeout=config.BOOT_TIMEOUT-wait_time)
@@ -457,13 +454,13 @@ class BaseTestSuite(object):
class TestUpgrades(BaseTestSuite):
@contextlib.contextmanager
- def given_out_of_date_trove_instance(self, vm_name, fixture_dir, reuse=False):
+ def given_out_of_date_trove_instance(self, fixture_dir, reuse=False):
'''
GIVEN a running current Trove system but with lighttpd version 1.3.14
'''
if reuse:
branch = SystemTestBranch(fixture_dir, 'old')
- instance = TroveInitialDeployment(branch, vm_name)
+ instance = TroveInitialDeployment(branch)
instance.admin_id = os.path.join(branch.morphs_dir, 'testuser.key')
else:
branch = self.create_system_branch(fixture_dir, 'old')
@@ -471,7 +468,7 @@ class TestUpgrades(BaseTestSuite):
system='trove-system-x86_64', stratum='trove',
chunk='lighttpd', tag='lighttpd-1.3.14')
- instance = TroveInitialDeployment(branch, vm_name)
+ instance = TroveInitialDeployment(branch)
instance.create_config()
instance.run_build()
instance.run_deploy(autostart=True)
@@ -486,7 +483,7 @@ class TestUpgrades(BaseTestSuite):
# Should pass the .pub file really ...
cliapp.runcmd(['ssh-add', '-d', instance.admin_id])
- def test_scenario_trove_upgrade(self, vm_name, fixture_dir, workspace_dir,
+ def test_scenario_trove_upgrade(self, fixture_dir, workspace_dir,
reuse_fixture=False):
'''
We want to be able to upgrade an old Trove system to the latest
@@ -522,15 +519,15 @@ class TestUpgrades(BaseTestSuite):
'''
with self.given_out_of_date_trove_instance(
- vm_name, fixture_dir, reuse=reuse_fixture) as instance:
+ fixture_dir, reuse=reuse_fixture) as instance:
branch = self.create_system_branch(workspace_dir, 'current')
- test_url = 'ssh://root@%s/' % vm_name
+ test_url = 'ssh://root@%s/' % instance.name
old_lighttpd_output = remote_runcmd(test_url, ['lighttpd', '-v'])
print "Lighttpd outout: %s" % old_lighttpd_output
- upgrade = TroveUpgrade(branch, vm_name)
+ upgrade = TroveUpgrade(branch)
upgrade.create_config(instance, upgrade_method='ssh-rsync',
version_label='trove-current')
upgrade.run_build()
@@ -566,13 +563,13 @@ class TestUpgrades(BaseTestSuite):
# perhaps crib from Gitano test suite
@contextlib.contextmanager
- def given_trove_instance_with_old_kernel(self, vm_name, fixture_dir, reuse=False):
+ def given_trove_instance_with_old_kernel(self, fixture_dir, reuse=False):
'''
GIVEN a running current Trove system but with Linux 3.6
'''
if reuse:
branch = SystemTestBranch(fixture_dir, 'old')
- instance = TroveInitialDeployment(branch, vm_name)
+ instance = TroveInitialDeployment(branch)
instance.admin_id = os.path.join(branch.morphs_dir, 'testuser.key')
else:
branch = self.create_system_branch(fixture_dir, 'old')
@@ -580,7 +577,7 @@ class TestUpgrades(BaseTestSuite):
system='trove-system-x86_64', stratum='bsp-x86_64-generic',
chunk='linux', tag='v3.6')
- instance = TroveInitialDeployment(branch, vm_name)
+ instance = TroveInitialDeployment(branch)
instance.create_config()
instance.run_build()
instance.run_deploy(autostart=True)
@@ -595,8 +592,8 @@ class TestUpgrades(BaseTestSuite):
# Should pass the .pub file really ...
cliapp.runcmd(['ssh-add', '-d', instance.admin_id])
- def test_scenario_trove_kernel_upgrade(self, vm_name, fixture_dir,
- workspace_dir, reuse_fixture=False):
+ def test_scenario_trove_kernel_upgrade(self, fixture_dir, workspace_dir,
+ reuse_fixture=False):
'''
The kernel requires special treatment by the upgrade mechanism because
it is the first thing that loads.
@@ -610,16 +607,16 @@ class TestUpgrades(BaseTestSuite):
'''
with self.given_trove_instance_with_old_kernel(
- vm_name, fixture_dir, reuse=reuse_fixture) as instance:
+ fixture_dir, reuse=reuse_fixture) as instance:
branch = self.create_system_branch(workspace_dir, 'current')
- test_url = 'ssh://root@%s/' % vm_name
+ test_url = 'ssh://root@%s/' % instance.name
old_uname_output = remote_runcmd(
test_url, ['uname', '--kernel-release'])
print "uname output: %s" % old_uname_output
- upgrade = TroveUpgrade(branch, vm_name)
+ upgrade = TroveUpgrade(branch)
upgrade.create_config(instance, upgrade_method='ssh-rsync',
version_label='trove-current')
upgrade.run_build()
@@ -649,7 +646,7 @@ class TestUpgrades(BaseTestSuite):
print "RBK uname output: %s" % rollback_uname_output
def test_scenario_trove_upgrade_shared_user_data(
- self, vm_name, fixture_dir, workspace_dir, reuse_fixture=False):
+ self, 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.
@@ -659,6 +656,10 @@ class TestUpgrades(BaseTestSuite):
- Anything the user puts in /usr, /lib, /bin or /sbin will be
lost on upgrade.
+ This test is simple because currently the method used to share the
+ state is to mount a shared subvolume, so the only thing that can go
+ wrong is for all of a directories contents to be missing.
+
SCENARIO Bob upgrades his Trove
GIVEN a running an out-of-date Trove system
AND files in /opt, /srv, /home, /root and /var
@@ -667,19 +668,19 @@ class TestUpgrades(BaseTestSuite):
THEN the files are present in the new Trove
'''
- statedirs = ['/home', '/opt', '/root', '/srv']
+ statedirs = ['/home', '/opt', '/root', '/srv', '/var']
with self.given_out_of_date_trove_instance(
- vm_name, fixture_dir, reuse=reuse_fixture) as instance:
+ fixture_dir, reuse=reuse_fixture) as instance:
branch = self.create_system_branch(workspace_dir, 'current')
- test_url = 'ssh://root@%s/' % vm_name
+ test_url = 'ssh://root@%s/' % instance.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 = TroveUpgrade(branch)
upgrade.create_config(instance, upgrade_method='ssh-rsync')
upgrade.run_build()
upgrade.run_deploy()
@@ -733,8 +734,8 @@ class SimpleTestRunner(cliapp.Application):
['virsh', '-c', 'qemu:///system'] + args)
except cliapp.AppException as e:
pass
- run_virsh(['destroy', self.vm_name])
- run_virsh(['undefine', self.vm_name])
+ run_virsh(['destroy', vm_name])
+ run_virsh(['undefine', vm_name])
def add_settings(self):
self.settings.string(
@@ -747,10 +748,8 @@ class SimpleTestRunner(cliapp.Application):
def process_args(self, args):
self.check_access_to_deploy_host()
- self.vm_name = 'brtests-%s' % (socket.gethostname())
-
if self.settings['reuse-fixture'] is None:
- self.maybe_delete_vm(self.vm_name)
+ self.maybe_delete_vm(config.DEPLOY_NAME)
self.run_test()
@@ -773,8 +772,7 @@ class SimpleTestRunner(cliapp.Application):
try:
run_morph(['init', workspace_dir])
reuse_fixture = self.settings['reuse-fixture'] is not None
- test(self.vm_name, fixture_dir, workspace_dir,
- reuse_fixture=reuse_fixture)
+ test(fixture_dir, workspace_dir, reuse_fixture=reuse_fixture)
finally:
print "Workspace kept in %s" % workspace_dir
#cliapp.runcmd(['rm', '-r', workspace_dir])