Skip to content

Commit

Permalink
Add retry tests for Deadline_Exceeded and Unavailable response codes
Browse files Browse the repository at this point in the history
  • Loading branch information
damemi committed Jun 12, 2023
1 parent b1b89dd commit 8a04d55
Show file tree
Hide file tree
Showing 6 changed files with 1,470 additions and 1 deletion.
6 changes: 6 additions & 0 deletions exporter/collector/integrationtest/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ func TestCollectorMetrics(t *testing.T) {
}
require.NoError(t, testServerExporter.Shutdown(ctx))

if !test.ExpectRetries {
require.Zero(t, testServer.RetryCount, "Server returned >0 retries when not expected")
} else {
require.NotZero(t, testServer.RetryCount, "Server returned 0 retries when expected >0")
}

expectFixture := test.LoadMetricFixture(
t,
test.ExpectFixturePath,
Expand Down
2 changes: 2 additions & 0 deletions exporter/collector/integrationtest/testcases/testcase.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ type TestCase struct {
SkipForSDK bool
// ExpectErr sets whether the test is expected to fail
ExpectErr bool
// ExpectRetries sets whether the test expects the server to report multiple attempts
ExpectRetries bool
}

func (tc *TestCase) LoadOTLPTracesInput(
Expand Down
24 changes: 24 additions & 0 deletions exporter/collector/integrationtest/testcases/testcases_metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -252,5 +252,29 @@ var MetricsTestCases = []TestCase{
},
SkipForSDK: true,
},
{
Name: "Write ahead log enabled, basic Counter with unavailable return code",
OTLPInputFixturePath: "testdata/fixtures/metrics/basic_counter_metrics.json",
ExpectFixturePath: "testdata/fixtures/metrics/basic_counter_metrics_wal_unavailable_expect.json",
ConfigureCollector: func(cfg *collector.Config) {
cfg.ProjectID = "unavailableproject"
cfg.MetricConfig.WALConfig.Enabled = true
cfg.MetricConfig.WALConfig.Directory, _ = os.MkdirTemp("", "test-wal-")
},
SkipForSDK: true,
ExpectRetries: true,
},
{
Name: "Write ahead log enabled, basic Counter with deadline_exceeded return code",
OTLPInputFixturePath: "testdata/fixtures/metrics/basic_counter_metrics.json",
ExpectFixturePath: "testdata/fixtures/metrics/basic_counter_metrics_wal_deadline_expect.json",
ConfigureCollector: func(cfg *collector.Config) {
cfg.ProjectID = "deadline_exceededproject"
cfg.MetricConfig.WALConfig.Enabled = true
cfg.MetricConfig.WALConfig.Directory, _ = os.MkdirTemp("", "test-wal-")
},
SkipForSDK: true,
ExpectRetries: true,
},
// TODO: Add integration tests for workload.googleapis.com metrics from the ops agent
}
Loading

0 comments on commit 8a04d55

Please sign in to comment.