Skip to content

Commit

Permalink
Simplify the test for gRPC streams metrics tags
Browse files Browse the repository at this point in the history
  • Loading branch information
olegbespalov committed Jul 16, 2024
1 parent e79ee2c commit 21d369e
Showing 1 changed file with 4 additions and 24 deletions.
28 changes: 4 additions & 24 deletions js/modules/k6/grpc/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -417,34 +417,14 @@ func TestStream_MetricsTagsMetadata(t *testing.T) {

stub := &featureExplorerStub{}

savedFeatures := []*grpcservice.Feature{
{
stub.listFeatures = func(_ *grpcservice.Rectangle, stream grpcservice.FeatureExplorer_ListFeaturesServer) error {
return stream.Send(&grpcservice.Feature{
Name: "foo",
Location: &grpcservice.Point{
Latitude: 1,
Longitude: 2,
},
},
{
Name: "bar",
Location: &grpcservice.Point{
Latitude: 3,
Longitude: 4,
},
},
}

stub.listFeatures = func(_ *grpcservice.Rectangle, stream grpcservice.FeatureExplorer_ListFeaturesServer) error {
for _, feature := range savedFeatures {
// adding a delay to make server response "slower"
time.Sleep(200 * time.Millisecond)

if err := stream.Send(feature); err != nil {
return err
}
}

return nil
})
}

grpcservice.RegisterFeatureExplorerServer(ts.httpBin.ServerGRPC, stub)
Expand Down Expand Up @@ -497,7 +477,7 @@ func TestStream_MetricsTagsMetadata(t *testing.T) {

samplesBuf := metrics.GetBufferedSamples(ts.samples)

assert.Len(t, samplesBuf, 5)
assert.Len(t, samplesBuf, 4)
for _, samples := range samplesBuf {
for _, sample := range samples.GetSamples() {
assertTags(t, sample, expTags)
Expand Down

0 comments on commit 21d369e

Please sign in to comment.