From 6c1d69bab4d6161a7ea5b3c3ea24f52dfdf06cf6 Mon Sep 17 00:00:00 2001 From: Preetha Appan Date: Wed, 27 Mar 2019 11:02:44 -0500 Subject: [PATCH] Use specific url prefix for metrics test Also changed the output to show client node IP addresses --- e2e/metrics/input/helloworld.nomad | 2 +- e2e/metrics/metrics_test.go | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/e2e/metrics/input/helloworld.nomad b/e2e/metrics/input/helloworld.nomad index 52e45082d..3870ce2d4 100644 --- a/e2e/metrics/input/helloworld.nomad +++ b/e2e/metrics/input/helloworld.nomad @@ -35,7 +35,7 @@ job "hello" { service { name = "hello" - tags = ["urlprefix-/"] + tags = ["urlprefix-hello/"] port = "web" check { name = "alive" diff --git a/e2e/metrics/metrics_test.go b/e2e/metrics/metrics_test.go index b44d22950..1ed7c5dc9 100644 --- a/e2e/metrics/metrics_test.go +++ b/e2e/metrics/metrics_test.go @@ -27,9 +27,10 @@ func WaitForCluster(t *testing.T, nomadClient *api.Client) { // TestMetrics runs fabio/prometheus and waits for those to succeed // After that a series of jobs added to the input directory are executed // Unlike other e2e tests this test does not clean up after itself. +// This test is meant for AWS environments and will not work locally func TestMetrics(t *testing.T) { if !*metrics { - t.Skip("skipping test in non-integration mode.") + t.Skip("skipping test in non-metrics mode.") } require := require.New(t) // Build Nomad api client @@ -63,7 +64,16 @@ func TestMetrics(t *testing.T) { allocs := e2eutil.RegisterAndWaitForAllocs(t, nomadClient, file, jobId) require.NotEmpty(allocs) } - clientAddr := nomadClient.Address() - clientIP := clientAddr[0:strings.LastIndex(clientAddr, ":")] - fmt.Printf("Prometheus Metrics available at %s:9999\n", clientIP) + + // Get a client node IP address + nodesAPI := nomadClient.Nodes() + nodes, _, err := nodesAPI.List(nil) + require.Nil(err) + for _, node := range nodes { + nodeDetails, _, err := nodesAPI.Info(node.ID, nil) + require.Nil(err) + clientPublicIP := nodeDetails.Attributes["unique.platform.aws.public-ipv4"] + fmt.Printf("Prometheus Metrics available at http://%s:9999\n", clientPublicIP) + } + }