Skip to content

Commit f4d65f0

Browse files
authored
Update Cosmos tests to be record/replay tests (Azure#2334)
* set up cosmos tests to be record/replay * update assets.json * clean up unnecessary changes to unique_db * pr feedback and spelling fix * restore dotnet and test-proxy install * clean up unused import
1 parent 1db222e commit f4d65f0

File tree

9 files changed

+104
-80
lines changed

9 files changed

+104
-80
lines changed

.devcontainer/devcontainer.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,20 @@
1010
"ghcr.io/devcontainers/features/azure-cli:1": {},
1111
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
1212
"ghcr.io/devcontainers/features/github-cli:1": {},
13-
"ghcr.io/devcontainers/features/sshd:1": {}
13+
"ghcr.io/devcontainers/features/sshd:1": {},
14+
"ghcr.io/devcontainers/features/dotnet:2": {},
15+
"ghcr.io/devcontainers/features/powershell:1": {}
1416
},
1517
"customizations": {
18+
"codespaces": {
19+
"repositories": {
20+
"Azure/azure-sdk-assets": {
21+
"permissions": {
22+
"contents": "write"
23+
}
24+
}
25+
}
26+
},
1627
"vscode": {
1728
"extensions": [
1829
"tamasfe.even-better-toml",
@@ -23,4 +34,4 @@
2334
]
2435
}
2536
}
26-
}
37+
}

.devcontainer/oncreate

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,7 @@ set -euo pipefail
55
echo "Running Azure SDK for Rust devcontainer post create script..."
66

77
echo "Updating toolchains..."
8-
rustup show
8+
rustup install
9+
10+
echo "Installing test-proxy..."
11+
dotnet tool update azure.sdk.tools.testproxy --global --prerelease --add-source https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-net/nuget/v3/index.json --ignore-failed-sources

.vscode/cspell.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,4 +194,4 @@
194194
]
195195
}
196196
]
197-
}
197+
}

sdk/cosmos/assets.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"AssetsRepo": "Azure/azure-sdk-assets",
3+
"AssetsRepoPrefixPath": "rust",
4+
"Tag": "rust/azure_data_cosmos_43a7f435b6",
5+
"TagPrefix": "rust/azure_data_cosmos"
6+
}

