Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions acceptance/bundle/migrate/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,10 @@ EnvMatrix.DMS = [""]

# workspace list prints each state file's object id, minted per run.
[[Repls]]
Old = '(?m)^\d+(\s+FILE)'
New = '[OBJECT_ID]${1}'
Old = '(?m)^\d+ +FILE\b'
New = '[OBJECT_ID] FILE'

# The ID column width depends on ID length, not migration behavior.
[[Repls]]
Old = '(?m)^ID +Type Language Path$'
New = 'ID Type Language Path'
6 changes: 6 additions & 0 deletions acceptance/test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,9 @@ New = 'json.plan_version = [PLAN_VERSION];'

# The lineage hash (libs/shortid) is not masked: fixture lineages hash to stable values, and
# tests with a freshly minted lineage register its hash with read_lineage.py.

# Workspace TreeIDs can be short (for example, in LITE). Match the deployment path
# rather than arbitrary numbers so version numbers and counts stay visible.
[[Repls]]
Old = '\bdeployments/[0-9]+\b'
New = 'deployments/[DEPLOYMENT_ID]'
2 changes: 1 addition & 1 deletion libs/testserver/alerts.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func (s *FakeWorkspace) writeAlertFile(alert sql.AlertV2) error {
Info: workspace.ObjectInfo{
ObjectType: "FILE",
Path: filePath,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
Data: data,
}
Expand Down
2 changes: 1 addition & 1 deletion libs/testserver/bundledeployments.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (s *FakeWorkspace) CreateDeployment(req Request) Response {
if resp, ok := s.requireParentDirectory(nodePath); !ok {
return resp
}
objectID := nextID()
objectID := nextTreenodeID()
s.files[nodePath] = FileEntry{
Info: workspace.ObjectInfo{
// The service registers its own node type, which get-status reports back;
Expand Down
30 changes: 19 additions & 11 deletions libs/testserver/fake_workspace.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"strconv"
"strings"
"sync"
"sync/atomic"
"time"

"github.com/databricks/databricks-sdk-go/service/compute"
Expand Down Expand Up @@ -99,8 +100,15 @@ var (
idMutex sync.Mutex
lastNowNano int64
lastNowMilli int64
workspaceID atomic.Int64
)

// nextTreenodeID starts above common version numbers and counts, which scripts
// can otherwise mask when registering literal ID replacements.
func nextTreenodeID() int64 {
return 1000 + workspaceID.Add(1)
}

// IDs are prefixed with 7 and padded to avoid matching regex 1[78]\d{14}
func nextID() int64 {
// offset enough so that it does not match UNIX_TIME_NANO regex
Expand Down Expand Up @@ -444,40 +452,40 @@ func NewFakeWorkspace(url, token string) *FakeWorkspace {
"/Workspace": {
ObjectType: "DIRECTORY",
Path: "/Workspace",
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
"/Users": {
ObjectType: "DIRECTORY",
Path: "/Users",
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
"/Users/" + TestUser.UserName: {
ObjectType: "DIRECTORY",
Path: "/Users/" + TestUser.UserName,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
"/Users/" + TestUserSP.UserName: {
ObjectType: "DIRECTORY",
Path: "/Users/" + TestUserSP.UserName,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
// The user home also exists under the /Workspace alias on real
// workspaces, so model it here too. Imports require the parent
// directory to exist (see WorkspaceFilesImportFile).
"/Workspace/Users": {
ObjectType: "DIRECTORY",
Path: "/Workspace/Users",
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
"/Workspace/Users/" + TestUser.UserName: {
ObjectType: "DIRECTORY",
Path: "/Workspace/Users/" + TestUser.UserName,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
"/Workspace/Users/" + TestUserSP.UserName: {
ObjectType: "DIRECTORY",
Path: "/Workspace/Users/" + TestUserSP.UserName,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
},
files: make(map[string]FileEntry),
Expand Down Expand Up @@ -824,7 +832,7 @@ func (s *FakeWorkspace) WorkspaceMkdirs(request workspace.Mkdirs) {
s.directories[dir] = workspace.ObjectInfo{
ObjectType: "DIRECTORY",
Path: dir,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
}
}
}
Expand Down Expand Up @@ -1049,7 +1057,7 @@ func (s *FakeWorkspace) importFile(filePath string, body []byte, overwrite, dete
ObjectType: "NOTEBOOK",
Path: workspacePath,
Language: lang,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
Data: body,
}
Expand All @@ -1061,7 +1069,7 @@ func (s *FakeWorkspace) importFile(filePath string, body []byte, overwrite, dete
Info: workspace.ObjectInfo{
ObjectType: "FILE",
Path: workspacePath,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
Data: body,
}
Expand Down Expand Up @@ -1119,7 +1127,7 @@ func (s *FakeWorkspace) WorkspaceImportNotebook(filePath string, body []byte, la
ObjectType: "NOTEBOOK",
Path: filePath,
Language: language,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
},
Data: body,
}
Expand Down
2 changes: 1 addition & 1 deletion libs/testserver/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func AddDefaultHandlers(server *Server) {
req.Workspace.directories[dir] = workspace.ObjectInfo{
ObjectType: "DIRECTORY",
Path: dir,
ObjectId: nextID(),
ObjectId: nextTreenodeID(),
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion libs/testserver/repos.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func (s *FakeWorkspace) ReposCreate(req Request) Response {
}
}

repoId := nextID()
repoId := nextTreenodeID()
id := strconv.FormatInt(repoId, 10)

repoInfo := workspace.RepoInfo{
Expand Down
Loading