Skip to content

Commit

Permalink
failoverRecovery test fix for metrics and logs (#31007)
Browse files Browse the repository at this point in the history
Fixes FailoverRecovery test issue from #31006 for both metrics and logs
as well.
  • Loading branch information
akats7 authored Feb 1, 2024
1 parent 365d278 commit dc415ae
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
12 changes: 6 additions & 6 deletions connector/failoverconnector/logs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func TestLogsWithFailoverError(t *testing.T) {
}

func TestLogsWithFailoverRecovery(t *testing.T) {
t.Skip("Flaky Test - See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/31005")
var sinkFirst, sinkSecond, sinkThird consumertest.LogsSink
logsFirst := component.NewIDWithName(component.DataTypeLogs, "logs/first")
logsSecond := component.NewIDWithName(component.DataTypeLogs, "logs/second")
Expand Down Expand Up @@ -178,12 +179,11 @@ func TestLogsWithFailoverRecovery(t *testing.T) {
// Simulate recovery of exporter
failoverConnector.failover.ModifyConsumerAtIndex(0, consumertest.NewNop())

time.Sleep(100 * time.Millisecond)

_, ch, ok = failoverConnector.failover.getCurrentConsumer()
idx = failoverConnector.failover.pS.ChannelIndex(ch)
assert.True(t, ok)
require.Equal(t, idx, 0)
require.Eventually(t, func() bool {
_, ch, ok = failoverConnector.failover.getCurrentConsumer()
idx = failoverConnector.failover.pS.ChannelIndex(ch)
return ok && idx == 0
}, 3*time.Second, 100*time.Millisecond)
}

func sampleLog() plog.Logs {
Expand Down
12 changes: 6 additions & 6 deletions connector/failoverconnector/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ func TestMetricsWithFailoverError(t *testing.T) {
}

func TestMetricsWithFailoverRecovery(t *testing.T) {
t.Skip("Flaky Test - See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/31005")
var sinkSecond, sinkThird consumertest.MetricsSink
metricsFirst := component.NewIDWithName(component.DataTypeMetrics, "metrics/first")
metricsSecond := component.NewIDWithName(component.DataTypeMetrics, "metrics/second")
Expand Down Expand Up @@ -179,12 +180,11 @@ func TestMetricsWithFailoverRecovery(t *testing.T) {
// Simulate recovery of exporter
failoverConnector.failover.ModifyConsumerAtIndex(0, consumertest.NewNop())

time.Sleep(100 * time.Millisecond)

_, ch, ok = failoverConnector.failover.getCurrentConsumer()
idx = failoverConnector.failover.pS.ChannelIndex(ch)
assert.True(t, ok)
require.Equal(t, idx, 0)
require.Eventually(t, func() bool {
_, ch, ok = failoverConnector.failover.getCurrentConsumer()
idx = failoverConnector.failover.pS.ChannelIndex(ch)
return ok && idx == 0
}, 3*time.Second, 100*time.Millisecond)
}

func sampleMetric() pmetric.Metrics {
Expand Down
1 change: 1 addition & 0 deletions connector/failoverconnector/traces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ func TestTracesWithFailoverError(t *testing.T) {
}

func TestTracesWithFailoverRecovery(t *testing.T) {
t.Skip("Flaky Test - See https://github.com/open-telemetry/opentelemetry-collector-contrib/issues/31005")
var sinkSecond, sinkThird consumertest.TracesSink
tracesFirst := component.NewIDWithName(component.DataTypeTraces, "traces/first")
tracesSecond := component.NewIDWithName(component.DataTypeTraces, "traces/second")
Expand Down

0 comments on commit dc415ae

Please sign in to comment.