def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.servers_client cls.config = zodiac.config.ZodiacConfig() cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref cls.image_ref_alt = cls.config.env.image_ref_alt cls.flavor_ref_alt = cls.config.env.flavor_ref_alt cls.s1_name = data_gen('server') resp, server = cls.client.create_server(cls.s1_name, cls.image_ref, cls.flavor_ref) cls.client.wait_for_server_status(server['id'], 'ACTIVE') resp, cls.s1 = cls.client.get_server(server['id']) cls.s2_name = data_gen('server') resp, server = cls.client.create_server(cls.s2_name, cls.image_ref_alt, cls.flavor_ref) cls.client.wait_for_server_status(server['id'], 'ACTIVE') resp, cls.s2 = cls.client.get_server(server['id']) cls.s3_name = data_gen('server') resp, server = cls.client.create_server(cls.s3_name, cls.image_ref, cls.flavor_ref_alt) cls.client.wait_for_server_status(server['id'], 'ACTIVE') resp, cls.s3 = cls.client.get_server(server['id'])
def test_create_delete_server(self): meta = { 'hello' : 'world' } accessIPv4 = '1.1.1.1' accessIPv6 = '::babe:220.12.22.2' name = data_gen('server') file_contents = 'This is a test file.' personality = [{'path' : '/etc/test.txt', 'contents' : base64.b64encode(file_contents)}] resp, server = self.client.create_server_object(name, self.image_ref, self.flavor_ref, meta=meta, accessIPv4=accessIPv4, accessIPv6=accessIPv6, personality=personality) #Wait for the server to become active self.client.wait_for_server_status(server.id, 'ACTIVE') #Verify the specified attributes are set correctly # resp, server = self.client.get_server(server['id']) self.assertEqual('1.1.1.1', server.accessIPv4) self.assertEqual('::babe:220.12.22.2', server.accessIPv6) self.assertEqual(name, server.name) self.assertEqual(self.image_ref, server.image.id) self.assertEqual(str(self.flavor_ref), server.flavor.id) #Teardown self.client.delete_server(server.id)
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.servers_client cls.config = zodiac.config.ZodiacConfig() cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref name = data_gen('server') resp, server = cls.client.create_server(name, cls.image_ref, cls.flavor_ref) cls.id = server['id'] cls.client.wait_for_server_status(cls.id, 'ACTIVE')
def test_exceed_server_metadata_limit_on_create(self): """ The amount of metadata items provided on server creation exceeds the compute provider's limit, the request should fail """ meta = { 'key1' : 'value1', 'key2' : 'value2', 'key3' : 'value3', 'key4' : 'value4', 'key5' : 'value5', 'key6' : 'value6'} name = data_gen('server') resp, body = self.client.create_server(name, self.image_ref, self.flavor_ref, meta=meta) self.assertEqual('413', resp['status'])
def test_personality_files_exceed_limit(self): name = data_gen('server') file_contents = 'This is a test file.' personality = [{'path' : '/etc/test1.txt', 'contents' : base64.b64encode(file_contents)}, {'path' : '/etc/test2.txt', 'contents' : base64.b64encode(file_contents)}, {'path' : '/etc/test3.txt', 'contents' : base64.b64encode(file_contents)}, {'path' : '/etc/test4.txt', 'contents' : base64.b64encode(file_contents)}, {'path' : '/etc/test5.txt', 'contents' : base64.b64encode(file_contents)}, {'path' : '/etc/test6.txt', 'contents' : base64.b64encode(file_contents)}] resp, body = self.client.create_server(name, self.image_ref, self.flavor_ref, personality=personality) self.assertEqual('413', resp['status']) self.assertEqual('Personality file limit exceeded', body['overLimit']['message'])
def test_create_delete_image(self): """ An image for the provided server should be created """ name = data_gen('image') resp, body = self.client.create_image(self.id, name) image_id = body['image']['id'] self.images_client.wait_for_image_status(image_id) #Verify the image was created correctly resp, body = self.images_client.get_image(image_id) self.assertEqual(name, body['image']['name']) #Teardown self.images_client.delete()
def setUpClass(cls): cls.os = openstack.Manager() cls.client = cls.os.servers_client cls.config = zodiac.config.ZodiacConfig() cls.image_ref = cls.config.env.image_ref cls.flavor_ref = cls.config.env.flavor_ref cls.meta = { 'test1' : 'value1', 'test2' : 'value2' } name = data_gen('server') resp, server = cls.client.create_server(name, cls.image_ref, cls.flavor_ref, meta=cls.meta) #Wait for the server to become active cls.client.wait_for_server_status(server['id'], 'ACTIVE')
def test_update_server_name(self): """ The server name should be changed to the the provided value """ name = data_gen('server') resp, server = self.client.create_server(name, self.image_ref, self.flavor_ref) self.client.wait_for_server_status(server['id'], 'ACTIVE') #Update the server with a new name self.client.update_server(server['id'], name='newname') self.client.wait_for_server_status(server['id'], 'ACTIVE') #Verify the name of the server has changed resp, server = self.client.get_server(server['id']) self.assertEqual('newname', server['name']) #Teardown self.client.delete_server(server['id'])
def test_update_access_server_address(self): """ The server's access addresses should reflect the provided values """ name = data_gen('server') resp, server = self.client.create_server(name, self.image_ref, self.flavor_ref) self.client.wait_for_server_status(server['id'], 'ACTIVE') #Update the IPv4 and IPv6 access addresses self.client.update_server(server['id'], accessIPv4='1.1.1.1', accessIPv6='::babe:2.2.2.2') self.client.wait_for_server_status(server['id'], 'ACTIVE') #Verify the access addresses have been updated resp, server = self.client.get_server(server['id']) self.assertEqual('1.1.1.1', server['accessIPv4']) self.assertEqual('::babe:2.2.2.2', server['accessIPv6']) #Teardown self.client.delete_server(server['id'])
def test_create_server_with_admin_password(self): """ If an admin password is provided on server creation, the server's root password should be set to that password. """ name = data_gen('server') resp, server = self.client.create_server(name, self.image_ref, self.flavor_ref, adminPass='******') #Verify the password is set correctly in the response self.assertEqual('testpassword', server['adminPass']) #SSH into the server using the set password self.client.wait_for_server_status(server['id'], 'ACTIVE') resp, addresses = self.client.list_addresses(server['id']) ip = addresses['public'][0]['addr'] client = ssh.Client(ip, 'root', 'testpassword', self.ssh_timeout) self.assertTrue(client.test_connection_auth()) #Teardown self.client.delete_server(server['id'])
def setUp(self): self.name = data_gen('server') resp, server = self.client.create_server(self.name, self.image_ref, self.flavor_ref) self.id = server['id'] self.client.wait_for_server_status(self.id, 'ACTIVE')