From f8899ee310fd42a528bbf11065c847811705df87 Mon Sep 17 00:00:00 2001 From: Alexandre Gaudreault Date: Mon, 5 Jan 2026 15:18:26 -0500 Subject: [PATCH] test(e2e): unstable CMP e2e test when running locally (#25752) Signed-off-by: Alexandre Gaudreault --- Makefile | 1 + Procfile | 4 +- test/e2e/custom_tool_test.go | 109 +++++----------------------- test/e2e/fixture/app/context_cmp.go | 87 ++++++++++++++++++++++ test/e2e/fixture/gitconfig | 8 ++ test/e2e/hydrator_test.go | 11 +-- 6 files changed, 118 insertions(+), 102 deletions(-) create mode 100644 test/e2e/fixture/app/context_cmp.go create mode 100644 test/e2e/fixture/gitconfig diff --git a/Makefile b/Makefile index 3472f5a0f2..2fe2dfc27e 100644 --- a/Makefile +++ b/Makefile @@ -507,6 +507,7 @@ start-e2e-local: mod-vendor-local dep-ui-local cli-local ARGOCD_GPG_ENABLED=$(ARGOCD_GPG_ENABLED) \ ARGOCD_PLUGINCONFIGFILEPATH=/tmp/argo-e2e/app/config/plugin \ ARGOCD_PLUGINSOCKFILEPATH=/tmp/argo-e2e/app/config/plugin \ + ARGOCD_GIT_CONFIG=$(PWD)/test/e2e/fixture/gitconfig \ ARGOCD_E2E_DISABLE_AUTH=false \ ARGOCD_ZJWT_FEATURE_FLAG=always \ ARGOCD_IN_CI=$(ARGOCD_IN_CI) \ diff --git a/Procfile b/Procfile index b3f57144a1..f5bddd2086 100644 --- a/Procfile +++ b/Procfile @@ -2,7 +2,7 @@ controller: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run api-server: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "GOCOVERDIR=${ARGOCD_COVERAGE_DIR:-/tmp/coverage/api-server} FORCE_LOG_COLORS=1 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} ARGOCD_BINARY_NAME=argocd-server $COMMAND --loglevel debug --redis localhost:${ARGOCD_E2E_REDIS_PORT:-6379} --disable-auth=${ARGOCD_E2E_DISABLE_AUTH:-'true'} --insecure --dex-server http://localhost:${ARGOCD_E2E_DEX_PORT:-5556} --repo-server localhost:${ARGOCD_E2E_REPOSERVER_PORT:-8081} --port ${ARGOCD_E2E_APISERVER_PORT:-8080} --otlp-address=${ARGOCD_OTLP_ADDRESS} --application-namespaces=${ARGOCD_APPLICATION_NAMESPACES:-''} --hydrator-enabled=${ARGOCD_HYDRATOR_ENABLED:='false'}" dex: sh -c "ARGOCD_BINARY_NAME=argocd-dex go run github.com/argoproj/argo-cd/v3/cmd gendexcfg -o `pwd`/dist/dex.yaml && (test -f dist/dex.yaml || { echo 'Failed to generate dex configuration'; exit 1; }) && docker run --rm -p ${ARGOCD_E2E_DEX_PORT:-5556}:${ARGOCD_E2E_DEX_PORT:-5556} -v `pwd`/dist/dex.yaml:/dex.yaml ghcr.io/dexidp/dex:$(grep "image: ghcr.io/dexidp/dex" manifests/base/dex/argocd-dex-server-deployment.yaml | cut -d':' -f3) dex serve /dex.yaml" redis: hack/start-redis-with-password.sh -repo-server: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "GOCOVERDIR=${ARGOCD_COVERAGE_DIR:-/tmp/coverage/repo-server} FORCE_LOG_COLORS=1 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_GNUPGHOME=${ARGOCD_GNUPGHOME:-/tmp/argocd-local/gpg/keys} ARGOCD_PLUGINSOCKFILEPATH=${ARGOCD_PLUGINSOCKFILEPATH:-./test/cmp} ARGOCD_GPG_DATA_PATH=${ARGOCD_GPG_DATA_PATH:-/tmp/argocd-local/gpg/source} ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} ARGOCD_BINARY_NAME=argocd-repo-server ARGOCD_GPG_ENABLED=${ARGOCD_GPG_ENABLED:-false} $COMMAND --loglevel debug --port ${ARGOCD_E2E_REPOSERVER_PORT:-8081} --redis localhost:${ARGOCD_E2E_REDIS_PORT:-6379} --otlp-address=${ARGOCD_OTLP_ADDRESS}" +repo-server: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "export PATH=./dist:\$PATH && [ -n \"\$ARGOCD_GIT_CONFIG\" ] && export GIT_CONFIG_GLOBAL=\$ARGOCD_GIT_CONFIG && export GIT_CONFIG_NOSYSTEM=1; GOCOVERDIR=${ARGOCD_COVERAGE_DIR:-/tmp/coverage/repo-server} FORCE_LOG_COLORS=1 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_GNUPGHOME=${ARGOCD_GNUPGHOME:-/tmp/argocd-local/gpg/keys} ARGOCD_PLUGINSOCKFILEPATH=${ARGOCD_PLUGINSOCKFILEPATH:-./test/cmp} ARGOCD_GPG_DATA_PATH=${ARGOCD_GPG_DATA_PATH:-/tmp/argocd-local/gpg/source} ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} ARGOCD_BINARY_NAME=argocd-repo-server ARGOCD_GPG_ENABLED=${ARGOCD_GPG_ENABLED:-false} $COMMAND --loglevel debug --port ${ARGOCD_E2E_REPOSERVER_PORT:-8081} --redis localhost:${ARGOCD_E2E_REDIS_PORT:-6379} --otlp-address=${ARGOCD_OTLP_ADDRESS}" cmp-server: [ "$ARGOCD_E2E_TEST" = 'true' ] && exit 0 || [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "FORCE_LOG_COLORS=1 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_BINARY_NAME=argocd-cmp-server ARGOCD_PLUGINSOCKFILEPATH=${ARGOCD_PLUGINSOCKFILEPATH:-./test/cmp} $COMMAND --config-dir-path ./test/cmp --loglevel debug --otlp-address=${ARGOCD_OTLP_ADDRESS}" commit-server: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "GOCOVERDIR=${ARGOCD_COVERAGE_DIR:-/tmp/coverage/commit-server} FORCE_LOG_COLORS=1 ARGOCD_BINARY_NAME=argocd-commit-server $COMMAND --loglevel debug --port ${ARGOCD_E2E_COMMITSERVER_PORT:-8086}" ui: sh -c 'cd ui && ${ARGOCD_E2E_YARN_CMD:-yarn} start' @@ -11,4 +11,4 @@ helm-registry: test/fixture/testrepos/start-helm-registry.sh oci-registry: test/fixture/testrepos/start-authenticated-helm-registry.sh dev-mounter: [ "$ARGOCD_E2E_TEST" != "true" ] && go run hack/dev-mounter/main.go --configmap argocd-ssh-known-hosts-cm=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} --configmap argocd-tls-certs-cm=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} --configmap argocd-gpg-keys-cm=${ARGOCD_GPG_DATA_PATH:-/tmp/argocd-local/gpg/source} applicationset-controller: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "GOCOVERDIR=${ARGOCD_COVERAGE_DIR:-/tmp/coverage/applicationset-controller} FORCE_LOG_COLORS=4 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_SSH_DATA_PATH=${ARGOCD_SSH_DATA_PATH:-/tmp/argocd-local/ssh} ARGOCD_BINARY_NAME=argocd-applicationset-controller $COMMAND --loglevel debug --metrics-addr localhost:12345 --probe-addr localhost:12346 --argocd-repo-server localhost:${ARGOCD_E2E_REPOSERVER_PORT:-8081}" -notification: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "GOCOVERDIR=${ARGOCD_COVERAGE_DIR:-/tmp/coverage/notification} FORCE_LOG_COLORS=4 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_BINARY_NAME=argocd-notifications $COMMAND --loglevel debug --application-namespaces=${ARGOCD_APPLICATION_NAMESPACES:-''} --self-service-notification-enabled=${ARGOCD_NOTIFICATION_CONTROLLER_SELF_SERVICE_NOTIFICATION_ENABLED:-'false'}" \ No newline at end of file +notification: [ "$BIN_MODE" = 'true' ] && COMMAND=./dist/argocd || COMMAND='go run ./cmd/main.go' && sh -c "GOCOVERDIR=${ARGOCD_COVERAGE_DIR:-/tmp/coverage/notification} FORCE_LOG_COLORS=4 ARGOCD_FAKE_IN_CLUSTER=true ARGOCD_TLS_DATA_PATH=${ARGOCD_TLS_DATA_PATH:-/tmp/argocd-local/tls} ARGOCD_BINARY_NAME=argocd-notifications $COMMAND --loglevel debug --application-namespaces=${ARGOCD_APPLICATION_NAMESPACES:-''} --self-service-notification-enabled=${ARGOCD_NOTIFICATION_CONTROLLER_SELF_SERVICE_NOTIFICATION_ENABLED:-'false'}" diff --git a/test/e2e/custom_tool_test.go b/test/e2e/custom_tool_test.go index f80dbaa328..0bc2322f73 100644 --- a/test/e2e/custom_tool_test.go +++ b/test/e2e/custom_tool_test.go @@ -1,12 +1,10 @@ package e2e import ( - "os" "path/filepath" "sort" "strings" "testing" - "time" "github.com/argoproj/gitops-engine/pkg/health" . "github.com/argoproj/gitops-engine/pkg/sync/common" @@ -23,11 +21,7 @@ import ( func TestCustomToolWithGitCreds(t *testing.T) { ctx := Given(t) ctx. - And(func() { - go startCMPServer(t, "./testdata/cmp-gitcreds") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-gitcreds"). CustomCACertAdded(). // add the private repo with credentials HTTPSRepoURLAdded(true). @@ -51,11 +45,7 @@ func TestCustomToolWithGitCreds(t *testing.T) { func TestCustomToolWithGitCredsTemplate(t *testing.T) { ctx := Given(t) ctx. - And(func() { - go startCMPServer(t, "./testdata/cmp-gitcredstemplate") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-gitcredstemplate"). CustomCACertAdded(). // add the git creds template HTTPSCredentialsUserPassAdded(). @@ -92,11 +82,7 @@ func TestCustomToolWithSSHGitCreds(t *testing.T) { ctx := Given(t) // path does not matter, we ignore it ctx. - And(func() { - go startCMPServer(t, "./testdata/cmp-gitsshcreds") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-gitsshcreds"). // add the private repo with ssh credentials CustomSSHKnownHostsAdded(). SSHRepoURLAdded(true). @@ -126,11 +112,7 @@ func TestCustomToolWithSSHGitCredsDisabled(t *testing.T) { ctx := Given(t) // path does not matter, we ignore it ctx. - And(func() { - go startCMPServer(t, "./testdata/cmp-gitsshcreds-disable-provide") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-gitsshcreds-disable-provide"). CustomCACertAdded(). // add the private repo with ssh credentials CustomSSHKnownHostsAdded(). @@ -150,11 +132,7 @@ func TestCustomToolWithSSHGitCredsDisabled(t *testing.T) { func TestCustomToolWithEnv(t *testing.T) { ctx := Given(t) ctx. - And(func() { - go startCMPServer(t, "./testdata/cmp-fileName") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-fileName"). // does not matter what the path is Path("cmp-fileName"). When(). @@ -211,11 +189,7 @@ func TestCustomToolSyncAndDiffLocal(t *testing.T) { ctx := Given(t) appPath := filepath.Join(testdataPath, "guestbook") ctx. - And(func() { - go startCMPServer(t, "./testdata/cmp-kustomize") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-kustomize"). // does not matter what the path is Path("guestbook"). When(). @@ -233,29 +207,11 @@ func TestCustomToolSyncAndDiffLocal(t *testing.T) { }) } -func startCMPServer(t *testing.T, configFile string) { - t.Helper() - pluginSockFilePath := fixture.TmpDir + fixture.PluginSockFilePath - t.Setenv("ARGOCD_BINARY_NAME", "argocd-cmp-server") - // ARGOCD_PLUGINSOCKFILEPATH should be set as the same value as repo server env var - t.Setenv("ARGOCD_PLUGINSOCKFILEPATH", pluginSockFilePath) - if _, err := os.Stat(pluginSockFilePath); os.IsNotExist(err) { - // path/to/whatever does not exist - err := os.Mkdir(pluginSockFilePath, 0o700) - require.NoError(t, err) - } - errors.NewHandler(t).FailOnErr(fixture.RunWithStdin("", "", "../../dist/argocd", "--config-dir-path", configFile)) -} - // Discover by fileName func TestCMPDiscoverWithFileName(t *testing.T) { pluginName := "cmp-fileName" Given(t). - And(func() { - go startCMPServer(t, "./testdata/cmp-fileName") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-fileName"). Path(pluginName + "/subdir"). When(). CreateApp(). @@ -269,11 +225,7 @@ func TestCMPDiscoverWithFileName(t *testing.T) { // Discover by Find glob func TestCMPDiscoverWithFindGlob(t *testing.T) { Given(t). - And(func() { - go startCMPServer(t, "./testdata/cmp-find-glob") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-find-glob"). Path("guestbook"). When(). CreateApp(). @@ -287,11 +239,7 @@ func TestCMPDiscoverWithFindGlob(t *testing.T) { // Discover by Plugin Name func TestCMPDiscoverWithPluginName(t *testing.T) { Given(t). - And(func() { - go startCMPServer(t, "./testdata/cmp-find-glob") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-find-glob"). Path("guestbook"). When(). CreateFromFile(func(app *Application) { @@ -310,11 +258,7 @@ func TestCMPDiscoverWithFindCommandWithEnv(t *testing.T) { pluginName := "cmp-find-command" ctx := Given(t) ctx. - And(func() { - go startCMPServer(t, "./testdata/cmp-find-command") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-find-command"). Path(pluginName). When(). CreateApp(). @@ -349,12 +293,9 @@ func TestCMPDiscoverWithFindCommandWithEnv(t *testing.T) { } func TestPruneResourceFromCMP(t *testing.T) { - Given(t). - And(func() { - go startCMPServer(t, "./testdata/cmp-find-glob") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + ctx := Given(t) + ctx. + RunningCMPServer("./testdata/cmp-find-glob"). Path("guestbook"). When(). CreateApp(). @@ -373,11 +314,7 @@ func TestPruneResourceFromCMP(t *testing.T) { func TestPreserveFileModeForCMP(t *testing.T) { Given(t). - And(func() { - go startCMPServer(t, "./testdata/cmp-preserve-file-mode") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata/cmp-preserve-file-mode"). Path("cmp-preserve-file-mode"). When(). CreateFromFile(func(app *Application) { @@ -393,11 +330,7 @@ func TestPreserveFileModeForCMP(t *testing.T) { func TestCMPWithSymlinkPartialFiles(t *testing.T) { Given(t, fixture.WithTestData("testdata2")). - And(func() { - go startCMPServer(t, "./testdata2/cmp-symlink") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata2/cmp-symlink"). Path("guestbook-partial-symlink-files"). When(). CreateApp(). @@ -410,11 +343,7 @@ func TestCMPWithSymlinkPartialFiles(t *testing.T) { func TestCMPWithSymlinkFiles(t *testing.T) { Given(t, fixture.WithTestData("testdata2")). - And(func() { - go startCMPServer(t, "./testdata2/cmp-symlink") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata2/cmp-symlink"). Path("guestbook-symlink-files"). When(). CreateApp(). @@ -427,11 +356,7 @@ func TestCMPWithSymlinkFiles(t *testing.T) { func TestCMPWithSymlinkFolder(t *testing.T) { Given(t, fixture.WithTestData("testdata2")). - And(func() { - go startCMPServer(t, "./testdata2/cmp-symlink") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + RunningCMPServer("./testdata2/cmp-symlink"). Path("guestbook-symlink-folder"). When(). CreateApp(). diff --git a/test/e2e/fixture/app/context_cmp.go b/test/e2e/fixture/app/context_cmp.go new file mode 100644 index 0000000000..990309563f --- /dev/null +++ b/test/e2e/fixture/app/context_cmp.go @@ -0,0 +1,87 @@ +package app + +import ( + "os" + "path" + "testing" + "time" + + "github.com/stretchr/testify/require" + + "github.com/argoproj/argo-cd/v3/cmpserver/plugin" + "github.com/argoproj/argo-cd/v3/test/e2e/fixture" + "github.com/argoproj/argo-cd/v3/util/errors" +) + +// RunningCMPServer starts a CMP server with the given config directory and waits for it to be ready. +// It blocks until the CMP socket is created or times out after 10 seconds. +func (c *Context) RunningCMPServer(configFile string) *Context { + c.t.Helper() + startCMPServer(c.t, configFile) + c.t.Setenv("ARGOCD_BINARY_NAME", "argocd") + return c +} + +// startCMPServer starts the CMP server and waits for its socket to be ready. +// It blocks until the socket file is created or times out after 10 seconds. +func startCMPServer(t *testing.T, configDir string) { + t.Helper() + pluginSockFilePath := path.Join(fixture.TmpDir, fixture.PluginSockFilePath) + t.Setenv("ARGOCD_BINARY_NAME", "argocd-cmp-server") + // ARGOCD_PLUGINSOCKFILEPATH should be set as the same value as repo server env var + t.Setenv("ARGOCD_PLUGINSOCKFILEPATH", pluginSockFilePath) + if _, err := os.Stat(pluginSockFilePath); os.IsNotExist(err) { + err := os.Mkdir(pluginSockFilePath, 0o700) + require.NoError(t, err) + } + + // Read plugin config to get expected socket path + cfg, err := plugin.ReadPluginConfig(configDir) + require.NoError(t, err, "failed to read plugin config from %s", configDir) + expectedSocket := cfg.Address() + + // Remove stale socket if it exists from a previous test run + if err := os.Remove(expectedSocket); err != nil && !os.IsNotExist(err) { + require.NoError(t, err, "failed to remove stale socket") + } + + // Start CMP server in goroutine (non-blocking) + go func() { + errors.NewHandler(t).FailOnErr(fixture.RunWithStdin("", "", "../../dist/argocd", "--config-dir-path", configDir)) + }() + + // Wait for socket to be created + waitForSocket(t, expectedSocket, 10*time.Second) +} + +// waitForSocket polls for a socket file to exist with exponential backoff +func waitForSocket(t *testing.T, socketPath string, timeout time.Duration) { + t.Helper() + deadline := time.Now().Add(timeout) + + sleepIntervals := []time.Duration{ + 10 * time.Millisecond, + 20 * time.Millisecond, + 50 * time.Millisecond, + 100 * time.Millisecond, + 200 * time.Millisecond, + 500 * time.Millisecond, + } + sleepIdx := 0 + + for time.Now().Before(deadline) { + if info, err := os.Stat(socketPath); err == nil { + if info.Mode()&os.ModeSocket != 0 { + return // Socket exists and is a socket! + } + } + if sleepIdx < len(sleepIntervals) { + time.Sleep(sleepIntervals[sleepIdx]) + sleepIdx++ + } else { + time.Sleep(500 * time.Millisecond) + } + } + + t.Fatalf("CMP socket %s did not appear within %v", socketPath, timeout) +} diff --git a/test/e2e/fixture/gitconfig b/test/e2e/fixture/gitconfig new file mode 100644 index 0000000000..56e8f992eb --- /dev/null +++ b/test/e2e/fixture/gitconfig @@ -0,0 +1,8 @@ +# Git configuration for e2e tests +# This file ensures reproducible test behavior by disabling system credential helpers + +[credential] + helper = + +[core] + askPass = diff --git a/test/e2e/hydrator_test.go b/test/e2e/hydrator_test.go index bc2111e92b..4dbe196b69 100644 --- a/test/e2e/hydrator_test.go +++ b/test/e2e/hydrator_test.go @@ -2,7 +2,6 @@ package e2e import ( "testing" - "time" "github.com/stretchr/testify/require" @@ -255,13 +254,9 @@ func TestHydratorWithDirectory(t *testing.T) { } func TestHydratorWithPlugin(t *testing.T) { - Given(t). - Path("hydrator-plugin"). - And(func() { - go startCMPServer(t, "./testdata/hydrator-plugin") - time.Sleep(100 * time.Millisecond) - t.Setenv("ARGOCD_BINARY_NAME", "argocd") - }). + ctx := Given(t) + ctx.Path("hydrator-plugin"). + RunningCMPServer("./testdata/hydrator-plugin"). When(). CreateFromFile(func(app *Application) { app.Spec.Source = nil