sdk/cosmos/azure_data_cosmos/tests/cosmos_containers.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,11 @@ use azure_data_cosmos::{
1616
use framework::TestAccount;
1717
use futures::StreamExt;
1818

19-
#[recorded::test(live)]
19+
#[recorded::test]
2020
pub async fn container_crud(context: TestContext) -> Result<(), Box<dyn Error>> {
2121
use azure_data_cosmos::models::PartitionKeyKind;
2222

23-
let account = TestAccount::from_env(context, None)?;
23+
let account = TestAccount::from_env(context, None).await?;
2424
let cosmos_client = account.connect_with_key(None)?;
2525
let test_db_id = account.unique_db("DatabaseCRUD");
2626
cosmos_client.create_database(&test_db_id, None).await?;
@@ -159,9 +159,9 @@ pub async fn container_crud(context: TestContext) -> Result<(), Box<dyn Error>>
159159
Ok(())
160160
}
161161

162-
#[recorded::test(live)]
162+
#[recorded::test]
163163
pub async fn container_crud_autoscale(context: TestContext) -> Result<(), Box<dyn Error>> {
164-
let account = TestAccount::from_env(context, None)?;
164+
let account = TestAccount::from_env(context, None).await?;
165165
let cosmos_client = account.connect_with_key(None)?;
166166
let test_db_id = account.unique_db("DatabaseCRUD");
167167
cosmos_client.create_database(&test_db_id, None).await?;
@@ -212,9 +212,9 @@ pub async fn container_crud_autoscale(context: TestContext) -> Result<(), Box<dy
212212
Ok(())
213213
}
214214

215-
#[recorded::test(live)]
215+
#[recorded::test]
216216
pub async fn container_crud_hierarchical_pk(context: TestContext) -> Result<(), Box<dyn Error>> {
217-
let account = TestAccount::from_env(context, None)?;
217+
let account = TestAccount::from_env(context, None).await?;
218218
let cosmos_client = account.connect_with_key(None)?;
219219
let test_db_id = account.unique_db("DatabaseCRUD");
220220
cosmos_client.create_database(&test_db_id, None).await?;

sdk/cosmos/azure_data_cosmos/tests/cosmos_databases.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ use azure_data_cosmos::{models::ThroughputProperties, CreateDatabaseOptions, Que
99
use framework::TestAccount;
1010
use futures::StreamExt;
1111

12-
#[recorded::test(live)]
12+
#[recorded::test]
1313
pub async fn database_crud(context: TestContext) -> Result<(), Box<dyn Error>> {
14-
let account = TestAccount::from_env(context, None)?;
14+
let account = TestAccount::from_env(context, None).await?;
1515
let cosmos_client = account.connect_with_key(None)?;
1616

1717
let test_db_id = account.unique_db("DatabaseCRUD");
@@ -62,10 +62,10 @@ pub async fn database_crud(context: TestContext) -> Result<(), Box<dyn Error>> {
6262
Ok(())
6363
}
6464

65-
#[recorded::test(live)]
65+
#[recorded::test]
6666
#[cfg(feature = "key_auth")]
6767
pub async fn database_with_offer_crud(context: TestContext) -> Result<(), Box<dyn Error>> {
68-
let account = TestAccount::from_env(context, None)?;
68+
let account = TestAccount::from_env(context, None).await?;
6969
let cosmos_client = account.connect_with_key(None)?;
7070

7171
let test_db_id = account.unique_db("DatabaseWithOfferCRUD");

sdk/cosmos/azure_data_cosmos/tests/cosmos_items.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ async fn create_container(
5050
Ok(container_client)
5151
}
5252

53-
#[recorded::test(live)]
53+
#[recorded::test]
5454
pub async fn item_create_read_replace_delete(context: TestContext) -> Result<(), Box<dyn Error>> {
55-
let account = TestAccount::from_env(context, None)?;
55+
let account = TestAccount::from_env(context, None).await?;
5656
let cosmos_client = account.connect_with_key(None)?;
5757
let container_client = create_container(&account, &cosmos_client).await?;
5858

@@ -131,13 +131,13 @@ pub async fn item_create_read_replace_delete(context: TestContext) -> Result<(),
131131
Ok(())
132132
}
133133

134-
#[recorded::test(live)]
134+
#[recorded::test]
135135
pub async fn item_create_content_response_on_write(
136136
context: TestContext,
137137
) -> Result<(), Box<dyn Error>> {
138138
use azure_data_cosmos::ItemOptions;
139139

140-
let account = TestAccount::from_env(context, None)?;
140+
let account = TestAccount::from_env(context, None).await?;
141141
let cosmos_client = account.connect_with_key(None)?;
142142
let container_client = create_container(&account, &cosmos_client).await?;
143143

@@ -170,9 +170,9 @@ pub async fn item_create_content_response_on_write(
170170
Ok(())
171171
}
172172

173-
#[recorded::test(live)]
173+
#[recorded::test]
174174
pub async fn item_read_system_properties(context: TestContext) -> Result<(), Box<dyn Error>> {
175-
let account = TestAccount::from_env(context, None)?;
175+
let account = TestAccount::from_env(context, None).await?;
176176
let cosmos_client = account.connect_with_key(None)?;
177177
let container_client = create_container(&account, &cosmos_client).await?;
178178

@@ -208,9 +208,9 @@ pub async fn item_read_system_properties(context: TestContext) -> Result<(), Box
208208
Ok(())
209209
}
210210

211-
#[recorded::test(live)]
211+
#[recorded::test]
212212
pub async fn item_upsert_new(context: TestContext) -> Result<(), Box<dyn Error>> {
213-
let account = TestAccount::from_env(context, None)?;
213+
let account = TestAccount::from_env(context, None).await?;
214214
let cosmos_client = account.connect_with_key(None)?;
215215
let container_client = create_container(&account, &cosmos_client).await?;
216216

@@ -238,9 +238,9 @@ pub async fn item_upsert_new(context: TestContext) -> Result<(), Box<dyn Error>>
238238
Ok(())
239239
}
240240

241-
#[recorded::test(live)]
241+
#[recorded::test]
242242
pub async fn item_upsert_existing(context: TestContext) -> Result<(), Box<dyn Error>> {
243-
let account = TestAccount::from_env(context, None)?;
243+
let account = TestAccount::from_env(context, None).await?;
244244
let cosmos_client = account.connect_with_key(None)?;
245245
let container_client = create_container(&account, &cosmos_client).await?;
246246

@@ -278,9 +278,9 @@ pub async fn item_upsert_existing(context: TestContext) -> Result<(), Box<dyn Er
278278
Ok(())
279279
}
280280

281-
#[recorded::test(live)]
281+
#[recorded::test]
282282
pub async fn item_patch(context: TestContext) -> Result<(), Box<dyn Error>> {
283-
let account = TestAccount::from_env(context, None)?;
283+
let account = TestAccount::from_env(context, None).await?;
284284
let cosmos_client = account.connect_with_key(None)?;
285285
let container_client = create_container(&account, &cosmos_client).await?;
286286

@@ -332,9 +332,9 @@ pub async fn item_patch(context: TestContext) -> Result<(), Box<dyn Error>> {
332332
Ok(())
333333
}
334334

335-
#[recorded::test(live)]
335+
#[recorded::test]
336336
pub async fn item_null_partition_key(context: TestContext) -> Result<(), Box<dyn Error>> {
337-
let account = TestAccount::from_env(context, None)?;
337+
let account = TestAccount::from_env(context, None).await?;
338338
let cosmos_client = account.connect_with_key(None)?;
339339
let container_client = create_container(&account, &cosmos_client).await?;
340340

sdk/cosmos/azure_data_cosmos/tests/cosmos_query.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ async fn create_container(
7171
Ok(container_client)
7272
}
7373

74-
#[recorded::test(live)]
74+
#[recorded::test]
7575
pub async fn single_partition_query(context: TestContext) -> Result<(), Box<dyn Error>> {
76-
let account = TestAccount::from_env(context, None)?;
76+
let account = TestAccount::from_env(context, None).await?;
7777
let cosmos_client = account.connect_with_key(None)?;
7878
let container_client = create_container(&account, &cosmos_client).await?;
7979

@@ -88,11 +88,11 @@ pub async fn single_partition_query(context: TestContext) -> Result<(), Box<dyn
8888
Ok(())
8989
}
9090

91-
#[recorded::test(live)]
91+
#[recorded::test]
9292
pub async fn single_partition_query_with_parameters(
9393
context: TestContext,
9494
) -> Result<(), Box<dyn Error>> {
95-
let account = TestAccount::from_env(context, None)?;
95+
let account = TestAccount::from_env(context, None).await?;
9696
let cosmos_client = account.connect_with_key(None)?;
9797
let container_client = create_container(&account, &cosmos_client).await?;
9898

@@ -109,11 +109,11 @@ pub async fn single_partition_query_with_parameters(
109109
Ok(())
110110
}
111111

112-
#[recorded::test(live)]
112+
#[recorded::test]
113113
pub async fn single_partition_query_with_projection(
114114
context: TestContext,
115115
) -> Result<(), Box<dyn Error>> {
116-
let account = TestAccount::from_env(context, None)?;
116+
let account = TestAccount::from_env(context, None).await?;
117117
let cosmos_client = account.connect_with_key(None)?;
118118
let container_client = create_container(&account, &cosmos_client).await?;
119119

0 commit comments

Comments
 (0)