def test_cli_metrics_inspect(self, mock): parsers, args = parse_args([ 'metrics', 'inspect', 'custom.googleapis.com/invoice/paid/amount', '-p', PROJECT_ID ]) mlabel_keys = [ 'type', 'name', 'metricKind', 'valueType', 'description', 'displayName', 'event_type' ] rlabel_keys = ['instance_id', 'project_id', 'zone'] responses = cli(parsers, args) response = responses[0] mtype = response['metric']['type'] mlabels = response['metric']['labels'] rtype = response['resource']['type'] rlabels = response['resource']['labels'] mpoints = response['points'] mintval = mpoints[0]['value']['int64Value'] self.assertEqual(mtype, 'custom.googleapis.com/invoice/paid/amount') self.assertEqual(sorted(list(mlabels.keys())), sorted(mlabel_keys)) self.assertEqual(len(mpoints), 1) self.assertEqual(mintval, '100') self.assertEqual(rtype, 'gce_instance') self.assertEqual(sorted(list(rlabels.keys())), sorted(rlabel_keys))
def test_cli_services_list(self, *mocks): parsers, args = parse_args(['services', 'list', '-p', PROJECT_ID]) responses = cli(parsers, args) response = responses[0] display_name = response['displayName'] service_id = response['name'].split('/')[-1] self.assertEqual(len(responses), 1) self.assertEqual(display_name, 'fake') self.assertEqual(service_id, SERVICE_ID)
def test_cli_slos_list(self, *mocks): parsers, args = parse_args( ['slos', 'list', '-p', PROJECT_ID, SERVICE_ID]) responses = cli(parsers, args) response = responses[0] display_name = response['displayName'] goal = response['goal'] rolling_period = response['rollingPeriod'] sli = response['serviceLevelIndicator']['basicSli'] threshold = sli['latency']['threshold'] self.assertEqual(len(responses), 1) self.assertEqual(display_name, 'fake') self.assertEqual(goal, 0.999) self.assertEqual(rolling_period, '86400s') self.assertEqual(threshold, '0.724s')
def test_cli_metrics_list(self, mock): parsers, args = parse_args([ 'metrics', 'list', 'custom.googleapis.com/fake', '-p', PROJECT_ID ]) response = cli(parsers, args) logging.info(response)