Commit Graph

61 Commits

Author SHA1 Message Date
Denis Bilenko e38d729792 only run --debug test locally 2025-02-04 16:16:29 +01:00
Denis Bilenko de6a27c93d windows fix 2025-02-04 15:57:38 +01:00
Denis Bilenko dcf05f676e avoid empty output.txt 2025-02-04 15:50:22 +01:00
Denis Bilenko b1b8151c3f rebase and update tests output 2025-02-04 15:48:40 +01:00
Denis Bilenko d568637d18 rebase and refresh acceptance tests output 2025-02-04 15:46:46 +01:00
Denis Bilenko b4c68d4fe4 update badness 2025-02-04 15:46:46 +01:00
Denis Bilenko df0b3fcb46 rebase & update acceptance tests 2025-02-04 15:46:46 +01:00
Denis Bilenko 917a9c806c fix bundle/debug 2025-02-04 15:46:46 +01:00
Denis Bilenko f3231ea7a5 do not use 'sort' - produces different result on Windows
Might be fixable with Locale setting (https://stackoverflow.com/a/39172728), but it's easier just not to depend on it.
2025-02-04 15:46:46 +01:00
Denis Bilenko 3c407bc8b5 fix slash on Windows 2025-02-04 15:46:46 +01:00
Denis Bilenko 8df08e8895 Restore back time for debug mode 2025-02-04 15:46:46 +01:00
Denis Bilenko 8666213249 update badness 2025-02-04 15:46:46 +01:00
Denis Bilenko 5aa3bdade4 tweak log output
- remove time
- remove attrs unless level is debug
- replace $DEV_VERSION
- add acceptance test for --debug
2025-02-04 15:46:46 +01:00
Denis Bilenko 9320bd1682
acc: Use [VARNAME] instead of $VARNAME (#2282)
$VARNAME is what we use for environment variables, it's good to
separate.

Some people use envsubst for homemade variable interpolation, it's also
good to have separation there.
2025-02-03 14:10:19 +00:00
Denis Bilenko f267318bb9
Include acceptance tests in integration tests (#2242)
## Changes
- Include acceptance directory in integration tests. Acceptance tests
will not start local server if CLOUD_ENV is set, so they become
integration tests.
- Add dependency for vendor to integration, so that CLI can be build
there.
- Implement LocalOnly option in test.toml to opt out of running
acceptance tests as integration tests. Use it in certain tests that are
difficult or not necessary to fix when run as integration tests.
- Update terraform test to redact timings out.
- Clean up .workspace.current_user from outputs of the tests.

## Tests
Existing tests.
2025-02-03 10:43:25 +00:00
Denis Bilenko e5730bf57e
Use real terraform in acceptance tests (#2267)
## Changes
- Add a script install_terraform.py that downloads terraform and
provider and generates a config to use, inspired by
https://gist.github.com/pietern/1cb6b6f3e0a452328e13cdc75031105e
- Make acceptance tests run this script once before running the tests
and set the required env vars to make cli use this terraform
installation.
- Use OS-specific directory for things that are build by acceptance test
runner (CLI and terraform).

This enables acceptance tests against cloud #2242 and local test for
bundle deploy #2254.

## Tests
- Add an acceptance test for standalone terraform. This is useful to
debug terraform with TF_LOG=DEBUG to see that it uses local provider.
- Other acceptance tests are updated with regard to terraform exec path.
- The overall time for tests locally is unchanged (if terraform is
already fetched).
2025-01-31 13:53:13 +00:00
Denis Bilenko 58ef34f320
acc: Include "id" into /api/2.0/preview/scim/v2/Me response (#2266)
This is something terraform provider expects.

Related to https://github.com/databricks/cli/pull/2242
2025-01-29 17:35:03 +00:00
Denis Bilenko 38efedcd73
Remove bundle.git.inferred (#2258)
The only use case for it was to emit a warning and based on the
discussion here
https://github.com/databricks/cli/pull/2213/files#r1933558087 the
warning it not useful and logging that with reduced severity is also not
useful.
2025-01-29 14:15:52 +00:00
Andrew Nester ec7808da34
Added support for double underscore variable references (#2203)
## Changes
Added support for double underscore variable references.

Previously we made this restriction stronger with no particular reason,
TF provider supports multiple underscores and thus DABs should do as
well.

Fixes #1753

## Tests
Added acceptance and integration tests
2025-01-29 13:38:28 +00:00
Ilya Kuznetsov 59d6fbfee9
Restore variable file tests (#2220)
## Changes

Uncomment flaky tests, they work properly with latest changes from main 

## Tests
<!-- How is this tested? -->
2025-01-29 13:34:26 +00:00
Denis Bilenko 4ba222ab36
Fix env_overrides not to use variables in workspace.profile (#2251)
This does not work when this test is run against cloud.

Needed for https://github.com/databricks/cli/pull/2242
2025-01-28 15:22:56 +01:00
shreyas-goenka 65e4f79dfe
Switch to using `[` from `<` in text replacements (#2224)
## Changes
Noticed this when working on
https://github.com/databricks/cli/pull/2221. `<` is a special HTML
character that is encoded during text replacement when using
`AssertEqualTexts`.


## Tests
N/A
2025-01-28 10:54:23 +00:00
Denis Bilenko 60709e3d48
acc: Restore unexpected output error (#2243)
## Changes
Restore original behaviour of acceptance tests: any unaccounted for
files trigger an error (not just those that start with "out"). This got
changed in
https://github.com/databricks/cli/pull/2146/files#diff-2bb968d823f4afb825e1dcea2879bdbdedf2b7c15d4e77f47905691b14246a04L196
which started only checking files starting with "out*" and skipping
everything else.

## Tests
Existing tests.
2025-01-28 10:15:32 +00:00
Denis Bilenko be908ee1a1
Add acceptance test for 'experimental.scripts' (#2240) 2025-01-27 15:28:33 +00:00
Denis Bilenko 67d1413db5
Add default regex for DEV_VERSION (#2241)
## Changes

- Replace development version with $DEV_VERSION
- Update experimental-jobs-as-code to make use of it.

## Tests
- Existing tests.
- Using this in https://github.com/databricks/cli/pull/2213
2025-01-27 15:34:53 +01:00
Denis Bilenko 52bf7e388a
acc: Propagate user's UV_CACHE_DIR to tests (#2239)
There is a speed up in 0.5s but it is still 4.4s, so something else is
slow there.

Benchmarking bundle/templates/experimental-jobs-as-code:

```
# Without UV_CACHE_DIR
~/work/cli/acceptance/bundle/templates/experimental-jobs-as-code % hyperfine --warmup 2 'testme -count=1'
Benchmark 1: testme -count=1
  Time (mean ± σ):      4.950 s ±  0.079 s    [User: 2.730 s, System: 8.524 s]
  Range (min … max):    4.838 s …  5.076 s    10 runs

# With UV_CACHE_DIR
~/work/cli/acceptance/bundle/templates/experimental-jobs-as-code % hyperfine --warmup 2 'testme -count=1'
Benchmark 1: testme -count=1
  Time (mean ± σ):      4.410 s ±  0.049 s    [User: 2.669 s, System: 8.710 s]
  Range (min … max):    4.324 s …  4.467 s    10 runs
```
2025-01-27 15:25:56 +01:00
Denis Bilenko b7dd70b8b3
acc: Add a couple of error tests for 'bundle init' (#2233)
This captures how we log errors related to subprocess run and what does
the output look like.
2025-01-27 12:22:40 +00:00
Denis Bilenko 468660dc45
Add an acc test covering failures when reading .git (#2223)
## Changes
- New test covering failures in reading .git. One case results in error,
some result in warning (not shown).
- New helper withdir runs commands in a subdirectory.

## Tests
New acceptance test.
2025-01-24 15:53:06 +00:00
Denis Bilenko d6d9b994d4
acc: only print non-zero exit codes in errcode function (#2222)
Reduce noise in the output and matches how "Exit code" is handled for
the whole script.
2025-01-24 10:47:12 +01:00
Ilya Kuznetsov 0487e816cc
Reading variables from file (#2171)
## Changes

New source of default values for variables - variable file
`.databricks/bundle/<target>/variable-overrides.json`

CLI tries to stat and read that file every time during variable
initialisation phase

<!-- Summary of your changes that are easy to understand -->

## Tests

Acceptance tests
2025-01-23 14:35:33 +00:00
Andrew Nester 8af9efaa62
Show an error when non-yaml files used in include section (#2201)
## Changes
`include` section is used only to include other bundle configuration
YAML files. If any other file type is used, raise an error and guide
users to use `sync.include` instead

## Tests
Added acceptance test

---------

Co-authored-by: Julia Crawford (Databricks) <julia.crawford@databricks.com>
2025-01-23 13:58:18 +00:00
Denis Bilenko ba3a400327
Remove test-specific logic from generic test runner (#2215)
Revert changes to acceptance_test.go added in #2177 and add
test-specific fix.
2025-01-23 11:59:01 +01:00
Denis Bilenko e9902036b8
Set WorktreeRoot to sync root outside git repo (#2197)
## Changes
If git is not detected, set default worktree root to sync root.
Otherwise NewFileSet/View raise an error about worktree root being
outside view root in acceptance/bundle/sync-paths-dotdot.

This behavior is introduced in
https://github.com/databricks/cli/pull/1945

Stacked on https://github.com/databricks/cli/pull/2202

## Tests
Existing tests.
2025-01-22 10:50:13 +00:00
Denis Bilenko fde30ff1ab
Add a test for sync root outside of git root (#2202)
- Move acceptance/bundle/sync-paths-dotdot test to
acceptance/bundle/syncroot/dotdot-notgit
- Add new test acceptance/bundle/syncroot/dotdot-git

Fix replacer to work with this test and on Windows:
- Make PATH work on Windows by using EvalSymlinks.
- Make concatenated path match within JSON but stripping quotes.
2025-01-22 10:17:45 +00:00
Denis Bilenko de5155ed0a
Add acceptance for test for sync.paths equal to two dots (#2196)
Based on integration test from @andrewnester in #2194

Manually checked that this databricks.yml passes validation on v0.235.0
but fails on v0.236.0, very like it was broken in
https://github.com/databricks/cli/pull/1945

This also adds replacements for tmpdir, it's parent and (just in case)
grand parent.
2025-01-21 11:50:28 +00:00
Denis Bilenko 33613b5d2a
Add test for #2181 /Workspace not prepended (#2188) 2025-01-21 11:27:02 +00:00
Denis Bilenko ee4a4b4c24
Migrate quality_monitor_test.go to acceptance test (#2192) 2025-01-20 16:33:03 +00:00
Gleb Kanterov 31c10c1b82
Add experimental-jobs-as-code template (#2177)
## Changes

Add experimental-jobs-as-code template allowing defining jobs using
Python instead of YAML through the `databricks-bundles` PyPI package.

## Tests

Manually and acceptance tests.
2025-01-20 10:15:11 +00:00
Pieter Noordhuis 50f62692ce
Include a materialized copy of built-in templates (#2146)
## Changes

Include a materialized copy of built-in templates as reference output.

This updates the output comparison logic to work against an output
directory. The `doComparison` function now always works on real files.
It can now tell apart non-existing files and empty files (e.g., the
`.gitkeep` files in templates).
2025-01-17 15:03:59 +00:00
Pieter Noordhuis 0d5193a62c
Include help output for bundle commands in acceptance tests (#2178)
## Changes

This includes a change to the defaults for the output directory flags of
the "generate" commands. These defaults included the expanded working
directory. This can be omitted because it is implied.
2025-01-17 14:52:53 +00:00
Denis Bilenko 560c3d352e
Add test for passing --var twice for the same arg (#2176)
This shows that passing two --var for the same arg is rejected
currently.
2025-01-17 13:40:19 +00:00
Pieter Noordhuis 89eb556318
Migrate path translation tests to acceptance tests (#2122)
## Changes

The assertions on the output made are now captured in the `output.*`
files. These don't capture intent like actual assertions do, but we
still have regular test coverage in the path translation tests under
`bundle/config/mutator`.

## Tests

Tests pass.
2025-01-17 10:22:49 +00:00
Denis Bilenko 2e70558dc1
Resolve variables in a loop (#2164)
## Changes
- Instead of doing 2 passes on variable resolution, do a loop until
there are no more updates (or we reach count 100).
- Stacked on top of #2163 which is a regression test for this:
acceptance/bundle/variables/complex-transitive-deep

## Tests
Existing tests, new regression tests.

These tests already passed before, added for completeness:
- acceptance/bundle/variables/cycle
- acceptance/bundle/variables/complex-cross-ref
2025-01-16 14:39:54 +00:00
Denis Bilenko bc1610f6e6
Add a test for complex variable resolution with 3 levels (#2163)
Follow up to #2157. That PR repeated variable resolution. This test
still does not resolve fully but would resolve with 3 passes. This is
slightly different from complex-transitive-deeper - this test does not
show any errors, the issue is purely not enough passes.
2025-01-16 12:14:00 +00:00
Denis Bilenko 30dec59781
Improve resolution of complex variables within complex variables (#2157)
## Changes
- Remove ResolveVariableReferencesInComplexVariables - it blocked
complex-within-complex for no good reason.
- Repeat regular resolution twice, it helps with a couple test cases we
have.

There may be a case for running it 3 times or more in a loop, but there
is no test case for that, so this PR is simple incremental improvement.

## Tests
Existing acceptance tests. Previously all unit tests for complex
variables were converted to acceptance tests, to capture this change and
ensure nothing breaks.
2025-01-15 18:03:43 +01:00
Denis Bilenko 39b03592d7
Migrate TestResolveComplexVariableWithVarReference (#2156)
This is the last test referencing
ResolveVariableReferencesInComplexVariables, allowing removal of that
mutator.
2025-01-15 17:52:17 +01:00
Denis Bilenko d53a78e926
Introduce $DATABRICKS_URL replacement in tests (#2158)
## Changes
It covers both https://$DATABRICKS_HOST and http://$DATABRICKS_HOST so
the test output does not change between local and the cloud.

## Tests
Existing tests using golden files (acceptance and integration) catch
this and were updated.
2025-01-15 17:24:12 +01:00
Denis Bilenko 581565a1c4
Migrate more variable tests to acceptance (#2154) 2025-01-15 15:59:42 +01:00
Denis Bilenko b76eee0e8c
Migrate resolution tests to acceptance tests (#2143) 2025-01-15 11:22:23 +01:00
Denis Bilenko 55494a0bda
Add test about using variable in bundle.git.branch (#2118)
This test checks load git details functionality + variable interpolation
there.

The variables are not working there because LoadGitDetails mutator is
running before variable interpolation.

Additionally, correctly replace tmp path that is used for DATABRICKS_TF_EXEC_PATH
2025-01-15 10:34:51 +01:00