Skip to content
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

{CI} Fix top N slowest Test #21880

Merged
merged 5 commits into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import time

from datetime import datetime
from time import sleep
from dateutil.tz import tzutc # pylint: disable=import-error
from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from msrestazure.azure_exceptions import CloudError
Expand Down Expand Up @@ -234,7 +233,7 @@ def _test_server_mgmt(self, database_engine, resource_group_1, resource_group_2)
date_format = '%Y-%m-%dT%H:%M:%S.%f+00:00'

if current_time < earliest_restore_time:
sleep((datetime.strptime(earliest_restore_time, date_format) - datetime.strptime(current_time,
time.sleep((datetime.strptime(earliest_restore_time, date_format) - datetime.strptime(current_time,
date_format)).total_seconds())

self.cmd('{} server restore -g {} --name {} '
Expand Down Expand Up @@ -1026,7 +1025,7 @@ def _test_replica_mgmt(self, resource_group, skuName, testSkuName, isBasicTier):
# restart server
self.cmd('{} server restart -g {} --name {}'
.format(database_engine, resource_group, server), checks=NoneCheck())
sleep(120)
time.sleep(120)

# test replica create
self.cmd('{} server replica create -g {} -n {} -l westus --sku-name {} '
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,8 @@ def test_resource_policy_subscription_id(self, resource_group):
def test_show_built_in_policy(self):
# get the list of builtins, then retrieve each via show and validate the results match
results = self.cmd('policy definition list --query "[?policyType==\'BuiltIn\']"').get_output_in_json()
for i, result in enumerate(results):
if results:
result = results[0]
self.kwargs['pn'] = result['name']
self.kwargs['dn'] = result['displayName']
self.kwargs['desc'] = result['description']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3096,7 +3096,8 @@ def test_resource_policyset_grouping(self, resource_group):
def test_show_built_in_policy(self):
# get the list of builtins, then retrieve each via show and validate the results match
results = self.cmd('policy definition list --query "[?policyType==\'BuiltIn\']"').get_output_in_json()
for i, result in enumerate(results):
if results:
result = results[0]
self.kwargs['pn'] = result['name']
self.kwargs['dn'] = result['displayName']
self.kwargs['desc'] = result['description']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ def _create_db_wait_for_first_backup(test, resource_group, server, database_name
# Wait until earliestRestoreDate is in the past. When run live, this will take at least
# 10 minutes. Unforunately there's no way to speed this up
while db['earliestRestoreDate'] is None:
sleep(60)
time.sleep(60)
Copy link
Member

Choose a reason for hiding this comment

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

from time import sleep can now be removed.

Copy link
Member Author

Choose a reason for hiding this comment

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

We need modify these codes before remove from time import sleep.
I think add if self.is_live condition is also acceptable.


if self.is_live:
self.assertTrue(datetime.now() < start_time + timeout, 'Deleted db not found before timeout expired.')
sleep(10) # seconds






Copy link
Member

Choose a reason for hiding this comment

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

Let's only remove from time import sleep when it is not used.

db = test.cmd('sql db show -g {} -s {} -n {}'
.format(resource_group, server, database_name)).get_output_in_json()

Expand All @@ -1336,7 +1336,7 @@ def _create_db_wait_for_first_backup(test, resource_group, server, database_name
print('Waiting until earliest restore date', earliest_restore_date)

while datetime.utcnow() <= earliest_restore_date:
sleep(10) # seconds
time.sleep(10)

return db

Expand Down Expand Up @@ -3410,7 +3410,7 @@ def test_sql_tde(self, resource_group, server):
self.cmd('sql db tde set -g {} -s {} -d {} --status Disabled'
.format(resource_group, sn, db_name))

sleep(5)
time.sleep(5)

self.cmd('sql db tde show -g {} -s {} -d {}'
.format(resource_group, sn, db_name),
Expand All @@ -3420,7 +3420,7 @@ def test_sql_tde(self, resource_group, server):
self.cmd('sql db tde set -g {} -s {} -d {} --status Enabled'
.format(resource_group, sn, db_name))

sleep(5)
time.sleep(5)

# validate encryption is enabled
self.cmd('sql db tde show -g {} -s {} -d {}'
Expand Down Expand Up @@ -5939,7 +5939,7 @@ def test_sql_ledger(self, resource_group, server):
self.cmd('sql db ledger-digest-uploads enable -g {} -s {} --name {} --endpoint {}'
.format(resource_group, server, db_name, endpoint))

sleep(2)
time.sleep(2)

# validate setting through show command
self.cmd('sql db ledger-digest-uploads show -g {} -s {} --name {}'
Expand All @@ -5951,7 +5951,7 @@ def test_sql_ledger(self, resource_group, server):
self.cmd('sql db ledger-digest-uploads disable -g {} -s {} --name {}'
.format(resource_group, server, db_name))

sleep(2)
time.sleep(2)

# validate setting through show command
self.cmd('sql db ledger-digest-uploads show -g {} -s {} --name {}'
Expand Down