diff --git a/x-pack/filebeat/input/cometd/input.go b/x-pack/filebeat/input/cometd/input.go index 014f77922e13..0a455156980a 100644 --- a/x-pack/filebeat/input/cometd/input.go +++ b/x-pack/filebeat/input/cometd/input.go @@ -39,10 +39,10 @@ func (in *cometdInput) Run() { in.workerOnce.Do(func() { in.workerWg.Add(1) go func() { - in.log.Info("Input worker has started.") - defer in.log.Info("Input worker has stopped.") defer in.workerWg.Done() defer in.workerCancel() + in.log.Info("Input worker has started.") + defer in.log.Info("Input worker has stopped.") in.b = bay.Bayeux{} rt := rate.NewLimiter(rate.Every(retryInterval), 1) diff --git a/x-pack/filebeat/input/cometd/input_test.go b/x-pack/filebeat/input/cometd/input_test.go index 458db7596c84..a5db28ef2304 100644 --- a/x-pack/filebeat/input/cometd/input_test.go +++ b/x-pack/filebeat/input/cometd/input_test.go @@ -522,7 +522,6 @@ func newTestServer(URL string, handler http.Handler) (*httptest.Server, error) { } func TestNegativeCases(t *testing.T) { - t.Skip("https://github.com/elastic/beats/issues/47698") expectedHTTPEventCount = 1 defer atomic.StoreUint64(&called, 0) eventsCh := make(chan beat.Event) @@ -582,13 +581,14 @@ func TestNegativeCases(t *testing.T) { require.NotNil(t, input) input.Run() - go func() { - <-eventsCh - assert.Error(t, fmt.Errorf("there should be no events")) - }() // wait for run to return error or event - time.Sleep(100 * time.Millisecond) + select { + case <-eventsCh: + t.Error("expected no events, but received one") + case <-time.After(100 * time.Millisecond): + // Expected: no events received. + } input.Stop() }