From e0d54f0bb6a017f231bda41a37583ef09030a1ff Mon Sep 17 00:00:00 2001 From: shreyas-goenka <88374338+shreyas-goenka@users.noreply.github.com> Date: Mon, 9 Dec 2024 18:04:27 +0530 Subject: [PATCH] Do not run mlops-stacks integration test in parallel (#1982) ## Changes This test changes the cwd using the `testutil.Chdir` function. This causes flakiness with other integration tests, like `TestAccWorkspaceFilesExtensionsNotebooksAreNotDeletedAsFiles`, which rely on the cwd being configured correctly to read test fixtures. The `t.Setenv` call in `testutil.Chdir` ensures that it is not run from a test whose upstream is executing in parallel. --- internal/init_test.go | 1 - internal/testutil/env.go | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/init_test.go b/internal/init_test.go index 25bfc19da..839d8185d 100644 --- a/internal/init_test.go +++ b/internal/init_test.go @@ -39,7 +39,6 @@ func TestAccBundleInitErrorOnUnknownFields(t *testing.T) { // make changes that can break the MLOps Stacks DAB. In which case we should // skip this test until the MLOps Stacks DAB is updated to work again. func TestAccBundleInitOnMlopsStacks(t *testing.T) { - t.Parallel() env := testutil.GetCloud(t).String() tmpDir1 := t.TempDir() diff --git a/internal/testutil/env.go b/internal/testutil/env.go index e1973ba82..7a7436f47 100644 --- a/internal/testutil/env.go +++ b/internal/testutil/env.go @@ -51,6 +51,10 @@ func GetEnvOrSkipTest(t *testing.T, name string) string { // Changes into specified directory for the duration of the test. // Returns the current working directory. func Chdir(t *testing.T, dir string) string { + // Prevent parallel execution when changing the working directory. + // t.Setenv automatically fails if t.Parallel is set. + t.Setenv("DO_NOT_RUN_IN_PARALLEL", "true") + wd, err := os.Getwd() require.NoError(t, err)