From 8ba0e464c81dddc8eab7dc5746d1e464db9cd511 Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Wed, 15 Jun 2022 11:02:56 -0600 Subject: [PATCH 1/2] test: update wait for statement for postgres The postgres docker image will start up and immediately shutdown the service will the docker entrypoint starts configuration. This results in the expected ready to accept connections log message to show up twice. This generally happens within a tenth of a second, but in CI this can get hit and the test will fail as the database is not yet up. fixes: #11292 --- plugins/inputs/postgresql/postgresql_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/inputs/postgresql/postgresql_test.go b/plugins/inputs/postgresql/postgresql_test.go index 0ae557a8eb672..2a06de48ad219 100644 --- a/plugins/inputs/postgresql/postgresql_test.go +++ b/plugins/inputs/postgresql/postgresql_test.go @@ -21,7 +21,7 @@ func launchTestContainer(t *testing.T) *testutil.Container { "POSTGRES_HOST_AUTH_METHOD": "trust", }, WaitingFor: wait.ForAll( - wait.ForLog("database system is ready to accept connections"), + wait.ForLog("database system is ready to accept connections").WithOccurrence(2), wait.ForListeningPort(nat.Port(servicePort)), ), } From 387e134674a917e35f58429ee6264bb42d77a84d Mon Sep 17 00:00:00 2001 From: Josh Powers Date: Thu, 16 Jun 2022 09:08:14 -0600 Subject: [PATCH 2/2] add comment about 2 starts --- plugins/inputs/postgresql/postgresql_test.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plugins/inputs/postgresql/postgresql_test.go b/plugins/inputs/postgresql/postgresql_test.go index 2a06de48ad219..98e5c0ee26065 100644 --- a/plugins/inputs/postgresql/postgresql_test.go +++ b/plugins/inputs/postgresql/postgresql_test.go @@ -21,6 +21,8 @@ func launchTestContainer(t *testing.T) *testutil.Container { "POSTGRES_HOST_AUTH_METHOD": "trust", }, WaitingFor: wait.ForAll( + // the database comes up twice, once right away, then again a second + // time after the docker entrypoint starts configuraiton wait.ForLog("database system is ready to accept connections").WithOccurrence(2), wait.ForListeningPort(nat.Port(servicePort)), ),