Skip to content

Commit 2d15caa

Browse files
authored
cosmos: add a few extra contributing nodes for Cosmos itself
1 parent a83f397 commit 2d15caa

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Contributing to the Azure Cosmos DB SDK for Rust.
2+
3+
First, review the Azure Core SDK Contributing guide: [CONTRIBUTING.md](../../CONTRIBUTING.md).
4+
5+
## Running Integration Tests
6+
7+
Our integration tests are designed to run against either the Cosmos DB Emulator, or an actual Azure Cosmos DB account.
8+
They use the [Azure SDK Test Proxy](https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md) to record and playback HTTP interactions.
9+
10+
**By default** when you run the integration tests, they work against recorded HTTP interactions (playback mode).
11+
This means that if you're adding a new test, it will likely fail with this error:
12+
13+
```
14+
Error: Error { context: SimpleMessage(DataConversion, "header not found x-recording-id") }
15+
```
16+
17+
This indicates that the test proxy failed to find a recorded interaction for the test you are trying to run.
18+
19+
### `AZURE_TEST_MODE` Environment Variable
20+
21+
The test proxy behavior is controlled by the `AZURE_TEST_MODE` environment variable.
22+
It can have one of three values:
23+
24+
* `playback` (this is the default if the variable is empty or unset): The test proxy will only use recorded HTTP interactions.
25+
* `record`: The test proxy will forward HTTP requests to the actual service and record the interactions for future playback.
26+
* `live`: The test proxy will forward HTTP requests to the actual service, but will not record the interactions.
27+
28+
When adding a new test, you should set `AZURE_TEST_MODE=record` to have the test proxy record the HTTP interactions.
29+
The HTTP recordings will be saved to the `.assets/WL6WTRCUBG` folder (this folder name is used by all tests in `sdk/cosmos`).
30+
You can review the JSON recordings to ensure they look correct.
31+
32+
### Specifying the Cosmos DB Endpoint
33+
34+
When running tests in `record` or `live` mode, the test proxy needs to know which Cosmos DB account to use.
35+
You can specify this using the `AZURE_COSMOS_CONNECTION_STRING` environment variable.
36+
This can contain a valid Cosmos DB connection string, **or** the special string `emulator` to use the Cosmos DB Emulator.
37+
The `emulator` marker is highly recommended when running against a local emulator because it ALSO automatically disables TLS certificate validation, which is often necessary when testing against the local emulator.
38+
39+
If you need to disable TLS certificate validation when using a different connections
40+
41+
### Saving Recordings
42+
43+
Before opening a PR, if you've added any integration tests, or changed the HTTP interactions of existing tests, you must save the recordings.
44+
The recordings are saved in the https://github.com/Azure/azure-sdk-assets repository.
45+
Whenever you "push" new recordings, a new commit is made to that repository and given a unique Git tag (for example [`azure_data_cosmos_69ad1e4995`](https://github.com/Azure/azure-sdk-assets/commit/69ad1e49952a7dd831d80e19eebbbee3454f404a)).
46+
Then, the `sdk/cosmos/assets.json` file is updated to specify the name of that Git tag.
47+
The Test Proxy uses this tag to find the correct recordings when running tests in playback mode.
48+
The CI pipeline runs tests in playback mode, so it's important that the `assets.json` file is updated correctly before submitting a PR.
49+
50+
Setting `AZURE_TEST_MODE=record` and running the tests will update your LOCAL copy of the recordings, in `.assets`, but will not publish them to the `azure-sdk-assets` repository, or update the `assets.json` file.
51+
To do that, install the [Azure SDK Test Proxy](https://github.com/Azure/azure-sdk-tools/blob/main/tools/test-proxy/Azure.Sdk.Tools.TestProxy/README.md#installation) tools, then run the following command from the repo root:
52+
53+
```bash
54+
test-proxy push --assets-json-path ./sdk/cosmos/assets.json
55+
```
56+
57+
This will publish the recordings to the `azure-sdk-assets` repository, and update the `assets.json` file accordingly.
58+
It's fine to run this command multiple times if you realize the recordings need to be updated again before submitting your PR, or while reviewing feedback from code reviewers.
59+
Each time the command is run, the `assets.json` file will be updated to point to the latest Git tag in the `azure-sdk-assets` repository.
60+
Make sure you commit this change to your PR branch, so that the test proxy can find the correct recordings when running tests in playback mode.

0 commit comments

Comments
 (0)