From 6c9bf5e7c764845a004a613e4794724883298613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marco=20Andr=C3=A9=20Dinis?= Date: Sat, 23 Dec 2023 15:48:25 +0000 Subject: [PATCH] Tests: check DiscoveryFetch events before creating resource (#36008) After creating a DiscoveryConfig with valid matchers, the DiscoveryService will fetch Cloud Resources and emit a DiscoveryFetchEvent. The test was asserting that the number of FetchEvents was zero right after creating the DiscoveryConfig, but it might happen that between the CreateDiscoveryConfig and reading the DiscoveryFetchEventCount, the DiscoveryConfig was processed, a new fetch was triggered and an event emitted. This PR moves the check to before the CreateDiscoveryConfig call. --- lib/srv/discovery/discovery_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/srv/discovery/discovery_test.go b/lib/srv/discovery/discovery_test.go index f69f61341ff35..3f2650c844e98 100644 --- a/lib/srv/discovery/discovery_test.go +++ b/lib/srv/discovery/discovery_test.go @@ -1930,9 +1930,9 @@ func TestDiscoveryDatabaseRemovingDiscoveryConfigs(t *testing.T) { ) require.NoError(t, err) + require.Zero(t, reporter.DiscoveryFetchEventCount()) _, err = tlsServer.Auth().DiscoveryConfigClient().CreateDiscoveryConfig(ctx, dc1) require.NoError(t, err) - require.Zero(t, reporter.DiscoveryFetchEventCount()) // Check for new resource in reconciler expectDatabases := []types.Database{awsRDSDB}