Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
Fix equivalence test (#208)
Browse files Browse the repository at this point in the history
* Revert "Use endpoint instead of connection in equivalence_test (#207)"

This reverts commit b2a517b.

* Make test result more accurate
  • Loading branch information
songy23 committed Sep 12, 2019
1 parent b2a517b commit ac1282a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion equivalence_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,17 @@ func TestEquivalenceStatsVsMetricsUploads(t *testing.T) {
server, addr, doneFn := createFakeServer(t)
defer doneFn()

// Now create a gRPC connection to the fake Stackdriver server.
conn, err := grpc.Dial(addr, grpc.WithInsecure())
if err != nil {
t.Fatalf("Failed to make a gRPC connection to the server: %v", err)
}
defer conn.Close()

// Finally create the OpenCensus stats exporter
exporterOptions := Options{
ProjectID: "equivalence",
MonitoringClientOptions: []option.ClientOption{option.WithEndpoint(addr)},
MonitoringClientOptions: []option.ClientOption{option.WithGRPCConn(conn)},

// Setting this time delay threshold to a very large value
// so that batching is performed deterministically and flushing is
Expand Down Expand Up @@ -342,6 +349,14 @@ func TestEquivalenceStatsVsMetricsUploads(t *testing.T) {
stackdriverMetricDescriptorsFromMetricsPb = append(stackdriverMetricDescriptorsFromMetricsPb, sdmd)
})

if len(stackdriverTimeSeriesFromMetrics) == 0 {
t.Fatalf("Failed to export timeseries with metrics")
}

if len(stackdriverTimeSeriesFromMetricsPb) == 0 {
t.Fatalf("Failed to export timeseries with metrics pb")
}

// The results should be equal now
if diff := cmpTSReqs(stackdriverTimeSeriesFromMetricsPb, stackdriverTimeSeriesFromMetrics); diff != "" {
t.Fatalf("Unexpected CreateTimeSeriesRequests -FromMetricsPb +FromMetrics: %s", diff)
Expand Down

0 comments on commit ac1282a

Please sign in to comment.