Skip to content
This repository was archived by the owner on Jan 30, 2025. It is now read-only.

Commit e6db54c

Browse files
author
Ivan Mirić
committed
Revert "Add metrics emission test (#167)"
This reverts commit dac5c9a. Page.WaitForLoadState() isn't enough to avoid flakiness[1], so reverting this for now. [1]: https://github.com/grafana/xk6-browser/runs/4608718007
1 parent dac5c9a commit e6db54c

File tree

2 files changed

+0
-127
lines changed

2 files changed

+0
-127
lines changed

tests/metrics_test.go

Lines changed: 0 additions & 62 deletions
This file was deleted.

tests/network_manager_test.go

Lines changed: 0 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,10 @@ package tests
2323
import (
2424
"testing"
2525

26-
"github.com/grafana/xk6-browser/common"
2726
"github.com/stretchr/testify/assert"
28-
"github.com/stretchr/testify/require"
29-
k6metrics "go.k6.io/k6/lib/metrics"
30-
k6stats "go.k6.io/k6/stats"
3127
)
3228

3329
func TestDataURLSkipRequest(t *testing.T) {
34-
t.Parallel()
3530
tb := newTestBrowser(t)
3631
p := tb.NewPage(nil)
3732

@@ -41,63 +36,3 @@ func TestDataURLSkipRequest(t *testing.T) {
4136

4237
assert.True(t, lc.contains("skipped request handling of data URL"))
4338
}
44-
45-
func TestMetricsEmission(t *testing.T) {
46-
t.Parallel()
47-
tb := newTestBrowser(t, withHTTPServer())
48-
49-
url := tb.URL("/get")
50-
browserTags := map[string]string{
51-
"group": "",
52-
"url": "about:blank",
53-
}
54-
httpTags := map[string]string{
55-
"method": "GET",
56-
"url": url,
57-
"status": "200",
58-
"group": "",
59-
"proto": "http/1.1",
60-
"from_cache": "false",
61-
"from_prefetch_cache": "false",
62-
"from_service_worker": "false",
63-
}
64-
expMetricTags := map[string]map[string]string{
65-
common.BrowserDOMContentLoaded.Name: browserTags,
66-
common.BrowserLoaded.Name: browserTags,
67-
k6metrics.DataSentName: map[string]string{
68-
"group": "",
69-
"method": "GET",
70-
"url": url,
71-
},
72-
k6metrics.HTTPReqsName: httpTags,
73-
k6metrics.HTTPReqDurationName: httpTags,
74-
k6metrics.DataReceivedName: httpTags,
75-
k6metrics.HTTPReqConnectingName: httpTags,
76-
k6metrics.HTTPReqTLSHandshakingName: httpTags,
77-
k6metrics.HTTPReqSendingName: httpTags,
78-
k6metrics.HTTPReqReceivingName: httpTags,
79-
}
80-
81-
p := tb.NewPage(nil)
82-
resp := p.Goto(url, nil)
83-
require.NotNil(t, resp)
84-
85-
// Wait for all metrics to be emitted
86-
p.WaitForLoadState("networkidle", nil)
87-
88-
bufSamples := k6stats.GetBufferedSamples(tb.samples)
89-
90-
var reqsCount int
91-
cb := func(sample k6stats.Sample) {
92-
switch sample.Metric.Name {
93-
case k6metrics.HTTPReqsName:
94-
reqsCount += int(sample.Value)
95-
case k6metrics.DataSentName, k6metrics.DataReceivedName:
96-
assert.Greaterf(t, int(sample.Value), 0,
97-
"metric %s", sample.Metric.Name)
98-
}
99-
}
100-
101-
assertMetricsEmitted(t, bufSamples, expMetricTags, cb)
102-
assert.Equal(t, 1, reqsCount)
103-
}

0 commit comments

Comments
 (0)