Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TestOutputFlush always enabled #3146

Merged
merged 2 commits into from
Jun 29, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions output/cloud/expv2/integration/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"net/http"
"net/http/httptest"
"os"
"sort"
"testing"
"time"

Expand All @@ -32,8 +33,7 @@ func TestOutputFlush(t *testing.T) {
// TODO: it has 3s for aggregation time
// then it means it will execute for +3s that it is a waste of time
// because it isn't really required.
// Reduce the aggregation time (to 1s?) then run always.
t.Skip("Skip the integration test, if required enable it manually")
// Reduce the aggregation time (to 1s?)
t.Parallel()

results := make(chan *pbcloud.MetricSet)
Expand Down Expand Up @@ -63,21 +63,27 @@ func TestOutputFlush(t *testing.T) {
})

// wait for results
mset := <-results
capturedMetrics := <-results
close(results)
assert.NoError(t, o.StopWithTestError(nil))

// sort the metrics' result by name to have a deterministic order
// that should be same as the expected json
sort.Slice(capturedMetrics.Metrics, func(i, j int) bool {
return capturedMetrics.Metrics[i].Name < capturedMetrics.Metrics[j].Name
})

// read and convert the json version
// of the expected protobuf sent request
var exp pbcloud.MetricSet
expjs, err := os.ReadFile("./testdata/metricset.json") //nolint:forbidigo // ReadFile here is used in a test
expectedMetrics, err := os.ReadFile("./testdata/metricset.json") //nolint:forbidigo // ReadFile here is used in a test
require.NoError(t, err)
err = protojson.Unmarshal(expjs, &exp)
err = protojson.Unmarshal(expectedMetrics, &exp)
require.NoError(t, err)

msetjs, err := protojson.Marshal(mset)
actualMetrics, err := protojson.Marshal(capturedMetrics)
require.NoError(t, err)
assert.JSONEq(t, string(expjs), string(msetjs))
assert.JSONEq(t, string(expectedMetrics), string(actualMetrics))
}

func metricsHandler(results chan<- *pbcloud.MetricSet) http.HandlerFunc {
Expand Down