Skip to content

Commit 0047b13

Browse files
authored
Fix issue for skip tests with split timeout (#41520)
1 parent b78d310 commit 0047b13

File tree

2 files changed

+11
-9
lines changed

2 files changed

+11
-9
lines changed

sdk/cosmos/azure-cosmos/tests/test_config.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
except:
2727
print("no urllib3")
2828

29+
SPLIT_TIMEOUT = 60*25 # timeout test at 25 minutes
30+
SLEEP_TIME = 60 # sleep for 1 minutes
2931

3032
class TestConfig(object):
3133
local_host = 'https://localhost:8081/'
@@ -204,19 +206,19 @@ async def _validate_offset_limit(cls, created_collection, query, results):
204206
def trigger_split(container, throughput):
205207
print("Triggering a split in session token helpers")
206208
container.replace_throughput(throughput)
207-
print("changed offer to 11k")
209+
print(f"changed offer to {throughput}")
208210
print("--------------------------------")
209211
print("Waiting for split to complete")
210212
start_time = time.time()
211213

212214
while True:
213215
offer = container.get_throughput()
214216
if offer.properties['content'].get('isOfferReplacePending', False):
215-
if time.time() - start_time > 60 * 25: # timeout test at 25 minutes
216-
unittest.skip("Partition split didn't complete in time.")
217+
if time.time() - start_time > SPLIT_TIMEOUT: # timeout test at 25 minutes
218+
raise unittest.SkipTest("Partition split didn't complete in time")
217219
else:
218220
print("Waiting for split to complete")
219-
time.sleep(60)
221+
time.sleep(SLEEP_TIME)
220222
else:
221223
break
222224
print("Split in session token helpers has completed")
@@ -225,19 +227,19 @@ def trigger_split(container, throughput):
225227
async def trigger_split_async(container, throughput):
226228
print("Triggering a split in session token helpers")
227229
await container.replace_throughput(throughput)
228-
print("changed offer to 11k")
230+
print(f"changed offer to {throughput}")
229231
print("--------------------------------")
230232
print("Waiting for split to complete")
231233
start_time = time.time()
232234

233235
while True:
234236
offer = await container.get_throughput()
235237
if offer.properties['content'].get('isOfferReplacePending', False):
236-
if time.time() - start_time > 60 * 25: # timeout test at 25 minutes
237-
unittest.skip("Partition split didn't complete in time.")
238+
if time.time() - start_time > SPLIT_TIMEOUT: # timeout test at 25 minutes
239+
raise unittest.SkipTest("Partition split didn't complete in time")
238240
else:
239241
print("Waiting for split to complete")
240-
time.sleep(60)
242+
time.sleep(SLEEP_TIME)
241243
else:
242244
break
243245
print("Split in session token helpers has completed")

sdk/cosmos/azure-cosmos/tests/test_partition_split_query.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def test_partition_split_query(self):
8888
offer = self.database.get_throughput()
8989
while True:
9090
if time.time() - start_time > 60 * 25: # timeout test at 25 minutes
91-
unittest.skip("Partition split didn't complete in time.")
91+
raise unittest.SkipTest("Partition split didn't complete in time")
9292
if offer.properties['content'].get('isOfferReplacePending', False):
9393
time.sleep(10)
9494
offer = self.database.get_throughput()

0 commit comments

Comments
 (0)