Skip to content
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

acc: replace LocalOnly option with Local & Cloud #2387

Merged
merged 10 commits into from
Feb 26, 2025
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
8 changes: 6 additions & 2 deletions acceptance/acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,12 @@ func runTest(t *testing.T, dir, coverDir string, repls testdiff.ReplacementsCont
}

cloudEnv := os.Getenv("CLOUD_ENV")
if isTruePtr(config.LocalOnly) && cloudEnv != "" {
t.Skipf("Disabled via LocalOnly setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv)
if !isTruePtr(config.Local) && cloudEnv == "" {
t.Skipf("Disabled via Local setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv)
}

if !isTruePtr(config.Cloud) && cloudEnv != "" {
t.Skipf("Disabled via Cloud setting in %s (CLOUD_ENV=%s)", configPath, cloudEnv)
}

var tmpDir string
Expand Down
2 changes: 0 additions & 2 deletions acceptance/auth/bundle_and_profile/test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
LocalOnly=true

# Some of the clouds have DATABRICKS_HOST variable setup without https:// prefix
# In the result, output is replaced with DATABRICKS_URL variable instead of DATABRICKS_HOST
# This is a workaround to replace DATABRICKS_URL with DATABRICKS_HOST
Expand Down
2 changes: 0 additions & 2 deletions acceptance/auth/credentials/test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
LocalOnly = true

RecordRequests = true
IncludeRequestHeaders = ["Authorization", "User-Agent"]

Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/debug/test.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LocalOnly = true
Cloud = false

[[Repls]]
# The keys are unsorted and also vary per OS
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/generate/git_job/test.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
LocalOnly = true # This test needs to run against stubbed Databricks API
Cloud = false # This test needs to run against stubbed Databricks API

[[Server]]
Pattern = "GET /api/2.1/jobs/get"
Expand Down
1 change: 1 addition & 0 deletions acceptance/bundle/help/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Cloud = false
2 changes: 1 addition & 1 deletion acceptance/bundle/libraries/maven/test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# We run this test only locally for now because we need to figure out how to do
# bundle destroy on script.cleanup first.
LocalOnly = true
Cloud = false

RecordRequests = true
2 changes: 1 addition & 1 deletion acceptance/bundle/libraries/pypi/test.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# We run this test only locally for now because we need to figure out how to do
# bundle destroy on script.cleanup first.
LocalOnly = true
Cloud = false

RecordRequests = true
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
Badness = '''(minor) error message is not great: executing "" at <user_name>: error calling user_name:'''
LocalOnly = true

[[Server]]
Pattern = "GET /api/2.0/preview/scim/v2/Me"
Expand Down
1 change: 0 additions & 1 deletion acceptance/bundle/templates-machinery/helpers/test.toml

This file was deleted.

3 changes: 1 addition & 2 deletions acceptance/bundle/templates-machinery/test.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# Testing template machinery, by default there is no need to check against cloud.
LocalOnly = true
Cloud = false
2 changes: 1 addition & 1 deletion acceptance/bundle/templates/test.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# At the moment, there are many differences across different envs w.r.t to catalog use, node type and so on.
LocalOnly = true
Cloud = false
2 changes: 2 additions & 0 deletions acceptance/bundle/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Local = true
Cloud = true
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Since we use existing cluster id value which is not available in cloud envs, we need to stub the request
# and run this test only locally
LocalOnly = true
Cloud = false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these layers of override can be difficult to track. Could you add some functionality to see the resolved configuration for a test case or directory as a follow-up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think there is an easy way, so you'll have to track those manually. For a given boolean option you only need to know the closest setting though, not the whole chain.


[[Server]]
Pattern = "GET /api/2.1/clusters/get"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Since we use existing cluster id value which is not available in cloud envs, we need to stub the request
# and run this test only locally
LocalOnly = true
Cloud = false

[[Server]]
Pattern = "GET /api/2.1/clusters/get"
Expand Down
2 changes: 1 addition & 1 deletion acceptance/bundle/variables/test.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The tests here intend to test variable interpolation via "bundle validate".
# Even though "bundle validate" does a few API calls, that's not the focus there.
LocalOnly = true
Cloud = false
1 change: 0 additions & 1 deletion acceptance/cmd/workspace/apps/test.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
LocalOnly = true
RecordRequests = true

[[Server]]
Expand Down
7 changes: 5 additions & 2 deletions acceptance/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@ type TestConfig struct {
// If absent, default to true.
GOOS map[string]bool

// If true, do not run this test against cloud environment
LocalOnly *bool
// If true, run this test when running locally with a testserver
Local *bool

// If true, run this test when running with cloud env configured
Cloud *bool

// List of additional replacements to apply on this test.
// Old is a regexp, New is a replacement expression.
Expand Down
1 change: 0 additions & 1 deletion acceptance/selftest/server/test.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
LocalOnly = true
RecordRequests = true

[[Server]]
Expand Down
1 change: 0 additions & 1 deletion acceptance/selftest/test.toml

This file was deleted.

3 changes: 3 additions & 0 deletions acceptance/terraform/test.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
Local = true
Cloud = true

[[Repls]]
Old = 'Read complete after [^\s]+'
New = 'Read complete after (redacted)'
3 changes: 3 additions & 0 deletions acceptance/test.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Default settings that apply to all tests unless overriden by test.toml files in inner directories.
Local = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a comment here that this is the global configuration for all tests and that tests are only run locally by default and not as integration tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added a comment

Cloud = false
1 change: 0 additions & 1 deletion acceptance/workspace/jobs/create-error/test.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
LocalOnly = true # request recording currently does not work with cloud environment
RecordRequests = true

[[Server]]
Expand Down
1 change: 0 additions & 1 deletion acceptance/workspace/jobs/create/test.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
LocalOnly = true # request recording currently does not work with cloud environment
RecordRequests = true
IncludeRequestHeaders = ["Authorization", "User-Agent"]

Expand Down