Skip to content

Commit

Permalink
Fixed test test_devops_group_and_member_tests (#1183)
Browse files Browse the repository at this point in the history
* test_devops_group_and_member_tests

* sleep_in_live_run to 60

* Update test_devopsSecurityGroupTest.py

* Fixes

* org change

* Adding print command for logging

* Updated the recording after clearing the cache

* Recoreded after az logout

Co-authored-by: Roshan-sy <roshan-sy@github.com>
  • Loading branch information
roshan-sy and Roshan-sy authored Sep 2, 2021
1 parent 8cf32a4 commit 9e3e15d
Show file tree
Hide file tree
Showing 2 changed files with 4,446 additions and 2,365 deletions.
6,792 changes: 4,436 additions & 2,356 deletions tests/recordings/test_devops_group_and_member_tests.yaml

Large diffs are not rendered by default.

19 changes: 10 additions & 9 deletions tests/test_devopsSecurityGroupTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from azure_devtools.scenario_tests import AllowLargeResponse
from .utilities.helper import DevopsScenarioTest, disable_telemetry, set_authentication, get_test_org_from_env_variable

DEVOPS_CLI_TEST_ORGANIZATION = get_test_org_from_env_variable() or 'https://dev.azure.com/azuredevopsclitest'
DEVOPS_CLI_TEST_ORGANIZATION = get_test_org_from_env_variable() or 'https://dev.azure.com/devops-cli-test-org'
_TEST_EMAIL_ID = 'new_user_test@outlook.com'
_GROUP_DESCRIPTION = 'some description'

Expand All @@ -24,6 +24,7 @@ def test_devops_group_and_member_tests(self):
self.cmd('az devops configure --defaults organization=' + DEVOPS_CLI_TEST_ORGANIZATION + ' project=' + random_project_name)

try:
print(DEVOPS_CLI_TEST_ORGANIZATION)
create_project_command = 'az devops project create --name ' + random_project_name + ' --output json --detect false'
project_create_output = self.cmd(create_project_command).get_output_in_json()
created_project_id = project_create_output["id"]
Expand All @@ -49,7 +50,7 @@ def test_devops_group_and_member_tests(self):
assert create_project_group['displayName'] == project_group_name
project_group_descriptor = create_project_group['descriptor']

self.sleep_in_live_run(5)
self.sleep_in_live_run(100)

show_project_group = self.cmd('az devops security group show --id "'+ project_group_descriptor +'" -o json --detect false').get_output_in_json()
assert show_project_group['displayName'] == project_group_name
Expand All @@ -70,14 +71,14 @@ def test_devops_group_and_member_tests(self):
assert create_project_group['displayName'] == project_group_name2
project_group_descriptor2 = create_project_group['descriptor']

self.sleep_in_live_run(1)
self.sleep_in_live_run(100)
#create 3rd group and add it to multiple existing groups
project_group_name3 = 'project security ' + self.create_random_name(prefix='GroupName_',length=15)
create_project_group = self.cmd('az devops security group create --name "'+ project_group_name3 +'" --groups "'+ list_response[0]['descriptor'] + ',' + project_group_descriptor2 +'" -o json --detect false').get_output_in_json()
assert create_project_group['displayName'] == project_group_name3
project_group_descriptor3 = create_project_group['descriptor']

self.sleep_in_live_run(5)
self.sleep_in_live_run(100)
# validate list membership
list_valid_users_members = self.cmd('az devops security group membership list --id '+ valid_users_group_descriptor +' -o json --detect false').get_output_in_json()
new_valid_users_members_len = len(list_valid_users_members)
Expand All @@ -87,7 +88,7 @@ def test_devops_group_and_member_tests(self):
list_group_name3_members = self.cmd('az devops security group membership list --id '+ project_group_descriptor3 +' -o json --detect false').get_output_in_json()
assert len(list_group_name3_members) == 0

self.sleep_in_live_run(5) # Test is still flaky without this sleep only two memberships are reflected in time for the call.
self.sleep_in_live_run(100) # Test is still flaky without this sleep only two memberships are reflected in time for the call.
# member of
list_group_name3_memberof = self.cmd('az devops security group membership list --id '+ project_group_descriptor3 +' --relationship memberof -o json --detect false').get_output_in_json()
assert len(list_group_name3_memberof) == 3
Expand All @@ -98,7 +99,7 @@ def test_devops_group_and_member_tests(self):
# add user
add_membership = self.cmd('az devops security group membership add --group-id '+ project_group_descriptor +' --member-id '+ _TEST_EMAIL_ID +' -o json --detect false').get_output_in_json()

self.sleep_in_live_run(5)
self.sleep_in_live_run(100)
list_group_name3_memberof = self.cmd('az devops security group membership list --id '+ project_group_descriptor3 +' --relationship memberof -o json --detect false').get_output_in_json()
assert len(list_group_name3_memberof) == 4

Expand All @@ -108,7 +109,7 @@ def test_devops_group_and_member_tests(self):
# remove membership
remove_membership = self.cmd('az devops security group membership remove --group-id '+ project_group_descriptor +' --member-id '+ project_group_descriptor3 +' -y -o json --detect false')

self.sleep_in_live_run(5)
self.sleep_in_live_run(100)
list_group_name3_memberof = self.cmd('az devops security group membership list --id '+ project_group_descriptor3 +' --relationship memberof -o json --detect false').get_output_in_json()
assert len(list_group_name3_memberof) == 3

Expand All @@ -119,10 +120,10 @@ def test_devops_group_and_member_tests(self):
assert project_group_descriptor3 == update_project_group['descriptor']

#delete
self.sleep_in_live_run(1)
self.sleep_in_live_run(100)
delete_project_group = self.cmd('az devops security group delete --id "'+ project_group_descriptor3 +'" -y -o json --detect false')

self.sleep_in_live_run(1)
self.sleep_in_live_run(100)
# validate list
list_valid_users_members = list_project_groups = self.cmd('az devops security group membership list --id '+ valid_users_group_descriptor +' -o json --detect false').get_output_in_json()
new_valid_users_members_len = len(list_valid_users_members)
Expand Down

0 comments on commit 9e3e15d

Please sign in to comment.