Skip to content

Commit

Permalink
make test failures more verbose
Browse files Browse the repository at this point in the history
  • Loading branch information
faec committed Dec 30, 2024
1 parent 4df3155 commit b2ef6d3
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions libbeat/outputs/logstash/logstash_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"encoding/json"
"fmt"
"os"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -424,8 +423,8 @@ func testSendMultipleBatchesViaLogstash(
}

for _, batch := range batches {
ok := ls.BulkPublish(batch)
assert.Equal(t, true, ok)
result := ls.BulkPublish(batch)
assert.Equal(t, outest.BatchACK, result)
}

// wait for logstash event flush + elasticsearch
Expand Down Expand Up @@ -569,20 +568,17 @@ func (t *testOutputer) PublishEvent(event beat.Event) {
t.Publish(context.Background(), batch)
}

func (t *testOutputer) BulkPublish(events []beat.Event) bool {
ok := false
func (t *testOutputer) BulkPublish(events []beat.Event) outest.BatchSignalTag {
resultChan := make(chan outest.BatchSignalTag, 1)
batch := encodeBatch(t.encoder, outest.NewBatch(events...))

Check failure on line 573 in libbeat/outputs/logstash/logstash_integration_test.go

View workflow job for this annotation

GitHub Actions / lint (darwin)

cannot infer B (libbeat/outputs/logstash/logstash_integration_test.go:588:18) (typecheck)

var wg sync.WaitGroup
wg.Add(1)
batch.OnSignal = func(sig outest.BatchSignal) {
ok = sig.Tag == outest.BatchACK
wg.Done()
resultChan <- sig.Tag
close(resultChan)
}

t.Publish(context.Background(), batch)
wg.Wait()
return ok
return <-resultChan
}

// encodeBatch encodes a publisher.Batch so it can be provided to
Expand Down

0 comments on commit b2ef6d3

Please sign in to comment.