Skip to content
This repository has been archived by the owner on Mar 9, 2022. It is now read-only.

Commit

Permalink
spouttest: Adjust end-to-end test to account for max_pending metric
Browse files Browse the repository at this point in the history
Given the value of the metric is hard to know up front, regex matching
is used.
  • Loading branch information
mjs committed Apr 17, 2018
1 parent 29ee717 commit 14fed65
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions spouttest/e2e_test.go
Expand Up @@ -22,6 +22,7 @@ import (
"io/ioutil"
"net"
"net/http"
"regexp"
"strconv"
"strings"
"testing"
Expand Down Expand Up @@ -128,9 +129,10 @@ func TestEndToEnd(t *testing.T) {
}

// Check metrics published by monitor component.
expectedMetrics := `
expectedMetrics := regexp.MustCompile(`
failed_writes{component="writer",influxdb_address="localhost",influxdb_dbname="test",influxdb_port="44501",name="writer"} 0
invalid_time{component="filter",name="filter"} 0
max_pending{component="writer",influxdb_address="localhost",influxdb_dbname="test",influxdb_port="44501",name="writer"} \d+
passed{component="filter",name="filter"} 10
processed{component="filter",name="filter"} 20
read_errors{component="listener",name="listener"} 0
Expand All @@ -140,7 +142,7 @@ rejected{component="filter",name="filter"} 10
sent{component="listener",name="listener"} 1
triggered{component="filter",name="filter",rule="system"} 10
write_requests{component="writer",influxdb_address="localhost",influxdb_dbname="test",influxdb_port="44501",name="writer"} 2
`[1:]
$`[1:])
var lines string
for try := 0; try < 20; try++ {
resp, err := http.Get(fmt.Sprintf("http://localhost:%d/metrics", monitorPort))
Expand All @@ -150,7 +152,7 @@ write_requests{component="writer",influxdb_address="localhost",influxdb_dbname="
require.NoError(t, err)

lines = spouttest.StripTimestamps(t, string(raw))
if lines == expectedMetrics {
if expectedMetrics.MatchString(lines) {
return
}
time.Sleep(500 * time.Millisecond)
Expand Down

0 comments on commit 14fed65

Please sign in to comment.