def validate_exist_entry_audit_period_values( self, expected_audit_period_ending, expected_audit_period_beginning, event_exist_server=None): """ @summary: Validate that the Exist entry will have all expected values related to audit periods @param expected_audit_period_ending: The expected audit period ending of the server @type expected_audit_period_ending: datetime @param expected_audit_period_beginning: The expected audit period beginning of the server @type expected_audit_period_beginning: datetime @param event_exist_server: Details of the event Exist from DB @type event_exist_server: ServerExists """ self.event_exist_server = self.event_exist if event_exist_server: self.event_exist_server = event_exist_server self.assertTrue(EqualityTools.are_datetimes_equal( string_to_datetime(expected_audit_period_ending), string_to_datetime(self.event_exist_server.audit_period_ending), timedelta(seconds=self.leeway))) self.assertTrue(EqualityTools.are_datetimes_equal( string_to_datetime(expected_audit_period_beginning), string_to_datetime(self.event_exist_server.audit_period_beginning), timedelta(seconds=self.leeway))) self.assertTrue(EqualityTools.are_datetimes_equal( string_to_datetime(expected_audit_period_ending), string_to_datetime(self.event_exist_server.received), timedelta(seconds=self.leeway)))
def test_exists_entry_fields_on_rescue_server_response(self): """ Verify that the Exist entry will have all expected fields after Server Rescue """ self.validate_exist_entry_field_values(server=self.unrescued_server) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.rescue_start_time), string_to_datetime(self.event_exist.audit_period_ending), timedelta(seconds=self.leeway), ) ) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.audit_period_beginning), string_to_datetime(self.event_exist.audit_period_beginning), timedelta(seconds=self.leeway), ) ) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.rescue_start_time), string_to_datetime(self.event_exist.received), timedelta(seconds=self.leeway), ) )
def test_delete_entry_fields_on_delete_server_response(self): """ Verify that the Delete entry will have all expected fields after Server Delete """ self.assertEqual( self.deleted_server.id, self.event_delete.instance, self.msg.format("instance", self.deleted_server.id, self.event_delete.instance, self.delete_response.reason, self.delete_response.content)) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.launched_at_created_server), string_to_datetime(self.event_delete.launched_at), timedelta(seconds=self.leeway)), self.msg.format("launched_at", self.launched_at_created_server, self.event_delete.launched_at, self.delete_response.reason, self.delete_response.content)) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.deleted_at), string_to_datetime(self.event_delete.deleted_at), timedelta(seconds=self.leeway)), self.msg.format("deleted_at", self.deleted_at, self.event_delete.deleted_at, self.delete_response.reason, self.delete_response.content))
def test_delete_entry_fields_on_delete_server_response(self): """ Verify that the Delete entry will have all expected fields after Server Delete """ self.assertEqual(self.deleted_server.id, self.event_delete.instance, self.msg.format("instance", self.deleted_server.id, self.event_delete.instance, self.delete_response.reason, self.delete_response.content)) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.launched_at_created_server), string_to_datetime(self.event_delete.launched_at), timedelta(seconds=self.leeway)), self.msg.format("launched_at", self.launched_at_created_server, self.event_delete.launched_at, self.delete_response.reason, self.delete_response.content)) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.deleted_at), string_to_datetime(self.event_delete.deleted_at), timedelta(seconds=self.leeway)), self.msg.format("deleted_at", self.deleted_at, self.event_delete.deleted_at, self.delete_response.reason, self.delete_response.content))
def test_ram_and_disk_size_on_resize_up_server_revert(self): """ The server's RAM and disk space should return to its original values after a resize is reverted """ server_response = self.server_behaviors.create_active_server() server_to_resize = server_response.entity self.resources.add(server_to_resize.id, self.servers_client.delete_server) #resize server and revert self.servers_client.resize(server_to_resize.id, self.flavor_ref_alt) self.server_behaviors.wait_for_server_status(server_to_resize.id, NovaServerStatusTypes.VERIFY_RESIZE) self.servers_client.revert_resize(server_to_resize.id) reverted_server_response = self.server_behaviors.wait_for_server_status(server_to_resize.id, NovaServerStatusTypes.ACTIVE) reverted_server = reverted_server_response.entity flavor_response = self.flavors_client.get_flavor_details(self.flavor_ref) flavor = flavor_response.entity # Verify that the server resize was reverted public_address = self.server_behaviors.get_public_ip_address(reverted_server) reverted_server.admin_pass = server_to_resize.admin_pass remote_instance = self.server_behaviors.get_remote_instance_client(reverted_server, self.servers_config, public_address) self.assertEqual(self.flavor_ref, reverted_server.flavor.id, msg="Flavor id not reverted") lower_limit = int(flavor.ram) - (int(flavor.ram) * .1) server_ram_size = int(remote_instance.get_ram_size_in_mb()) self.assertTrue(int(flavor.ram) == server_ram_size or lower_limit <= server_ram_size, msg="Ram size after revert did not match.Expected ram size : %s, Actual ram size : %s" % (flavor.ram, server_ram_size)) self.assertTrue(EqualityTools.are_sizes_equal(flavor.disk, remote_instance.get_disk_size_in_gb(), 0.5), msg="Disk size %s after revert did not match %s" % (remote_instance.get_disk_size_in_gb(), flavor.disk))
def __eq__(self, other): """ @summary: Overrides the default equals @param other: Server object to compare with @type other: Server @return: True if Server objects are equal, False otherwise @rtype: bool """ return EqualityTools.are_objects_equal(self, other, ["admin_pass", "updated", "progress"])
def __eq__(self, other): """ :summary: Overrides the default equals :param other: Links object to compare with :type other: Links :return: True if Links objects are equal, False otherwise :rtype: bool """ return EqualityTools.are_objects_equal(self, other)
def __eq__(self, other): """ @summary: Overrides the default equals @param other: Image object to compare with @type other: Image @return: True if Image objects are equal, False otherwise @rtype: bool """ return EqualityTools.are_objects_equal(self, other)
def __eq__(self, other): """ @summary: Overrides the default equals @param other: Flavor object to compare with @type other: Flavor @return: True if Flavor objects are equal, False otherwise @rtype: bool """ return EqualityTools.are_objects_equal(self, other)
def __ne__(self, other): """ @summary: Overrides the default not-equals @param other: SecurityGroupRule object to compare with @type other: SecurityGroupRule @return: True if SecurityGroupRule objects are not equal, False otherwise @rtype: bool """ return not EqualityTools.are_objects_equal(self, other)
def __eq__(self, other): """ @summary: Overrides the default equals @param other: Server object to compare with @type other: Server @return: True if Server objects are equal, False otherwise @rtype: bool """ return EqualityTools.are_objects_equal( self, other, ['admin_pass', 'updated', 'progress'])
def __eq__(self, other): """ @summary: Overrides the default equals @param other: DiskSize object to compare with @type other: DiskSize @return: True if DiskSize objects are equal, False otherwise @rtype: bool """ return self.unit == other.unit and EqualityTools.are_sizes_equal( self.value, other.value, self.leeway_for_disk_size)
def test_exists_entry_fields_on_rescue_server_response(self): """ Verify that the Exist entry will have all expected fields after Server Rescue """ self.validate_exist_entry_field_values(server=self.unrescued_server) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.rescue_start_time), string_to_datetime(self.event_exist.audit_period_ending), timedelta(seconds=self.leeway))) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.audit_period_beginning), string_to_datetime(self.event_exist.audit_period_beginning), timedelta(seconds=self.leeway))) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.rescue_start_time), string_to_datetime(self.event_exist.received), timedelta(seconds=self.leeway)))
def validate_exist_entry_audit_period_values( self, expected_audit_period_ending, expected_audit_period_beginning, event_exist_server=None): """ @summary: Validate that the Exist entry will have all expected values related to audit periods @param expected_audit_period_ending: The expected audit period ending of the server @type expected_audit_period_ending: datetime @param expected_audit_period_beginning: The expected audit period beginning of the server @type expected_audit_period_beginning: datetime @param event_exist_server: Details of the event Exist from DB @type event_exist_server: ServerExists """ self.event_exist_server = self.event_exist if event_exist_server: self.event_exist_server = event_exist_server self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(expected_audit_period_ending), string_to_datetime( self.event_exist_server.audit_period_ending), timedelta(seconds=self.leeway))) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(expected_audit_period_beginning), string_to_datetime( self.event_exist_server.audit_period_beginning), timedelta(seconds=self.leeway))) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(expected_audit_period_ending), string_to_datetime(self.event_exist_server.received), timedelta(seconds=self.leeway)))
def test_ram_and_disk_size_on_resize_up_server_confirm_test(self): """ The server's RAM and disk space should be modified to that of the provided flavor """ new_flavor = self.flavors_client.get_flavor_details(self.flavor_ref).entity public_address = self.compute_provider.get_public_ip_address(self.resized_server) remote_instance = self.compute_provider.get_remote_instance_client(self.resized_server, public_address) lower_limit = int(new_flavor.ram) - (int(new_flavor.ram) * .1) server_ram_size = int(remote_instance.get_ram_size_in_mb()) server_swap_size = int(remote_instance.get_swap_size_in_mb()) self.assertTrue(int(new_flavor.ram) == server_ram_size or lower_limit <= server_ram_size, msg="Ram size after confirm-resize did not match. Expected ram size : %s, Actual ram size : %s" % (new_flavor.ram, server_ram_size)) self.assertEquals(int(new_flavor.swap), server_swap_size, msg="Swap size after confirm-resize did not match. Expected swap size: %s, Actual swap size: %s" % (new_flavor.swap, server_swap_size)) self.assertTrue(EqualityTools.are_sizes_equal(new_flavor.disk, remote_instance.get_disk_size_in_gb(), 0.5), msg="Disk size %s after confirm-resize did not match size %s" % (remote_instance.get_disk_size_in_gb(), new_flavor.disk))
def test_ram_and_disk_size_on_resize_up_server_revert(self): """ The server's RAM and disk space should return to its original values after a resize is reverted """ server_response = self.compute_provider.create_active_server() server_to_resize = server_response.entity self.resources.add(server_to_resize.id, self.servers_client.delete_server) remote_instance = self.compute_provider.get_remote_instance_client(server_to_resize) file_name = rand_name('file') + '.txt' file_content = 'This is a test file' file_details = remote_instance.create_file(file_name, file_content) #resize server and revert self.servers_client.resize(server_to_resize.id, self.flavor_ref_alt) self.compute_provider.wait_for_server_status(server_to_resize.id, NovaServerStatusTypes.VERIFY_RESIZE) self.servers_client.revert_resize(server_to_resize.id) reverted_server_response = self.compute_provider.wait_for_server_status(server_to_resize.id, NovaServerStatusTypes.ACTIVE) reverted_server = reverted_server_response.entity flavor_response = self.flavors_client.get_flavor_details(self.flavor_ref) flavor = flavor_response.entity '''Verify that the server resize was reverted ''' public_address = self.compute_provider.get_public_ip_address(reverted_server) reverted_server.adminPass = server_to_resize.adminPass remote_instance = self.compute_provider.get_remote_instance_client(reverted_server, public_address) actual_file_content = remote_instance.get_file_details(file_details.name) '''Verify that the file content does not change after resize revert''' self.assertEqual(actual_file_content, file_details, msg="file changed after resize revert") self.assertEqual(self.flavor_ref, reverted_server.flavor.id, msg="Flavor id not reverted") lower_limit = int(flavor.ram) - (int(flavor.ram) * .1) server_ram_size = int(remote_instance.get_ram_size_in_mb()) self.assertTrue(int(flavor.ram) == server_ram_size or lower_limit <= server_ram_size, msg="Ram size after revert did not match.Expected ram size : %s, Actual ram size : %s" % (flavor.ram, server_ram_size)) self.assertTrue(EqualityTools.are_sizes_equal(flavor.disk, remote_instance.get_disk_size_in_gb(), 0.5), msg="Disk size %s after revert did not match %s" % (remote_instance.get_disk_size_in_gb(), flavor.disk))
def __eq__(self, other): return EqualityTools.are_objects_equal(self, other)
def __eq__(self, other): return EqualityTools.are_objects_equal(self, other, ['admin_pass', 'updated', 'progress'])
def __eq__(self, other): return EqualityTools.are_objects_equal(self, other, ["admin_pass", "updated", "progress"])
def validate_launch_entry_field_values(self, server, event_launch_server=None, expected_flavor_ref=None, launched_at=None): """ @summary: Validate that the Launch entry will have all expected values @param server: Details of the server created in test @type server: Server @param event_launch_server: Details of the event Launch from DB @type event_launch_server: ServerLaunch @param expected_flavor_ref: The expected flavor to verify against @type expected_flavor_ref: String @param launched_at: The launched_at time of the server @type launched_at: datetime """ self.event_launch_server = self.event_launch if event_launch_server: self.event_launch_server = event_launch_server self.expected_flavor_ref = self.flavor_ref if expected_flavor_ref: self.expected_flavor_ref = expected_flavor_ref self.launched_at = self.launched_at_created_server if launched_at: self.launched_at = launched_at self.assertEqual(server.id, self.event_launch_server.instance, self.msg.format( "instance", server.id, self.event_launch_server.instance, self.launch_response.reason, self.launch_response.content)) self.assertEqual(server.flavor.id, self.event_launch_server.instance_type_id, self.msg.format( "instance_type_id", server.flavor.id, self.event_launch_server.instance_type_id, self.launch_response.reason, self.launch_response.content)) self.assertEqual(self.expected_flavor_ref, self.event_launch_server.instance_type_id, self.msg.format( "instance_type_id", self.expected_flavor_ref, self.event_launch_server.instance_type_id, self.launch_response.reason, self.launch_response.content)) self.assertEqual(self.expected_flavor_ref, self.event_launch_server.instance_flavor_id, self.msg.format( "instance_flavor_id", self.expected_flavor_ref, self.event_launch_server.instance_flavor_id, self.launch_response.reason, self.launch_response.content)) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.launched_at), string_to_datetime(self.event_launch_server.launched_at), timedelta(seconds=self.leeway)), self.msg.format("launched_at", self.launched_at, self.event_launch_server.launched_at, self.launch_response.reason, self.launch_response.content))
def validate_exist_entry_field_values(self, server, event_exist_server=None, expected_flavor_ref=None, launched_at=None): """ @summary: Validate that the Exist entry will have all expected values @param server: Details of the server created in test @type server: Server @param event_exist_server: Details of the event Exist from DB @type event_exist_server: ServerExists @param expected_flavor_ref: The expected flavor to verify against @type expected_flavor_ref: String @param launched_at: The launched_at time of the server @type launched_at: datetime """ self.event_exist_server = self.event_exist if event_exist_server: self.event_exist_server = event_exist_server self.expected_flavor_ref = self.flavor_ref if expected_flavor_ref: self.expected_flavor_ref = expected_flavor_ref self.launched_at = self.launched_at_created_server if launched_at: self.launched_at = launched_at self.assertEqual(server.id, self.event_exist_server.instance, self.msg.format("instance", self.created_server.id, self.event_exist_server.instance, self.exist_response.reason, self.exist_response.content)) self.assertEqual(server.flavor.id, self.event_exist_server.instance_type_id, self.msg.format( "instance_type_id", self.created_server.flavor.id, self.event_exist_server.instance_type_id, self.exist_response.reason, self.exist_response.content)) self.assertEqual(self.expected_flavor_ref, self.event_exist_server.instance_type_id, self.msg.format( "instance_type_id", self.expected_flavor_ref, self.event_exist_server.instance_type_id, self.exist_response.reason, self.exist_response.content)) self.assertEqual(self.expected_flavor_ref, self.event_exist_server.instance_flavor_id, self.msg.format( "instance_flavor_id", self.expected_flavor_ref, self.event_exist_server.instance_flavor_id, self.exist_response.reason, self.exist_response.content)) self.assertIn(self.event_exist_server.status, ['pending', 'verified'], self.msg.format("status", "Not None, Empty or unexpected value", self.event_exist_server.status, self.exist_response.reason, self.exist_response.content)) self.assertIn(self.event_exist_server.send_status, [0, 201], self.msg.format("send_status", "Not None, Empty or unexpected value", self.event_exist_server.status, self.exist_response.reason, self.exist_response.content)) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.launched_at), string_to_datetime(self.event_exist_server.launched_at), timedelta(seconds=self.leeway)), self.msg.format("launched_at", self.launched_at, self.event_exist_server.launched_at, self.exist_response.reason, self.exist_response.content))
def validate_launch_entry_field_values(self, server, event_launch_server=None, expected_flavor_ref=None, launched_at=None): """ @summary: Validate that the Launch entry will have all expected values @param server: Details of the server created in test @type server: Server @param event_launch_server: Details of the event Launch from DB @type event_launch_server: ServerLaunch @param expected_flavor_ref: The expected flavor to verify against @type expected_flavor_ref: String @param launched_at: The launched_at time of the server @type launched_at: datetime """ self.event_launch_server = self.event_launch if event_launch_server: self.event_launch_server = event_launch_server self.expected_flavor_ref = self.flavor_ref if expected_flavor_ref: self.expected_flavor_ref = expected_flavor_ref self.launched_at = self.launched_at_created_server if launched_at: self.launched_at = launched_at self.assertEqual( server.id, self.event_launch_server.instance, self.msg.format("instance", server.id, self.event_launch_server.instance, self.launch_response.reason, self.launch_response.content)) self.assertEqual( server.flavor.id, self.event_launch_server.instance_type_id, self.msg.format("instance_type_id", server.flavor.id, self.event_launch_server.instance_type_id, self.launch_response.reason, self.launch_response.content)) self.assertEqual( self.expected_flavor_ref, self.event_launch_server.instance_type_id, self.msg.format("instance_type_id", self.expected_flavor_ref, self.event_launch_server.instance_type_id, self.launch_response.reason, self.launch_response.content)) self.assertEqual( self.expected_flavor_ref, self.event_launch_server.instance_flavor_id, self.msg.format("instance_flavor_id", self.expected_flavor_ref, self.event_launch_server.instance_flavor_id, self.launch_response.reason, self.launch_response.content)) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.launched_at), string_to_datetime(self.event_launch_server.launched_at), timedelta(seconds=self.leeway)), self.msg.format("launched_at", self.launched_at, self.event_launch_server.launched_at, self.launch_response.reason, self.launch_response.content))
def validate_exist_entry_field_values(self, server, event_exist_server=None, expected_flavor_ref=None, launched_at=None): """ @summary: Validate that the Exist entry will have all expected values @param server: Details of the server created in test @type server: Server @param event_exist_server: Details of the event Exist from DB @type event_exist_server: ServerExists @param expected_flavor_ref: The expected flavor to verify against @type expected_flavor_ref: String @param launched_at: The launched_at time of the server @type launched_at: datetime """ self.event_exist_server = self.event_exist if event_exist_server: self.event_exist_server = event_exist_server self.expected_flavor_ref = self.flavor_ref if expected_flavor_ref: self.expected_flavor_ref = expected_flavor_ref self.launched_at = self.launched_at_created_server if launched_at: self.launched_at = launched_at self.assertEqual( server.id, self.event_exist_server.instance, self.msg.format("instance", self.created_server.id, self.event_exist_server.instance, self.exist_response.reason, self.exist_response.content)) self.assertEqual( server.flavor.id, self.event_exist_server.instance_type_id, self.msg.format("instance_type_id", self.created_server.flavor.id, self.event_exist_server.instance_type_id, self.exist_response.reason, self.exist_response.content)) self.assertEqual( self.expected_flavor_ref, self.event_exist_server.instance_type_id, self.msg.format("instance_type_id", self.expected_flavor_ref, self.event_exist_server.instance_type_id, self.exist_response.reason, self.exist_response.content)) self.assertEqual( self.expected_flavor_ref, self.event_exist_server.instance_flavor_id, self.msg.format("instance_flavor_id", self.expected_flavor_ref, self.event_exist_server.instance_flavor_id, self.exist_response.reason, self.exist_response.content)) self.assertIn( self.event_exist_server.status, ['pending', 'verified'], self.msg.format("status", "Not None, Empty or unexpected value", self.event_exist_server.status, self.exist_response.reason, self.exist_response.content)) self.assertIn( self.event_exist_server.send_status, [0, 201], self.msg.format("send_status", "Not None, Empty or unexpected value", self.event_exist_server.status, self.exist_response.reason, self.exist_response.content)) self.assertTrue( EqualityTools.are_datetimes_equal( string_to_datetime(self.launched_at), string_to_datetime(self.event_exist_server.launched_at), timedelta(seconds=self.leeway)), self.msg.format("launched_at", self.launched_at, self.event_exist_server.launched_at, self.exist_response.reason, self.exist_response.content))