Skip to content

Commit

Permalink
Fix integration tests TestRecoverFromInvalidOutputConfiguration (elas…
Browse files Browse the repository at this point in the history
…tic#40195)

TestRecoverFromInvalidOutputConfiguration was failing due to a closed
channel being closed again. Since 0e9c9de was introduced the
Filestream input is reporting its status, which leads Filebeat to make
more CheckIn calls to the Elastic-Agent. The test could not handle the
extra calls.

A boolean atomic flag has been introduced to indicate the channel has
already been closed.
  • Loading branch information
belimawr authored Jul 11, 2024
1 parent da2cfb5 commit a3fc591
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion x-pack/filebeat/tests/integration/managerV2_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,9 +504,17 @@ func TestRecoverFromInvalidOutputConfiguration(t *testing.T) {
// We use `success` to signal the test has ended successfully
// if `success` is never closed, then the test will fail with a timeout.
success := make(chan struct{})

// succeededChannelClosed is set to true whenever the `success`
// channel is closed. The Filestream input now is reporting its state
// to the Elastic-Agent, which cases more checkins to happen, thus the
// `success` channel was being close twice. `succeededChannelClosed`
// prevents that from happening.
succeededChannelClosed := atomic.Bool{}
// The test is successful when we reach the last element of `protoUnits`
onObserved := func(observed *proto.CheckinObserved, protoUnitsIdx int) {
if protoUnitsIdx == len(protos)-1 {
if protoUnitsIdx == len(protos)-1 && !succeededChannelClosed.Load() {
succeededChannelClosed.Store(true)
close(success)
}
}
Expand Down

0 comments on commit a3fc591

Please sign in to comment.