Skip to content

Commit

Permalink
Merge pull request #5478 from hashicorp/b-e2e_metrics
Browse files Browse the repository at this point in the history
Use specific url prefix for metrics test
  • Loading branch information
Preetha authored Mar 28, 2019
2 parents 27efdc4 + 6c1d69b commit 7feee07
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion e2e/metrics/input/helloworld.nomad
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ job "hello" {

service {
name = "hello"
tags = ["urlprefix-/"]
tags = ["urlprefix-hello/"]
port = "web"
check {
name = "alive"
Expand Down
18 changes: 14 additions & 4 deletions e2e/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
}

}

0 comments on commit 7feee07

Please sign in to comment.