Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 214
Add acceptance test for bundle run#2695
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
31b7ad0bf234c442f6ecf4f43fb990c6ad06002e0d1b5ff48c442378152d982f0d1dc5080d1bf58d28a9993956205cd18ca2748d5898b2c11996d3f88b6dc8fd2600c93c5e3fbbbbf30eb58d11007a7140c9fbf7edf7051769acf74061036c0d34f7112a9de647dab0be3be9c150a51c39d0b132212aa27fb464bb5e212339ec48a2c773684ef33dc996b58afcc296609c05dbacff901de5a3487dc24b690a95848c094db558612126684b18e19474d9b5f5e987220b2ba81e398f33a89ea61443c4ff1528669566239f4b28ea87ea6d161aa7ffe5dc56f6f5a0fcc5df30dffa7d46902c0c1ac63b57925e5e6ea4b0bb768fa6151bb515f2d396fc218add0f88056fd2a6f0694fd43bd7fd2f755ff71a22576a16e1f36d744c327f52a06b4972305f192bf456File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| bundle: | ||
| name: caterpillar | ||
| resources: | ||
| jobs: | ||
| foo: | ||
| name: foo | ||
| tasks: | ||
| - task_key: task | ||
| spark_python_task: | ||
| python_file: ./foo.py | ||
| environment_key: default | ||
| environments: | ||
| - environment_key: default | ||
| spec: | ||
| client: "2" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| print(1) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| === no run key specified | ||
| >>> [CLI] bundle run | ||
| Error: expected a KEY of the resource to run | ||
| Exit code: 1 | ||
| === deploy and run resource | ||
| >>> [CLI] bundle deploy | ||
| Uploading bundle files to /Workspace/Users/[USERNAME]/.bundle/caterpillar/default/files... | ||
| Deploying resources... | ||
| Updating deployment state... | ||
| Deployment complete! | ||
| >>> [CLI] bundle run foo | ||
| Run URL: [DATABRICKS_URL]/job/run/1 | ||
| [DATE] HH:MM:SS "run-name" TERMINATED | ||
| === no resource key with -- | ||
| >>> [CLI] bundle run -- | ||
| Error: expected a KEY of the resource to run | ||
| Exit code: 1 | ||
| === resource key with parameters | ||
| >>> [CLI] bundle run foo -- arg1 arg2 | ||
| Run URL: [DATABRICKS_URL]/job/run/2 | ||
| [DATE] HH:MM:SS "run-name" TERMINATED | ||
| === inline script | ||
| >>> [CLI] bundle run -- echo hello | ||
| hello |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| title "no run key specified" | ||
| errcode trace $CLI bundle run | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: personally prefer smaller tests, easier to review/debug and faster to run. e.g. you could split error-raising commands from the rest. if you have one command then you also don't need to specify title (it's test name), errcode and trace. ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough, but in this case it's only 5 commands so still small. The flip side is you end up with a bunch of really granular files / tests which does not seem optimal. | ||
| title "deploy and run resource" | ||
| errcode trace $CLI bundle deploy | ||
| errcode trace $CLI bundle run foo | ||
| title "no resource key with --" | ||
| errcode trace $CLI bundle run -- | ||
| title "resource key with parameters" | ||
| errcode trace $CLI bundle run foo -- arg1 arg2 | ||
| title "inline script" | ||
| errcode trace $CLI bundle run -- echo "hello" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| [[Repls]] | ||
| Old = "(?:[01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]" | ||
| New = "HH:MM:SS" | ||
| [[Repls]] | ||
| Old = '20\d\d-\d\d-\d\d' | ||
| New = '[DATE]' |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -20,13 +20,16 @@ import ( | ||
| // FakeWorkspace holds a state of a workspace for acceptance tests. | ||
| type FakeWorkspace struct { | ||
| mu sync.Mutex | ||
| mu sync.Mutex | ||
| url string | ||
| directories map[string]bool | ||
| files map[string][]byte | ||
| // normally, ids are not sequential, but we make them sequential for deterministic diff | ||
| nextJobId int64 | ||
| jobs map[int64]jobs.Job | ||
| nextJobId int64 | ||
| nextJobRunId int64 | ||
| jobs map[int64]jobs.Job | ||
| jobRuns map[int64]jobs.Run | ||
| Pipelines map[string]pipelines.PipelineSpec | ||
| Monitors map[string]catalog.MonitorInfo | ||
| @@ -70,19 +73,21 @@ func MapDelete[T any](w *FakeWorkspace, collection map[string]T, key string) Res | ||
| return Response{} | ||
| } | ||
| func NewFakeWorkspace() *FakeWorkspace { | ||
| func NewFakeWorkspace(url string) *FakeWorkspace { | ||
| return &FakeWorkspace{ | ||
| url: url, | ||
| directories: map[string]bool{ | ||
| "/Workspace": true, | ||
| }, | ||
| files: map[string][]byte{}, | ||
| jobs: map[int64]jobs.Job{}, | ||
| nextJobId: 1, | ||
| Pipelines: map[string]pipelines.PipelineSpec{}, | ||
| Monitors: map[string]catalog.MonitorInfo{}, | ||
| Apps: map[string]apps.App{}, | ||
| Schemas: map[string]catalog.SchemaInfo{}, | ||
| files: map[string][]byte{}, | ||
| jobs: map[int64]jobs.Job{}, | ||
| jobRuns: map[int64]jobs.Run{}, | ||
| nextJobId: 1, | ||
| nextJobRunId: 1, | ||
| Pipelines: map[string]pipelines.PipelineSpec{}, | ||
| Monitors: map[string]catalog.MonitorInfo{}, | ||
| Apps: map[string]apps.App{}, | ||
| Schemas: map[string]catalog.SchemaInfo{}, | ||
| } | ||
| } | ||
| @@ -247,6 +252,52 @@ func (s *FakeWorkspace) JobsGet(jobId string) Response { | ||
| } | ||
| } | ||
| func (s *FakeWorkspace) JobsRunNow(jobId int64) Response { | ||
| defer s.LockUnlock()() | ||
| _, ok := s.jobs[jobId] | ||
| if !ok { | ||
| return Response{ | ||
| StatusCode: 404, | ||
| } | ||
| } | ||
| runId := s.nextJobRunId | ||
| s.nextJobRunId++ | ||
| s.jobRuns[runId] = jobs.Run{ | ||
| RunId: runId, | ||
| State: &jobs.RunState{ | ||
| LifeCycleState: jobs.RunLifeCycleStateRunning, | ||
| }, | ||
| RunPageUrl: fmt.Sprintf("%s/job/run/%d", s.url, runId), | ||
| RunType: jobs.RunTypeJobRun, | ||
| RunName: "run-name", | ||
| } | ||
| return Response{ | ||
| Body: jobs.RunNowResponse{ | ||
| RunId: runId, | ||
| }, | ||
| } | ||
| } | ||
| func (s *FakeWorkspace) JobsGetRun(runId int64) Response { | ||
| defer s.LockUnlock()() | ||
| run, ok := s.jobRuns[runId] | ||
| if !ok { | ||
| return Response{ | ||
| StatusCode: 404, | ||
| } | ||
| } | ||
| // Mark the run as terminated. | ||
| run.State.LifeCycleState = jobs.RunLifeCycleStateTerminated | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems to be very specific to a particular test, might not be reusable. Perhaps instead you can have explicit endpoint to update this field?
| ||
| return Response{ | ||
| Body: run, | ||
| } | ||
| } | ||
| func (s *FakeWorkspace) PipelinesGet(pipelineId string) Response { | ||
| defer s.LockUnlock()() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is it here? The last command is "echo" which includes a newline.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The run command itself has a trailing space in it's output, not the echo command. Specifically:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this easily fixable? I would prefer to keep this ignore list to the absolute minimum.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to fix in #2864