def test_only_no_machines(self, mock_get_cluster_site): resources = { "machines": [{ "role": "role1", "nodes": 0, "cluster": "foocluster", }], } criteria = utils._build_reservation_criteria(resources["machines"], []) self.assertDictEqual({}, criteria)
def test_network_subnet(self, value): resources = { "networks": [{ "type": value, "site": "site1" }] } criteria = utils._build_reservation_criteria([], resources["networks"]) self.assertDictEqual({"site1": ["%s=1" % value ] }, criteria)
def test_only_machines_one_site(self, mock_get_cluster_site): resources = { "machines": [{ "role": "role1", "nodes": 1, "cluster": "foocluster", }], } criteria = utils._build_reservation_criteria(resources["machines"], []) self.assertDictEqual({"site1": ["{cluster='foocluster'}/nodes=1"]}, criteria)
def test_only_machines_two_sites(self, mock_get_cluster_site): resources = { "machines": [ { "role": "role1", "nodes": 1, "cluster": "foocluster" }, { "role": "role2", "nodes": 2, "cluster": "barcluster" }, ] } criteria = utils._build_reservation_criteria(resources["machines"], []) self.assertDictEqual( { "site1": ["{cluster='foocluster'}/nodes=1"], "site2": ["{cluster='barcluster'}/nodes=2"], }, criteria, )