def test_diagnostics_with_active_bucket(self): query_result = self.cluster.query( 'SELECT * FROM `beer-sample` LIMIT 1') if self.is_mock: try: query_result.rows() except: pass else: self.assertTrue(len(query_result.rows()) > 0) result = self.cluster.diagnostics( DiagnosticsOptions(report_id="imareportid")) print(result.as_json()) self.assertIn("imareportid", result.id) # we now open a bucket, and ping the services, in setUp's base classes. So # there should always be a management endpoint... if not self.is_mock: # no matter what there should be a config service type in there, # as long as we are not the mock. mgmt = result.endpoints[ServiceType.Management] self.assertTrue(len(mgmt) > 0) # but now, we have hit Query, so... q = result.endpoints[ServiceType.Query] self.assertTrue(len(q) > 0) self.assertIsNotNone(q[0].id) self.assertIsNotNone(q[0].local) self.assertIsNotNone(q[0].remote) self.assertIsNotNone(q[0].last_activity) self.assertEqual(q[0].state, EndpointState.Connected) self.assertEqual(q[0].type, ServiceType.Query)
def test_diagnostics(self): result = self.cluster.diagnostics( DiagnosticsOptions(report_id="imareportid")) self.assertIn("imareportid", result.id) self.assertIsNotNone(result.sdk) self.assertIsNotNone(result.version) self.assertEquals(result.state, ClusterState.Online) if not self.is_mock: # no matter what there should be a config service type in there, # as long as we are not the mock. config = result.endpoints[ServiceType.Config] self.assertTrue(len(config) > 0) self.assertIsNotNone(config[0].id) self.assertIsNotNone(config[0].local) self.assertIsNotNone(config[0].remote) self.assertIsNotNone(config[0].last_activity) self.assertEqual(config[0].state, EndpointState.Connected) self.assertEqual(config[0].type, ServiceType.Config)
def test_diagnostics_as_json(self): result = self.cluster.diagnostics( DiagnosticsOptions(report_id="imareportid")) self.assertIn("imareportid", result.id) self.assertIsNotNone(result.sdk) self.assertIsNotNone(result.version) self.assertEquals(result.state, ClusterState.Online) result_str = result.as_json() self.assertIsInstance(result_str, str) result_json = json.loads(result_str) self.assertIsNotNone(result_json['version']) self.assertIsNotNone(result_json['id']) self.assertIsNotNone(result_json['sdk']) self.assertIsNotNone(result_json['services']) for _, data in result_json['services'].items(): if len(data): self.assertIsNotNone(data[0]['id']) self.assertIsNotNone(data[0]['last_activity_us']) self.assertIsNotNone(data[0]['remote']) self.assertIsNotNone(data[0]['local']) self.assertIsNotNone(data[0]['state'])