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

Add acceptance tests #2081

Merged
merged 22 commits into from
Jan 8, 2025
Merged

Add acceptance tests #2081

merged 22 commits into from
Jan 8, 2025

Conversation

denik
Copy link
Contributor

@denik denik commented Jan 6, 2025

Changes

  • New kind of test is added - acceptance tests. See acceptance/README.md for explanation.
  • A few tests are converted to acceptance tests by moving databricks.yml to acceptance/ and adding corresponding script files.

As these tests run against compiled binary and can capture full output of the command, they can be useful to support major changes such as refactoring internal logging / diagnostics or complex variable interpolation.

These are currently run as part of 'make test' but the intention is to run them as part of integration tests as well.

Benefits

  • Full binary is tested, exactly as users get it.
    • We're not testing custom set of mutators like many existing tests.
    • Not mocking anything, real SDK is used (although the HTTP endpoint is not a real Databricks env).
  • Easy to maintain: output can be updated automatically.
  • Can easily set up external env, such as env vars, CLI args, .databrickscfg location etc.

Gaps

The tests currently share the test server and there is global place to define handlers. We should have a way for tests to override / add new handlers.

Tests

I manually checked that output of new acceptance tests matches previous asserts.

@denik denik force-pushed the denik/acceptance-tests branch from b036c0c to 60b1a77 Compare January 6, 2025 12:06
@denik denik force-pushed the denik/acceptance-tests branch from d9a41f8 to 1dbab3c Compare January 6, 2025 12:22
@denik denik force-pushed the denik/acceptance-tests branch from 1dbab3c to 28a69a1 Compare January 6, 2025 12:23
@denik denik force-pushed the denik/acceptance-tests branch from 5e0f5f3 to 30aa795 Compare January 6, 2025 12:48
@denik denik changed the base branch from main to gotestsum-format January 6, 2025 12:49
@denik denik temporarily deployed to test-trigger-is January 6, 2025 12:56 — with GitHub Actions Inactive
Base automatically changed from gotestsum-format to main January 6, 2025 13:12
@denik denik force-pushed the denik/acceptance-tests branch from 6be8afb to 151e62f Compare January 6, 2025 13:38
@denik denik marked this pull request as ready for review January 6, 2025 13:44
@denik
Copy link
Contributor Author

denik commented Jan 6, 2025

@@ -0,0 +1,4 @@
$CLI bundle validate -o json | jq '{resources,variables}' > out.default.json
Copy link
Contributor

Choose a reason for hiding this comment

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

since it's a bash script, shall we better name it script.sh to make it more clear?

Copy link
Contributor Author

@denik denik Jan 6, 2025

Choose a reason for hiding this comment

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

I don't know if 'bash' is going to stay or it is going to be the only thing that's used.

I think we might want to support other runners, especially for interactive use case. For example, expect or pexpect https://pexpect.readthedocs.io/en/stable/overview.html

Copy link
Contributor

Choose a reason for hiding this comment

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

Idea: We could use the extension to determine the runner? script.sh vs script.py?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could still do that once we have add another runner. script for current bash case and script.py for python runner.

acceptance/acceptance_test.go Show resolved Hide resolved
acceptance/acceptance_test.go Show resolved Hide resolved
acceptance/acceptance_test.go Outdated Show resolved Hide resolved
acceptance/acceptance_test.go Show resolved Hide resolved
acceptance/acceptance_test.go Show resolved Hide resolved
acceptance/acceptance_test.go Show resolved Hide resolved
@denik denik force-pushed the denik/acceptance-tests branch from 384b212 to 2d6504e Compare January 7, 2025 23:35
@denik denik temporarily deployed to test-trigger-is January 7, 2025 23:35 — with GitHub Actions Inactive
Copy link
Contributor

@pietern pietern left a comment

Choose a reason for hiding this comment

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

A few small remaining things. Approving to unblock merge.

break
}

dir = filepath.Dir(dir)
Copy link
Contributor

Choose a reason for hiding this comment

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

Please add a require.True(t, filepath.IsLocal(dir)) in there to make sure this remains true.

acceptance/acceptance_test.go Outdated Show resolved Hide resolved
acceptance/build/.gitignore Outdated Show resolved Hide resolved
acceptance/merge-string-map/databricks.yml Outdated Show resolved Hide resolved
@denik denik temporarily deployed to test-trigger-is January 8, 2025 12:15 — with GitHub Actions Inactive
@denik denik enabled auto-merge January 8, 2025 12:16
@denik denik temporarily deployed to test-trigger-is January 8, 2025 12:20 — with GitHub Actions Inactive
@denik denik added this pull request to the merge queue Jan 8, 2025
Merged via the queue into main with commit 185bbd2 Jan 8, 2025
9 checks passed
@denik denik deleted the denik/acceptance-tests branch January 8, 2025 12:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants