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 tests for default-python template on different Python versions #2025

Merged
merged 20 commits into from
Dec 20, 2024

Conversation

denik
Copy link
Contributor

@denik denik commented Dec 17, 2024

Changes

Add new type of test helpers that run the command and compare full output (golden files approach).

In case of JSON, there is also an option to ignore certain paths.

Add test for different versions of Python to go through bundle init default-python / validate / deploy / summary.

Tests

New integration tests.

go.mod Outdated Show resolved Hide resolved
@denik denik force-pushed the DECO-24194--denik--python-tests branch from 930057b to 1f8896c Compare December 18, 2024 13:09
@denik denik temporarily deployed to test-trigger-is December 18, 2024 13:09 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 13:09 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 13:44 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 13:44 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 14:22 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 14:22 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 15:00 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 15:00 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 15:20 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 15:20 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 15:33 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 15:33 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 16:12 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 16:13 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 17:13 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 18, 2024 17:13 — with GitHub Actions Inactive
@denik denik force-pushed the DECO-24194--denik--python-tests branch from abcf45d to 418564a Compare December 20, 2024 13:44
@denik denik temporarily deployed to test-trigger-is December 20, 2024 13:44 — with GitHub Actions Inactive
@denik denik temporarily deployed to test-trigger-is December 20, 2024 13:44 — with GitHub Actions Inactive
@denik denik enabled auto-merge December 20, 2024 13:48
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.

Few remaining questions/suggestions.

internal/testutil/env.go Show resolved Hide resolved
}

func AssertEqualTexts(t testutil.TestingT, filename1, filename2, expected, out string) {
if len(out) < 1000 && len(expected) < 1000 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Constants (used in multiple spots) can be a top level const, e.g. textDiffCharacterThreshold or smth.

}

// compare strings and ignore forward vs backward slashes
func almostSameStrings(v1, v2 any) bool {
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is this needed? Didn't see it before.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

b972bcd

This is to fix slashes on windows. See below "whl" for example. https://github.com/databricks-eng/eng-dev-ecosystem/actions/runs/12432516778/job/34712095471

   testdiff.go:49: Allowed differences between C:\a\eng-dev-ecosystem\eng-dev-ecosystem\ext\cli\integration\bundle\testdata\default_python\bundle_summary.txt and Output from [bundle summary --output json]:
          ==> replace /bundle/terraform/exec_path C:\Users\RUNNER~1\AppData\Local\Temp\TestDefaultPython3.<NUMID>\<NUMID>\project_name_$UNIQUE_PRJ\.databricks\bundle\dev\bin\terraform.exe old=/tmp/.../terraform
          ==> replace /include/0 resources\project_name_$UNIQUE_PRJ.job.yml old=resources/project_name_$UNIQUE_PRJ.job.yml
          ==> replace /include/1 resources\project_name_$UNIQUE_PRJ.pipeline.yml old=resources/project_name_$UNIQUE_PRJ.pipeline.yml
          ==>  remove /resources/jobs/project_name_$UNIQUE_PRJ_job/email_notifications <nil> old=map[on_failure:[$USERNAME]]
          ==> replace /resources/jobs/project_name_$UNIQUE_PRJ_job/job_clusters/0/new_cluster/node_type_id Standard_D3_v2 old=i3.xlarge
          ==> replace /resources/jobs/project_name_$UNIQUE_PRJ_job/tasks/2/libraries/0/whl dist\*.whl old=dist/*.whl
          ==> replace /resources/jobs/project_name_$UNIQUE_PRJ_job/url https://$DATABRICKS_HOST/jobs/<NUMID> old=https://$DATABRICKS_HOST/jobs/<NUMID>?o=<NUMID>
          ==>  remove /resources/pipelines/project_name_$UNIQUE_PRJ_pipeline/catalog <nil> old=main
          ==> replace /resources/pipelines/project_name_$UNIQUE_PRJ_pipeline/url https://$DATABRICKS_HOST/pipelines/<UUID> old=https://$DATABRICKS_HOST/pipelines/<UUID>?o=<NUMID>
          ==>     add /workspace/current_user/externalId <UUID> old=<nil>
          ==> replace /workspace/current_user/groups/0/display admins old=team.engineering
          ==>  remove /workspace/current_user/name/familyName <nil> old=$USERNAME

@denik denik added this pull request to the merge queue Dec 20, 2024
@pietern pietern removed this pull request from the merge queue due to a manual request Dec 20, 2024
@denik denik temporarily deployed to test-trigger-is December 20, 2024 14:19 — with GitHub Actions Inactive
Copy link

If integration tests don't run automatically, an authorized user can run them manually by following the instructions below:

Trigger:
go/deco-tests-run/cli

Inputs:

  • PR number: 2025
  • Commit SHA: 74345897c2b043417cdce3fbc2a2b876c83a82d6

Checks will be approved automatically on success.

@denik denik temporarily deployed to test-trigger-is December 20, 2024 14:19 — with GitHub Actions Inactive
@denik denik enabled auto-merge December 20, 2024 14:22
@denik denik added this pull request to the merge queue Dec 20, 2024
Merged via the queue into main with commit e095249 Dec 20, 2024
9 checks passed
@denik denik deleted the DECO-24194--denik--python-tests branch December 20, 2024 14: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