def test_cache_between_runs(self, *args): """ Ensure the cache contains the expected VMs between check runs. """ openstackCheck = OpenStackCheck( "test", { 'keystone_server_url': 'http://10.0.2.15:5000', 'ssl_verify': False, 'exclude_server_ids': common.EXCLUDED_SERVER_IDS, }, instances=instances, ) # Start off with a list of servers openstackCheck.server_details_by_id = copy.deepcopy( common.ALL_SERVER_DETAILS) i_key = "test_instance" # Update the cached list of servers based on what the endpoint returns cached_servers = openstackCheck.get_all_servers(i_key, False) assert 'server-1' not in cached_servers assert 'server_newly_added' in cached_servers
def test_server_exclusion(*args): """ Exclude servers using regular expressions. """ openstackCheck = OpenStackCheck( "test", { 'keystone_server_url': 'http://10.0.2.15:5000', 'ssl_verify': False, 'exclude_server_ids': common.EXCLUDED_SERVER_IDS, }, instances=instances, ) # Retrieve servers openstackCheck.server_details_by_id = copy.deepcopy( common.ALL_SERVER_DETAILS) i_key = "test_instance" server_ids = openstackCheck.get_servers_managed_by_hypervisor( i_key, False, False) # Assert # .. 1 out of 4 server ids filtered assert len(server_ids) == 1 # Ensure the server IDs filtered are the ones expected for server_id in server_ids: assert server_id in common.FILTERED_SERVER_ID