Add docker test to check metric names

This commit is contained in:
Stephen Marshall
2018-06-08 10:06:34 +01:00
parent 7551ce3812
commit c409179f4a
2 changed files with 108 additions and 8 deletions

View File

@@ -19,7 +19,6 @@ import (
"fmt"
"net"
"strconv"
"strings"
"testing"
"time"
@@ -54,7 +53,6 @@ func TestGoldenPathMetric(t *testing.T) {
func TestMetricNames(t *testing.T) {
t.Parallel()
approvedSuffixes := []string{"bytes", "seconds", "percentage", "count", "total"}
cli, err := client.NewEnvClient()
if err != nil {
t.Fatal(err)
@@ -71,23 +69,25 @@ func TestMetricNames(t *testing.T) {
time.Sleep(15 * time.Second)
// Now actually get the metrics (after waiting for some to become available)
// NB: There are currently a total of 93 metrics, but 3 do not generate values (based on the queue manager configuration)
metrics := getMetrics(t, port)
if len(metrics) <= 0 {
t.Error("Expected some metrics to be returned but had none...")
if len(metrics) != 90 {
t.Errorf("Expected 90 metrics to be returned, received %d", len(metrics))
}
// Check all the metrics have approved suffixes
// Check all the metrics have the correct names
names := metricNames()
for _, metric := range metrics {
ok := false
for _, e := range approvedSuffixes {
if strings.HasSuffix(metric.Key, e) {
for _, name := range names {
if metric.Key == "ibmmq_qmgr_"+name {
ok = true
break
}
}
if !ok {
t.Errorf("Metric '%s' does not have an approved suffix", metric.Key)
t.Errorf("Metric '%s' does not have the expected name", metric.Key)
}
}

View File

@@ -155,3 +155,103 @@ func metricsContainerConfig() *container.Config {
},
}
}
func metricNames() []string {
names := []string{
"cpu_load_five_minute_average_percentage",
"cpu_load_fifteen_minute_average_percentage",
"ram_free_percentage",
"ram_total_bytes",
"user_cpu_time_percentage",
"system_cpu_time_percentage",
"cpu_load_one_minute_average_percentage",
"system_cpu_time_estimate_for_queue_manager_percentage",
"ram_total_estimate_for_queue_manager_bytes",
"user_cpu_time_estimate_for_queue_manager_percentage",
"mq_trace_file_system_in_use_bytes",
"mq_trace_file_system_free_space_percentage",
"mq_errors_file_system_in_use_bytes",
"mq_errors_file_system_free_space_percentage",
"mq_fdc_file_count",
"queue_manager_file_system_in_use_bytes",
"queue_manager_file_system_free_space_percentage",
"log_occupied_by_reusable_extents_bytes",
"log_write_size_bytes",
"log_in_use_bytes",
"log_logical_written_bytes",
"log_write_latency_seconds",
"log_required_for_media_recovery_bytes",
"log_current_primary_space_in_use_percentage",
"log_workload_primary_space_utilization_percentage",
"log_occupied_by_extents_waiting_to_be_archived_bytes",
"log_max_bytes",
"log_file_system_in_use_bytes",
"log_file_system_max_bytes",
"log_physical_written_bytes",
"create_durable_subscription_count",
"resume_durable_subscription_count",
"create_non_durable_subscription_count",
"failed_create_alter_resume_subscription_count",
"subscription_delete_failure_count",
"mqsubrq_count",
"failed_mqsubrq_count",
"durable_subscriber_high_water_mark_count",
"non_durable_subscriber_high_water_mark_count",
"durable_subscriber_low_water_mark_count",
"delete_non_durable_subscription_count",
"alter_durable_subscription_count",
"delete_durable_subscription_count",
"non_durable_subscriber_low_water_mark_count",
"interval_total_topic_put_bytes",
"published_to_subscribers_message_count",
"published_to_subscribers_bytes",
"non_persistent_topic_mqput_mqput1_count",
"persistent_topic_mqput_mqput1_count",
"failed_topic_mqput_mqput1_count",
"topic_mqput_mqput1_interval_count",
"mqconn_mqconnx_count",
"failed_mqconn_mqconnx_count",
"concurrent_connections_high_water_mark_count",
"mqdisc_count",
"mqopen_count",
"failed_mqopen_count",
"mqclose_count",
"failed_mqclose_count",
"mqinq_count",
"failed_mqinq_count",
"mqset_count",
"failed_mqset_count",
"interval_total_mqput_mqput1_bytes",
"persistent_message_mqput_count",
"failed_mqput_count",
"non_persistent_message_mqput1_count",
"persistent_message_mqput1_count",
"failed_mqput1_count",
"put_non_persistent_messages_bytes",
"interval_total_mqput_mqput1_count",
"put_persistent_messages_bytes",
"mqstat_count",
"non_persistent_message_mqput_count",
"interval_total_destructive_get_count",
"mqctl_count",
"failed_mqget_count",
"got_non_persistent_messages_bytes",
"persistent_message_browse_count",
"expired_message_count",
"purged_queue_count",
"interval_total_destructive_get_bytes",
"non_persistent_message_destructive_get_count",
"got_persistent_messages_bytes",
"non_persistent_message_browse_count",
"failed_browse_count",
"persistent_message_destructive_get_count",
"non_persistent_message_browse_bytes",
"persistent_message_browse_bytes",
"mqcb_count",
"failed_mqcb_count",
"commit_count",
"rollback_count",
}
return names
}