def setUp(self): (download_cache_dir, reference_cloud_image_name) = requires_known_reference_image(self) super(TestImageWithBacking, self).setUp() # We'll share the images_dir between vms images_dir = os.path.join(self.test_base_dir, 'images') os.mkdir(images_dir) # Create a shared config conf = setup_vm.VmStack(None) conf.store._load_from_string(''' vm.release=raring vm.images_dir=%s vm.download_cache=%s vm.disk_size=2G [selftest-from-cloud] vm.name=selftest-from-cloud vm.cloud_image_name=%s [selftest-backing] vm.name=selftest-backing vm.backing=selftest-from-cloud.qcow2 ''' % (images_dir, download_cache_dir, reference_cloud_image_name)) conf.store.save() # To bypass creating a real vm, we start from the cloud image that is a # real and bootable one, so we just convert it. That also makes it # available in vm.images_dir temp_vm = setup_vm.KvmFromCloudImage( setup_vm.VmStack('selftest-from-cloud')) temp_vm.create_disk_image()
def setUp(self): super(TestVmStack, self).setUp() self.conf = setup_vm.VmStack('foo') self.conf.store._load_from_string(''' vm.release=raring vm.cpu_model=amd64 ''')
def setUp(self): (download_cache, reference_cloud_image_name) = requires_known_reference_image(self) super(TestInstallWithSeed, self).setUp() # We need to allow other users to read this dir os.chmod(self.test_base_dir, 0755) # We also need to sudo rm it as root created some files there self.addCleanup(setup_vm.run_subprocess, [ 'sudo', 'rm', '-fr', os.path.join(self.test_base_dir, 'home', '.virtinst') ]) self.conf = setup_vm.VmStack('selftest-seed') self.vm = setup_vm.KvmFromCloudImage(self.conf) images_dir = os.path.join(self.test_base_dir, 'images') os.mkdir(images_dir, 0755) config_dir = os.path.join(self.test_base_dir, 'config') self.conf.store._load_from_string(''' vm.name=selftest-seed vm.update=False # Shorten install time vm.cpus=2, vm.release=raring vm.config_dir=%s vm.images_dir=%s vm.download_cache=%s vm.cloud_image_name=%s vm.disk_size=8G ''' % (config_dir, images_dir, download_cache, reference_cloud_image_name))
def requires_known_reference_image(test): # We need a pre-seeded download cache from the user running the tests # as downloading the cloud image is too long. user_conf = setup_vm.VmStack(None) download_cache = user_conf.get('vm.download_cache') if download_cache is None: test.skip('vm.download_cache is not set') # We use some known reference reference_cloud_image_name = 'raring-server-cloudimg-amd64-disk1.img' cloud_image_path = os.path.join(download_cache, reference_cloud_image_name) if not os.path.exists(cloud_image_path): test.skip('%s is not available' % (cloud_image_path, )) return download_cache, reference_cloud_image_name
def setUp(self): (download_cache_dir, reference_cloud_image_name) = requires_known_reference_image(self) super(TestInstallWithBacking, self).setUp() # We need to allow other users to read this dir os.chmod(self.test_base_dir, 0755) # We also need to sudo rm it as root created some files there self.addCleanup(setup_vm.run_subprocess, [ 'sudo', 'rm', '-fr', os.path.join(self.test_base_dir, 'home', '.virtinst') ]) self.conf = setup_vm.VmStack('selftest-backing') self.vm = setup_vm.KvmFromBacking(self.conf) # We'll share the images_dir between vms images_dir = os.path.join(self.test_base_dir, 'images') os.mkdir(images_dir, 0755) config_dir = os.path.join(self.test_base_dir, 'config') # Create a shared config conf = setup_vm.VmStack(None) conf.store._load_from_string(''' vm.release=raring vm.config_dir=%s vm.images_dir=%s vm.download_cache=%s vm.disk_size=2G vm.update=False # Shorten install time [selftest-from-cloud] vm.name=selftest-from-cloud vm.cloud_image_name=%s [selftest-backing] vm.name=selftest-backing vm.backing=selftest-from-cloud.qcow2 ''' % (config_dir, images_dir, download_cache_dir, reference_cloud_image_name)) conf.store.save() # Fake a previous install by just re-using the reference cloud image temp_vm = setup_vm.KvmFromCloudImage( setup_vm.VmStack('selftest-from-cloud')) temp_vm.create_disk_image()
def setUp(self): # Downloading real isos or images is too long for tests, instead, we # fake it by downloading a small but known to exist file: MD5SUMS super(TestDownload, self).setUp() download_cache = os.path.join(self.test_base_dir, 'downloads') os.mkdir(download_cache) self.conf = setup_vm.VmStack('foo') self.conf.store._load_from_string(''' vm.iso_name=MD5SUMS vm.cloud_image_name=MD5SUMS vm.release=raring vm.cpu_model=amd64 vm.download_cache=%s ''' % (download_cache, ))
def setUp(self): super(TestMetaData, self).setUp() self.conf = setup_vm.VmStack('foo') self.vm = setup_vm.Kvm(self.conf) images_dir = os.path.join(self.test_base_dir, 'images') os.mkdir(images_dir) config_dir = os.path.join(self.test_base_dir, 'config') self.conf.store._load_from_string(''' vm.name=foo vm.images_dir=%s vm.config_dir=%s ''' % ( images_dir, config_dir, ))
def setUp(self): super(TestInstall, self).setUp() self.conf = setup_vm.VmStack('I-dont-exist') self.conf.store._load_from_string(''' vm.name=I-dont-exist vm.release=raring vm.cpu_model=amd64 ''') self.states = [] def vm_states(source=None): return self.states self.patch(setup_vm, 'vm_states', vm_states) self.vm = None
def setUp(self): super(TestImageFromCloud, self).setUp() self.conf = setup_vm.VmStack('foo') self.vm = setup_vm.KvmFromCloudImage(self.conf) images_dir = os.path.join(self.test_base_dir, 'images') os.mkdir(images_dir) download_cache_dir = os.path.join(self.test_base_dir, 'download') os.mkdir(download_cache_dir) self.conf.store._load_from_string(''' vm.name=foo vm.release=raring vm.images_dir=%s vm.download_cache=%s vm.cloud_image_name=fake.img vm.disk_size=1M ''' % (images_dir, download_cache_dir))
def setUp(self): super(TestSshKeyGen, self).setUp() self.conf = setup_vm.VmStack(None) self.vm = setup_vm.VM(self.conf) self.config_dir = os.path.join(self.test_base_dir, 'config')
def test_install_with_backing(self): vm = setup_vm.KvmFromBacking(setup_vm.VmStack('selftest-backing')) self.addCleanup(vm.undefine) vm.install() self.assertVmState(vm, 'shut off')
def setUp(self): super(TestVmStores, self).setUp() self.conf = setup_vm.VmStack('foo')
def test_create_image_with_backing(self): vm = setup_vm.KvmFromBacking(setup_vm.VmStack('selftest-backing')) self.assertTrue(vm._disk_image_path is None) vm.create_disk_image() self.assertFalse(vm._disk_image_path is None) self.assertTrue(os.path.exists(vm._disk_image_path))
def setUp(self): super(TestCreateUserData, self).setUp() self.conf = setup_vm.VmStack('foo') self.vm = setup_vm.Kvm(self.conf)
def setUp(self): super(TestCIUserData, self).setUp() self.conf = setup_vm.VmStack('foo') self.ci_data = setup_vm.CIUserData(self.conf)
def setUp(self): super(TestLaunchpadAccess, self).setUp() self.conf = setup_vm.VmStack('foo') self.vm = setup_vm.Kvm(self.conf) self.ci_data = setup_vm.CIUserData(self.conf)