Example #1
0
 def test_NodeLookup_lookup_client_forbidden(self, get_nodes):
     """Test the functionality of the setup and lookup functions"""
     nl = NodeLookup(mock.MagicMock(), {"design": "ref"}, retry_delay=0.1)
     sel = GroupNodeSelector({
         'node_names': [],
         'node_labels': [],
         'node_tags': [],
         'rack_names': [],
     })
     with pytest.raises(errors.ClientForbiddenError) as ex:
         resp = nl.lookup([sel])
     assert get_nodes.call_count == 1
Example #2
0
def _get_node_lookup(drydock_client, design_ref):
    """Return a NodeLookup suitable for the DeploymentGroupManager

    :param drydock_client: the drydock_client object
    :param design_ref: the design_ref for the NodeLookup
    """
    return NodeLookup(drydock_client, design_ref).lookup
Example #3
0
    def test_NodeLookup_lookup(self, *args):
        """Test the functionality of the setup and lookup functions"""
        nl = NodeLookup(mock.MagicMock(), {"design": "ref"})

        assert nl.design_ref == {"design": "ref"}
        assert nl.drydock_client

        sel = GroupNodeSelector({
            'node_names': [],
            'node_labels': ['label1:label1'],
            'node_tags': ['tag1', 'tag2'],
            'rack_names': ['rack3', 'rack1'],
        })

        resp = nl.lookup([sel])
        assert resp == ['node1', 'node2']
def _get_node_lookup(revision_id):
    # get a Drydock node_lookup function using the supplied revision_id

    return NodeLookup(
        service_clients.drydock_client(),
        DesignRefHelper().get_design_reference_dict(revision_id)
    ).lookup
Example #5
0
 def test_NodeLookup_lookup_missing_design_ref(self):
     """Test the functionality of the setup and lookup functions"""
     with pytest.raises(InvalidDeploymentGroupNodeLookupError) as idgnle:
         NodeLookup(mock.MagicMock(), {})
     assert 'An incomplete design ref' in str(idgnle.value)