|
1 | 1 | # The MIT License (MIT)
|
2 | 2 | # Copyright (c) Microsoft Corporation. All rights reserved.
|
3 | 3 | import os
|
4 |
| -import sys |
5 | 4 |
|
6 | 5 | from azure.cosmos import PartitionKey, ThroughputProperties
|
7 |
| -from workload_utils import create_logger |
| 6 | +from workload_utils import create_logger, create_random_item |
8 | 7 | from workload_configs import COSMOS_URI, COSMOS_KEY, PREFERRED_LOCATIONS, COSMOS_CONTAINER, COSMOS_DATABASE, \
|
9 | 8 | NUMBER_OF_LOGICAL_PARTITIONS, PARTITION_KEY, THROUGHPUT
|
10 | 9 |
|
11 |
| -sys.path.append(r"./") |
12 |
| - |
13 | 10 | from azure.cosmos.aio import CosmosClient as AsyncClient
|
14 | 11 | import asyncio
|
15 | 12 |
|
|
18 | 15 | async def write_item_concurrently_initial(container, num_upserts):
|
19 | 16 | tasks = []
|
20 | 17 | for i in range(num_upserts):
|
21 |
| - tasks.append(container.upsert_item({"id": "test-" + str(i), "pk": "pk-" + str(i)})) |
| 18 | + item = create_random_item() |
| 19 | + item["id"] = "test-" + str(i) |
| 20 | + item["pk"] = "pk-" + str(i) |
| 21 | + tasks.append(container.upsert_item(item)) |
22 | 22 | await asyncio.gather(*tasks)
|
23 | 23 |
|
24 | 24 |
|
25 | 25 | async def run_workload(client_id: str):
|
| 26 | + # Key always needs to be used for the initial setup to create the database and container as aad for control plane |
| 27 | + # operations using the dataplane sdk is not supported. |
26 | 28 | async with AsyncClient(COSMOS_URI, COSMOS_KEY, preferred_locations=PREFERRED_LOCATIONS,
|
27 | 29 | enable_diagnostics_logging=True, logger=logger,
|
28 | 30 | user_agent=str(client_id) + "-" + datetime.now().strftime("%Y%m%d-%H%M%S")) as client:
|
|
0 commit comments