def test_check(aggregator, mocked_request): # Instantiate YarnCheck yarn = YarnCheck('yarn', {}, {}) # Run the check once yarn.check(YARN_CONFIG['instances'][0]) aggregator.assert_service_check( SERVICE_CHECK_NAME, status=YarnCheck.OK, tags=YARN_CLUSTER_METRICS_TAGS + CUSTOM_TAGS + ['url:{}'.format(RM_ADDRESS)], ) # Check the YARN Cluster Metrics for metric, value in YARN_CLUSTER_METRICS_VALUES.iteritems(): aggregator.assert_metric(metric, value=value, tags=YARN_CLUSTER_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN App Metrics for metric, value in YARN_APP_METRICS_VALUES.iteritems(): aggregator.assert_metric(metric, value=value, tags=YARN_APP_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN Node Metrics for metric, value in YARN_NODE_METRICS_VALUES.iteritems(): aggregator.assert_metric(metric, value=value, tags=YARN_NODE_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN Root Queue Metrics for metric, value in YARN_ROOT_QUEUE_METRICS_VALUES.iteritems(): aggregator.assert_metric(metric, value=value, tags=YARN_ROOT_QUEUE_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN Custom Queue Metrics for metric, value in YARN_QUEUE_METRICS_VALUES.iteritems(): aggregator.assert_metric(metric, value=value, tags=YARN_QUEUE_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN Queue Metrics from excluded queues are absent for metric, value in YARN_QUEUE_METRICS.values(): aggregator.assert_metric(metric, tags=YARN_QUEUE_NOFOLLOW_METRICS_TAGS + CUSTOM_TAGS, count=0) aggregator.assert_all_metrics_covered()
def test_check(aggregator, mocked_request): instance = YARN_CONFIG['instances'][0] # Instantiate YarnCheck yarn = YarnCheck('yarn', {}, [instance]) # Run the check once yarn.check(instance) aggregator.assert_service_check( SERVICE_CHECK_NAME, status=YarnCheck.OK, tags=YARN_CLUSTER_METRICS_TAGS + CUSTOM_TAGS + ['url:{}'.format(RM_ADDRESS)], ) aggregator.assert_service_check( APPLICATION_STATUS_SERVICE_CHECK, status=YarnCheck.OK, tags=[ 'app_queue:default', 'app_name:word count', 'optional:tag1', 'cluster_name:SparkCluster' ], ) aggregator.assert_service_check( APPLICATION_STATUS_SERVICE_CHECK, status=YarnCheck.CRITICAL, tags=[ 'app_queue:default', 'app_name:dead app', 'optional:tag1', 'cluster_name:SparkCluster' ], ) aggregator.assert_service_check( APPLICATION_STATUS_SERVICE_CHECK, status=YarnCheck.OK, tags=[ 'app_queue:default', 'app_name:new app', 'optional:tag1', 'cluster_name:SparkCluster' ], ) # Check the YARN Cluster Metrics for metric, value in iteritems(YARN_CLUSTER_METRICS_VALUES): aggregator.assert_metric(metric, value=value, tags=YARN_CLUSTER_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN App Metrics for metric, value in iteritems(YARN_APP_METRICS_VALUES): aggregator.assert_metric(metric, value=value, tags=YARN_APP_METRICS_TAGS + CUSTOM_TAGS, count=1) for metric, value in iteritems(DEPRECATED_YARN_APP_METRICS_VALUES): aggregator.assert_metric(metric, value=value, tags=YARN_APP_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN Node Metrics for metric, value in iteritems(YARN_NODE_METRICS_VALUES): aggregator.assert_metric(metric, value=value, tags=YARN_NODE_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN Root Queue Metrics for metric, value in iteritems(YARN_ROOT_QUEUE_METRICS_VALUES): aggregator.assert_metric(metric, value=value, tags=YARN_ROOT_QUEUE_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN Custom Queue Metrics for metric, value in iteritems(YARN_QUEUE_METRICS_VALUES): aggregator.assert_metric(metric, value=value, tags=YARN_QUEUE_METRICS_TAGS + CUSTOM_TAGS, count=1) # Check the YARN Queue Metrics from excluded queues are absent for metric, _ in YARN_QUEUE_METRICS.values(): aggregator.assert_metric(metric, tags=YARN_QUEUE_NOFOLLOW_METRICS_TAGS + CUSTOM_TAGS, count=0) aggregator.assert_all_metrics_covered()