Add some sleeps to make it less flaky

Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
Miek Gieben
2021-10-11 12:57:31 +02:00
parent 76ffe2d4fd
commit b5c6655196

View File

@@ -53,6 +53,7 @@ func TestMetricsRefused(t *testing.T) {
if _, err = dns.Exchange(m, udp); err != nil {
t.Fatalf("Could not send message: %s", err)
}
time.Sleep(100 * time.Millisecond) // sleep a bit to allow actual metrics to be updated for sure.
data := test.Scrape("http://" + metrics.ListenAddr + "/metrics")
got, labels := test.MetricValue(metricName, data)
@@ -87,6 +88,7 @@ func TestMetricsPlugin(t *testing.T) {
if _, err = dns.Exchange(m, udp); err != nil {
t.Fatalf("Could not send message: %s", err)
}
time.Sleep(100 * time.Millisecond) // sleep a bit to allow actual metrics to be updated for sure.
data := test.Scrape("http://" + metrics.ListenAddr + "/metrics")
_, labels := test.MetricValue(metricName, data)
@@ -134,6 +136,7 @@ func TestMetricsAuto(t *testing.T) {
if _, err := dns.Exchange(m, udp); err != nil {
t.Fatalf("Could not send message: %s", err)
}
time.Sleep(100 * time.Millisecond) // sleep a bit to allow actual metrics to be updated for sure.
metricName := "coredns_dns_requests_total" // {zone, proto, family, type}
@@ -192,6 +195,7 @@ func TestMetricsSeveralBlocs(t *testing.T) {
if _, err = dns.Exchange(m, udp); err != nil {
t.Fatalf("Could not send message: %s", err)
}
time.Sleep(100 * time.Millisecond) // sleep a bit to allow actual metrics to be updated for sure.
beginCacheSize := test.ScrapeMetricAsInt(addrMetrics, cacheSizeMetricName, "", 0)
@@ -277,6 +281,7 @@ func TestMetricsAvailable(t *testing.T) {
if _, _, err := cl.Exchange(m, tcp); err != nil {
t.Fatalf("Could not send message: %s", err)
}
time.Sleep(100 * time.Millisecond) // sleep a bit to allow actual metrics to be updated for sure.
// we should have metrics from forward, cache, and metrics itself
if err := collectMetricsInfo(metrics.ListenAddr, procMetric, procCache, procCacheMiss, procForward); err != nil {