Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/docker/mqmetric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func TestGoldenPathMetric(t *testing.T) {
defer cleanContainer(t, cli, id)

hostname := getIPAddress(t, cli, id)
port := DEFAULT_METRIC_PORT
port := defaultMetricPort

// Now the container is ready we prod the prometheus endpoint until it's up.
waitForMetricReady(hostname, port)
Expand Down Expand Up @@ -90,7 +90,7 @@ func TestMetricNames(t *testing.T) {
defer cleanContainer(t, cli, id)

hostname := getIPAddress(t, cli, id)
port := DEFAULT_METRIC_PORT
port := defaultMetricPort

// Now the container is ready we prod the prometheus endpoint until it's up.
waitForMetricReady(hostname, port)
Expand Down Expand Up @@ -159,7 +159,7 @@ func TestMetricLabels(t *testing.T) {
defer cleanContainer(t, cli, id)

hostname := getIPAddress(t, cli, id)
port := DEFAULT_METRIC_PORT
port := defaultMetricPort

// Now the container is ready we prod the prometheus endpoint until it's up.
waitForMetricReady(hostname, port)
Expand Down Expand Up @@ -226,7 +226,7 @@ func TestRapidFirePrometheus(t *testing.T) {
defer cleanContainer(t, cli, id)

hostname := getIPAddress(t, cli, id)
port := DEFAULT_METRIC_PORT
port := defaultMetricPort

// Now the container is ready we prod the prometheus endpoint until it's up.
waitForMetricReady(hostname, port)
Expand Down Expand Up @@ -283,7 +283,7 @@ func TestSlowPrometheus(t *testing.T) {
defer cleanContainer(t, cli, id)

hostname := getIPAddress(t, cli, id)
port := DEFAULT_METRIC_PORT
port := defaultMetricPort

// Now the container is ready we prod the prometheus endpoint until it's up.
waitForMetricReady(hostname, port)
Expand Down
22 changes: 11 additions & 11 deletions test/docker/mqmetric_test_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ import (
"time"
)

type MQMETRIC struct {
type mqmetric struct {
Key string
Value string
Labels map[string]string
}

const DEFAULT_METRIC_URL = "/metrics"
const DEFAULT_METRIC_PORT = 9157
const DEFAULT_MQ_NAMESPACE = "ibmmq"
const defaultMetricURL = "/metrics"
const defaultMetricPort = 9157
const defaultMQNamespace = "ibmmq"

func getMetricsFromEndpoint(host string, port int) ([]MQMETRIC, error) {
returned := []MQMETRIC{}
func getMetricsFromEndpoint(host string, port int) ([]mqmetric, error) {
returned := []mqmetric{}
if host == "" {
return returned, fmt.Errorf("Test Error - Host was nil")
}
if port <= 0 {
return returned, fmt.Errorf("Test Error - port was not above 0")
}
urlToUse := fmt.Sprintf("http://%s:%d%s", host, port, DEFAULT_METRIC_URL)
urlToUse := fmt.Sprintf("http://%s:%d%s", host, port, defaultMetricURL)

resp, err := http.Get(urlToUse)
if err != nil {
Expand All @@ -58,8 +58,8 @@ func getMetricsFromEndpoint(host string, port int) ([]MQMETRIC, error) {
}

// Also filters out all non "ibmmq" metrics
func convertRawMetricToMap(input string) ([]MQMETRIC, error) {
returnList := []MQMETRIC{}
func convertRawMetricToMap(input string) ([]mqmetric, error) {
returnList := []mqmetric{}
if input == "" {
return returnList, fmt.Errorf("Test Error - Raw metric output was nil")
}
Expand All @@ -71,7 +71,7 @@ func convertRawMetricToMap(input string) ([]MQMETRIC, error) {
// Comment line of HELP or TYPE. Ignore
continue
}
if !strings.HasPrefix(line, DEFAULT_MQ_NAMESPACE) {
if !strings.HasPrefix(line, defaultMQNamespace) {
// Not an ibmmq_ metric. Ignore
continue
}
Expand All @@ -81,7 +81,7 @@ func convertRawMetricToMap(input string) ([]MQMETRIC, error) {
return returnList, fmt.Errorf("ibmmq_ metric could not be deciphered - %v", err)
}

toAdd := MQMETRIC{
toAdd := mqmetric{
Key: key,
Value: value,
Labels: labelMap,
Expand Down