Skip to content

Add support for recording requests in integration acceptance tests #2720

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

Open
wants to merge 37 commits into
base: main
Choose a base branch
from

Conversation

shreyas-goenka
Copy link
Contributor

@shreyas-goenka shreyas-goenka commented Apr 14, 2025

Changes

This PR adds support for recording API calls made during an integration acceptance test by setting RecordRequests = true in the test.toml file.

In order to do so, this PR introduces a newServer interface to decouple the logic recording the API requests/responses from the server implementation itself.

The original test server struct is renamed to LocalServer.

This PR adds a new struct ProxyServer which is a server that sits in between a client and a real Databricks workspace. Having a server in between allows us to record requests as they are sent to a real Databricks workspace in our integration tests.

Why

Other than being a useful feature in itself, this also unlocks migration away from Terraform in DABs since we can now record the API requests made by Terraform and ensure that our custom library makes the same API requests in all cases.

Tests

A bunch of new acceptance tests for the new feature.

@shreyas-goenka shreyas-goenka changed the base branch from main to refactor-server April 14, 2025 22:30
Base automatically changed from refactor-server to main April 21, 2025 19:51
# In unix: "raw_body": "hello, world\n"
# In windows: "raw_body": "hello, world\r\n"
# In order to prevent that difference, hello.txt does not have a trailing newline.
acceptance/selftest/record_cloud/volume-io/hello.txt
Copy link
Contributor Author

@shreyas-goenka shreyas-goenka Apr 25, 2025

Choose a reason for hiding this comment

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

I tried out [[Repls]], but they did not seem to work. I could not reproduce this locally on Windows, and it only seems to happen in the Windows CI runner.

I've already spent 1-2 hours trying to fix / patch this, so the easiest thing to do at this point is to ignore the lint rule.
I'm not sure we want to normalize in the raw_body since it is a part of the HTTP payload.

workspaceClient := internal.PrepareServerAndClient(t, config, LogRequests, tmpDir)

// Configure resolved credentials in the environment.
cmd.Env = append(cmd.Env, "DATABRICKS_HOST="+workspaceClient.Config.Host)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

no longer necessary since we use auth.ProcessEnv

@shreyas-goenka shreyas-goenka changed the title [WIP] Record requests in integration tests" Add support for recording requests in integration acceptance tests Apr 25, 2025
@shreyas-goenka shreyas-goenka marked this pull request as ready for review April 25, 2025 15:01
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.

1 participant