def test_get_all_servers_with_project_name_none(servers_detail, aggregator):
    """
    Ensure the cache contains the expected VMs between check runs.
    """
    check = OpenStackControllerCheck(
        "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
    check.servers_cache = copy.deepcopy(common.SERVERS_CACHE_MOCK)
    # Update the cached list of servers based on what the endpoint returns
    check.get_all_servers(
        {
            '6f70656e737461636b20342065766572': None,
            'blacklist_1': 'blacklist_1',
            'blacklist_2': 'blacklist_2'
        }, "test_name", [])
    servers = check.servers_cache['servers']
    assert 'server_newly_added' not in servers
    assert 'server-1' not in servers
    assert 'other-1' in servers
    assert 'other-2' in servers
def test_get_all_servers_with_paginated_server(servers_detail, aggregator):
    """
    Ensure the server cache is updated while using pagination
    """

    check = OpenStackControllerCheck("test", {
        'keystone_server_url': 'http://10.0.2.15:5000',
        'ssl_verify': False,
        'exclude_server_ids': common.EXCLUDED_SERVER_IDS,
        'paginated_server_limit': 1
    }, {}, instances=common.MOCK_CONFIG)
    check.get_all_servers({"6f70656e737461636b20342065766572": "testproj"}, "test_instance")
    assert len(check.server_details_by_id) == 1
    assert 'server-1' in check.server_details_by_id
    assert 'other-1' not in check.server_details_by_id
    assert 'other-2' not in check.server_details_by_id
Beispiel #3
0
def test_get_paginated_server(*args):
    """
    Ensure the server cache is updated while using pagination
    """

    openstackCheck = OpenStackControllerCheck("test", {
        'keystone_server_url': 'http://10.0.2.15:5000',
        'ssl_verify': False,
        'exclude_server_ids': common.EXCLUDED_SERVER_IDS,
        'paginated_server_limit': 1
    }, {},
                                              instances=common.MOCK_CONFIG)

    i_key = "test_instance"
    openstackCheck.get_all_servers(i_key)
    assert len(openstackCheck.server_details_by_id) == 1
    assert 'server-1' in openstackCheck.server_details_by_id
Beispiel #4
0
def test_project_name_none(*args):
    """
    Ensure the cache contains the expected VMs between check runs.
    """

    openstackCheck = OpenStackControllerCheck(
        "test", {
            'keystone_server_url': 'http://10.0.2.15:5000',
            'ssl_verify': False,
            'exclude_server_ids': common.EXCLUDED_SERVER_IDS
        }, {},
        instances=common.MOCK_CONFIG)

    # 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
    openstackCheck.get_all_servers(i_key)
    assert 'server_newly_added' in openstackCheck.server_details_by_id
    assert 'server-1' not in openstackCheck.server_details_by_id
def test_get_all_servers_between_runs(servers_detail, aggregator):
    """
    Ensure the cache contains the expected VMs between check runs.
    """

    check = OpenStackControllerCheck("test", {
        'keystone_server_url': 'http://10.0.2.15:5000',
        'ssl_verify': False,
        'exclude_server_ids': common.EXCLUDED_SERVER_IDS
    }, {}, instances=common.MOCK_CONFIG)

    # Start off with a list of servers
    check.server_details_by_id = copy.deepcopy(common.ALL_SERVER_DETAILS)
    # Update the cached list of servers based on what the endpoint returns
    check.get_all_servers({'6f70656e737461636b20342065766572': 'testproj',
                           'blacklist_1': 'blacklist_1',
                           'blacklist_2': 'blacklist_2'}, "test_instance")

    cached_servers = check.server_details_by_id
    print(cached_servers)
    assert 'server-1' not in cached_servers
    assert 'server_newly_added' in cached_servers
    assert 'other-1' in cached_servers
    assert 'other-2' in cached_servers