Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

test(e2e): address review on the automation tests

varonix9229c6e93981
diff --git a/tests/fixture/postgres_target.go b/tests/fixture/postgres_target.go
index d35bb0c7df..c3b83dab21 100644
--- a/tests/fixture/postgres_target.go
+++ b/tests/fixture/postgres_target.go
@@ -77,10 +77,13 @@ func (p *PostgresTarget) DropRoleAtCleanup(tt *testing.T, name string) {
ctx := context.WithoutCancel(tt.Context())
conn, err := pgx.Connect(ctx, p.external)
if err != nil {
+ tt.Errorf("dropping role %s: connecting to the target: %v", name, err)
return
}
defer func() { _ = conn.Close(ctx) }()
- _, _ = conn.Exec(ctx, "DROP ROLE IF EXISTS "+pgx.Identifier{name}.Sanitize())
+ if _, err := conn.Exec(ctx, "DROP ROLE IF EXISTS "+pgx.Identifier{name}.Sanitize()); err != nil {
+ tt.Errorf("dropping role %s: %v", name, err)
+ }
})
}
diff --git a/tests/suites/secretmanager/syncs/status_test.go b/tests/suites/secretmanager/syncs/status_test.go
index c58430dc10..6cb00d3dbd 100644
--- a/tests/suites/secretmanager/syncs/status_test.go
+++ b/tests/suites/secretmanager/syncs/status_test.go
@@ -18,16 +18,17 @@ import (
func TestSecretSync_Status(t *testing.T) {
t.Parallel()
- t.Run("should end succeeded and deliver the value when the destination fails once", func(t *testing.T) {
+ t.Run("should end succeeded and deliver the value when the first sync job fails", func(t *testing.T) {
t.Parallel()
- spec.Why(t, `A provider error is retried by the queue with backoff. One failure costs a
- 3 s retry, which fits the wait; a failure on every attempt would not.`)
+ spec.Why(t, `The HTTP client retries a 500 three times inside one job, so four failures
+ fail the first job. The queue then retries the job after a 3 s backoff, which fits
+ the wait; a failure on every attempt would not.`)
// Setup
proj, conn, gh := setup(t)
secretmanager.CreateSecret(t, proj, "dev", "API_KEY", "api-value")
s := newSync(t, proj, conn, repoScope("acme", "app"))
- gh.Fail(t, "PUT", "/repos/acme/app/actions/secrets/*", http.StatusInternalServerError, fakenet.Times(1))
+ gh.Fail(t, "PUT", "/repos/acme/app/actions/secrets/*", http.StatusInternalServerError, fakenet.Times(4))
// Action
got := s.triggerExpectingFailure(t)
@@ -35,7 +36,7 @@ func TestSecretSync_Status(t *testing.T) {
// Assert
require.Equalf(t, "succeeded", got.status, "the sync did not recover: %s", got.message)
require.Equal(t, "api-value", gh.Repo(t, "acme/app").Secrets["API_KEY"].Value)
- require.Equal(t, 2, gh.Received(t, "PUT", "/repos/acme/app/actions/secrets/API_KEY"))
+ require.Equal(t, 5, gh.Received(t, "PUT", "/repos/acme/app/actions/secrets/API_KEY"))
})
t.Run("should leave lastSyncedAt empty after a failed run and set it after a successful one", func(t *testing.T) {
diff --git a/tests/suites/secretmanager/syncs/trigger_test.go b/tests/suites/secretmanager/syncs/trigger_test.go
index b5c7353c1e..c11a84f965 100644
--- a/tests/suites/secretmanager/syncs/trigger_test.go
+++ b/tests/suites/secretmanager/syncs/trigger_test.go
@@ -9,6 +9,7 @@ import (
"github.com/Infisical/infisical/tests/fixture/secretmanager"
"github.com/Infisical/infisical/tests/infra/fakenet"
"github.com/Infisical/infisical/tests/internal/spec"
+ "github.com/Infisical/infisical/tests/internal/wait"
"github.com/stretchr/testify/require"
)
@@ -161,15 +162,21 @@ func TestSecretSync_Trigger(t *testing.T) {
proj, conn, gh := setup(t)
secretmanager.CreateFolder(t, proj, "dev", "/a")
secretmanager.CreateFolder(t, proj, "dev", "/b")
- secretmanager.CreateImport(t, proj, "dev", secretmanager.Location{Env: "dev", Path: "/b"}, secretmanager.IntoPath("/a"))
s := newSync(t, proj, conn, repoScope("acme", "app"), fromPath("/a"), autoSync(true))
s.awaitTerminal(t)
+ before := s.get(t).JSON200.SecretSync.LastSyncedAt
+ secretmanager.CreateImport(t, proj, "dev", secretmanager.Location{Env: "dev", Path: "/b"}, secretmanager.IntoPath("/a"))
+ wait.Until(t, "the sync run that creating the import queues", func() bool {
+ got := s.get(t).JSON200.SecretSync.LastSyncedAt
+ return got != nil && (before == nil || got.After(*before))
+ })
+ mark := gh.Mark(t)
// Action
secretmanager.CreateSecret(t, proj, "dev", "LATE_KEY", "late-value", secretmanager.WithPath("/b"))
// Assert
- gh.ExpectEvent[github.SecretCreated](t, created("LATE_KEY"), syncBudget)
+ gh.ExpectEvent[github.SecretCreated](t, created("LATE_KEY"), syncBudget, fakenet.Since(mark))
require.Equal(t, "late-value", gh.Repo(t, "acme/app").Secrets["LATE_KEY"].Value)
})
}