Skip to content

Commit

Permalink
exporter/collector/integrationtest: fix lack of sort expectFixture field
Browse files Browse the repository at this point in the history
Fix: #421

Signed-off-by: Koichi Shiraishi <[email protected]>
  • Loading branch information
zchee committed Jun 28, 2022
1 parent 39a7dbd commit 7afca26
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion exporter/collector/integrationtest/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package integrationtest

import (
"context"
"sort"
"testing"
"time"

Expand Down Expand Up @@ -58,6 +59,15 @@ func TestMetrics(t *testing.T) {
startTime,
endTime,
)
sort.Slice(expectFixture.CreateTimeSeriesRequests, func(i, j int) bool {
return expectFixture.CreateTimeSeriesRequests[i].Name < expectFixture.CreateTimeSeriesRequests[j].Name
})
sort.Slice(expectFixture.CreateMetricDescriptorRequests, func(i, j int) bool {
return expectFixture.CreateMetricDescriptorRequests[i].Name < expectFixture.CreateMetricDescriptorRequests[j].Name
})
sort.Slice(expectFixture.CreateServiceTimeSeriesRequests, func(i, j int) bool {
return expectFixture.CreateServiceTimeSeriesRequests[i].Name < expectFixture.CreateServiceTimeSeriesRequests[j].Name
})

selfObsMetrics, err := inMemoryOCExporter.Proto(ctx)
require.NoError(t, err)
Expand All @@ -67,19 +77,37 @@ func TestMetrics(t *testing.T) {
CreateServiceTimeSeriesRequests: testServer.CreateServiceTimeSeriesRequests(),
SelfObservabilityMetrics: selfObsMetrics,
}
sort.Slice(fixture.CreateTimeSeriesRequests, func(i, j int) bool {
return fixture.CreateTimeSeriesRequests[i].Name < fixture.CreateTimeSeriesRequests[j].Name
})
sort.Slice(fixture.CreateMetricDescriptorRequests, func(i, j int) bool {
return fixture.CreateMetricDescriptorRequests[i].Name < fixture.CreateMetricDescriptorRequests[j].Name
})
sort.Slice(fixture.CreateServiceTimeSeriesRequests, func(i, j int) bool {
return fixture.CreateServiceTimeSeriesRequests[i].Name < fixture.CreateServiceTimeSeriesRequests[j].Name
})
diff := DiffMetricProtos(
t,
fixture,
expectFixture,
func(i, j int) bool {
return fixture.CreateTimeSeriesRequests[i].Name > fixture.CreateTimeSeriesRequests[j].Name
return fixture.CreateTimeSeriesRequests[i].Name < fixture.CreateTimeSeriesRequests[j].Name
},
func(i, j int) bool {
return fixture.CreateMetricDescriptorRequests[i].Name < fixture.CreateMetricDescriptorRequests[j].Name
},
func(i, j int) bool {
return fixture.CreateServiceTimeSeriesRequests[i].Name < fixture.CreateServiceTimeSeriesRequests[j].Name
},
func(i, j int) bool {
return expectFixture.CreateTimeSeriesRequests[i].Name < expectFixture.CreateTimeSeriesRequests[j].Name
},
func(i, j int) bool {
return expectFixture.CreateMetricDescriptorRequests[i].Name < expectFixture.CreateMetricDescriptorRequests[j].Name
},
func(i, j int) bool {
return expectFixture.CreateServiceTimeSeriesRequests[i].Name < expectFixture.CreateServiceTimeSeriesRequests[j].Name
},
)
if diff != "" {
require.Fail(
Expand Down

0 comments on commit 7afca26

Please sign in to comment.