def test_get_tenant_metrics(self): """Extracts metrics from the servers.""" servers = { 'g1': ([_server('g1', 'ACTIVE')] * 2 + [_server('g1', 'SUSPENDED')] + # Destiny.AVOID_REPLACING [_server('g1', 'BUILD')] * 2 + [_server('g1', 'UNKNOWN')] + # Destiny.IGNORE [_server("g1", "ERROR"), # Destiny.DELETE _server("g1", "DELETED"), # Destiny.CLEANUP _server("g1", "SHUTOFF"), # Destiny.DELETE _server("g1", "PASSWORD")]), # Destiny.WAIT 'g3': [_server("g3", 'ACTIVE')], 'g4': [_server("g4", 'ACTIVE')], 'g5': [_server("g5", 'ACTIVE')] } groups = [{'groupId': 'g1', 'desired': 3}, {'groupId': 'g2', 'desired': 4, "status": "ACTIVE"}, {'groupId': 'g5', 'desired': 1, "status": "DISABLED"}, {'groupId': 'g4', 'desired': 5, "status": "ERROR"}] self.assertEqual( set(get_tenant_metrics('t', groups, servers)), # g1 2 BUILD and 1 PASSWORD servers is considered pending set([GroupMetrics('t', 'g1', 3, 3, 3), GroupMetrics('t', 'g2', 4, 0, 0), GroupMetrics('t', 'g3', 0, 1, 0)]) )
def test_get_tenant_metrics(self): """Extracts metrics from the servers.""" servers = { 'g1': ([_server('g1', 'ACTIVE')] * 3 + [_server('g1', 'BUILD')] * 2 + [ _server("g1", "ERROR"), _server("g1", "DELETED"), _server("g1", "SHUTOFF"), _server("g1", "PASSWORD") ]), 'g3': [_server("g3", 'ACTIVE')] } groups = [{ 'groupId': 'g1', 'desired': 3 }, { 'groupId': 'g2', 'desired': 4 }] self.assertEqual( set(get_tenant_metrics('t', groups, servers)), # g1 2 BUILD and 1 PASSWORD servers is considered pending set([ GroupMetrics('t', 'g1', 3, 3, 3), GroupMetrics('t', 'g2', 4, 0, 0), GroupMetrics('t', 'g3', 0, 1, 0) ]))
def test_get_tenant_metrics(self): """ Gets group's metrics """ servers = {'g1': [{'status': 'ACTIVE'}] * 3 + [{'status': 'BUILD'}] * 2} groups = [{'groupId': 'g1', 'desired': 3}, {'groupId': 'g2', 'desired': 4}] self.assertEqual( get_tenant_metrics('t', groups, servers), [GroupMetrics('t', 'g1', 3, 3, 2), GroupMetrics('t', 'g2', 4, 0, 0)])
def test_get_tenant_metrics(self): """Extracts metrics from the servers.""" servers = { 'g1': ([_server('g1', 'ACTIVE')] * 3 + [_server('g1', 'BUILD')] * 2 + [_server("g1", "ERROR"), _server("g1", "DELETED"), _server("g1", "SHUTOFF"), _server("g1", "PASSWORD")]), 'g3': [_server("g3", 'ACTIVE')] } groups = [{'groupId': 'g1', 'desired': 3}, {'groupId': 'g2', 'desired': 4}] self.assertEqual( set(get_tenant_metrics('t', groups, servers)), # g1 2 BUILD and 1 PASSWORD servers is considered pending set([GroupMetrics('t', 'g1', 3, 3, 3), GroupMetrics('t', 'g2', 4, 0, 0), GroupMetrics('t', 'g3', 0, 1, 0)]) )
def test_get_tenant_metrics(self): """Extracts metrics from the servers.""" servers = { 'g1': ([_server('g1', 'ACTIVE')] * 2 + [_server('g1', 'SUSPENDED')] + # Destiny.AVOID_REPLACING [_server('g1', 'BUILD')] * 2 + [_server('g1', 'UNKNOWN')] + # Destiny.IGNORE [ _server("g1", "ERROR"), # Destiny.DELETE _server("g1", "DELETED"), # Destiny.CLEANUP _server("g1", "SHUTOFF"), # Destiny.DELETE _server("g1", "PASSWORD") ]), # Destiny.WAIT 'g3': [_server("g3", 'ACTIVE')], 'g4': [_server("g4", 'ACTIVE')], 'g5': [_server("g5", 'ACTIVE')] } groups = [{ 'groupId': 'g1', 'desired': 3 }, { 'groupId': 'g2', 'desired': 4, "status": "ACTIVE" }, { 'groupId': 'g5', 'desired': 1, "status": "DISABLED" }, { 'groupId': 'g4', 'desired': 5, "status": "ERROR" }] self.assertEqual( set(get_tenant_metrics('t', groups, servers)), # g1 2 BUILD and 1 PASSWORD servers is considered pending set([ GroupMetrics('t', 'g1', 3, 3, 3), GroupMetrics('t', 'g2', 4, 0, 0), GroupMetrics('t', 'g3', 0, 1, 0) ]))
def test_get_tenant_metrics(self): """Extracts metrics from the servers.""" servers = { "g1": ( [_server("g1", "ACTIVE")] * 3 + [_server("g1", "BUILD")] * 2 + [ _server("g1", "ERROR"), _server("g1", "DELETED"), _server("g1", "SHUTOFF"), _server("g1", "PASSWORD"), ] ), "g3": [_server("g3", "ACTIVE")], } groups = [{"groupId": "g1", "desired": 3}, {"groupId": "g2", "desired": 4}] self.assertEqual( set(get_tenant_metrics("t", groups, servers)), # g1 2 BUILD and 1 PASSWORD servers is considered pending set([GroupMetrics("t", "g1", 3, 3, 3), GroupMetrics("t", "g2", 4, 0, 0), GroupMetrics("t", "g3", 0, 1, 0)]), )