Skip to content

Commit cb71496

Browse files
Fix TestLock not to create a new repo (#3201)
## Why This integration test creates a repo when it does not need to. Repos have been a persistent source of flakiness because they do not behave well under load. This PR reduces flakiness and improves CI health. Failure logs: ``` === FAIL: integration/libs/git TestFetchRepositoryInfoAPI_FromRepo (re-run 2) (4.42s) Error: Received unexpected error: a Workspace object at path /Repos/***/integration-test-e7844b5d8018420996b3bb0f95aec84e already exists. Try a different path for your Repo or rename the existing Workspace object. ```
1 parent 941aa5d commit cb71496

1 file changed

Lines changed: 1 addition & 29 deletions

File tree

integration/libs/locker/locker_test.go

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package locker_test
33
import (
44
"context"
55
"encoding/json"
6-
"fmt"
76
"io"
87
"io/fs"
98
"math/rand"
@@ -12,43 +11,16 @@ import (
1211
"time"
1312

1413
"github.com/databricks/cli/integration/internal/acc"
15-
"github.com/databricks/cli/internal/testutil"
1614
"github.com/databricks/cli/libs/filer"
1715
lockpkg "github.com/databricks/cli/libs/locker"
18-
"github.com/databricks/databricks-sdk-go"
19-
"github.com/databricks/databricks-sdk-go/service/workspace"
2016
"github.com/stretchr/testify/assert"
2117
"github.com/stretchr/testify/require"
2218
)
2319

24-
// TODO: create a utility function to create an empty test repo for tests and refactor sync_test integration test
25-
26-
const EmptyRepoUrl = "https://github.com/shreyas-goenka/empty-repo.git"
27-
28-
func createRemoteTestProject(t *testing.T, projectNamePrefix string, wsc *databricks.WorkspaceClient) string {
29-
ctx := context.TODO()
30-
me, err := wsc.CurrentUser.Me(ctx)
31-
assert.NoError(t, err)
32-
33-
remoteProjectRoot := fmt.Sprintf("/Repos/%s/%s", me.UserName, testutil.RandomName(projectNamePrefix))
34-
repoInfo, err := wsc.Repos.Create(ctx, workspace.CreateRepoRequest{
35-
Path: remoteProjectRoot,
36-
Url: EmptyRepoUrl,
37-
Provider: "gitHub",
38-
})
39-
assert.NoError(t, err)
40-
t.Cleanup(func() {
41-
err := wsc.Repos.DeleteByRepoId(ctx, repoInfo.Id)
42-
assert.NoError(t, err)
43-
})
44-
45-
return remoteProjectRoot
46-
}
47-
4820
func TestLock(t *testing.T) {
4921
ctx, wt := acc.WorkspaceTest(t)
5022
wsc := wt.W
51-
remoteProjectRoot := createRemoteTestProject(t, "lock-acc-", wsc)
23+
remoteProjectRoot := acc.TemporaryWorkspaceDir(wt, "lock-acc-")
5224

5325
// 5 lockers try to acquire a lock at the same time
5426
numConcurrentLocks := 5

0 commit comments

Comments
 (0)