def test__call__records_latency_metric(self): mock_metrics = self.patch(PROMETHEUS_METRICS, 'update') conn = DummyConnection() conn.ident = factory.make_name('ident') self.patch(conn, 'callRemote').return_value = (succeed(sentinel.boot_images)) client = RackClient(conn, {}) yield client(cluster.ListBootImages) mock_metrics.assert_called_with('maas_region_rack_rpc_call_latency', 'observe', labels={'call': 'ListBootImages'}, value=ANY)
def test__call__returns_cache_value(self): conn = DummyConnection() conn.ident = factory.make_name("ident") client = RackClient(conn, {}) call_cache = client._getCallCache() power_types = {"power_types": [{"name": "ipmi"}, {"name": "wedge"}]} call_cache[cluster.DescribePowerTypes] = power_types result = yield client(cluster.DescribePowerTypes) # The result is a copy. It should equal the result but not be # the same object. self.assertEquals(power_types, result) self.assertIsNot(power_types, result)
def test_call__records_latency_metric(self): mock_metrics = self.patch(PROMETHEUS_METRICS, "update") conn = DummyConnection() conn.ident = factory.make_name("ident") self.patch(conn, "callRemote").return_value = succeed(sentinel.boot_images) client = RackClient(conn, {}) yield client(cluster.ListBootImages) mock_metrics.assert_called_with( "maas_region_rack_rpc_call_latency", "observe", labels={"call": "ListBootImages"}, value=ANY, )