-
Notifications
You must be signed in to change notification settings - Fork 81
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
CICD Integration tests: s3 dataset shares, persistent shares #1580
Changes from 103 commits
b188538
45d1407
cd27097
d04b525
5e5507e
fa69dde
3e19596
c05de67
8f2a918
9b2c711
d30c121
2bad8bd
6214964
3972e05
2dcd60f
c261da7
1e9732b
cf8553c
5ea8b6b
520a34e
0cf4ea7
972c883
7b1c942
d9042dc
928c3aa
a996273
023fbc4
b633938
74cb6fe
c05df65
50e1a60
7897028
45f5078
43cde66
2330021
a857d0a
6abe590
5968fd3
e4e9c12
052bc7e
e739a25
9ad774e
146c45e
0907ea3
7f68d3b
98c7667
92f23e3
3907001
3553d12
9be25bb
1709bb5
6889c47
aba8536
3d67e2e
4fd56af
56b12c5
ade89e8
72259c4
3b74b03
b31d666
c220135
196fb6e
d3bb8be
fbbccb7
ec38ec0
ccb6887
01c65c8
5358677
590909b
adc48a3
2c8724c
1e3a2af
c6cfd11
b32b269
3907faa
b2f78a0
4004389
ae400b1
3b22dab
b3179d7
245ee77
d1b78fb
cf1f1ce
bfb0ede
c0e7308
1fb405c
2f2ca9a
5b36c5d
f46a6bd
9bf30c3
9125e05
417f80d
29dfca7
384317b
5bf4106
6e9e9fd
34d40f0
2ce7bb9
1217de0
4e94f68
367b0c2
1b5fd7a
8db7d65
cf8e37a
1c749e3
82604e9
b78b1df
0951632
6d0e748
6533f92
60ef47b
e891a64
0ac0959
d74f1d7
c64c220
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -71,6 +71,13 @@ def get_consumption_role(self, account_id, role_name, test_role_name): | |
self.put_consumption_role_policy(role_name) | ||
return role | ||
|
||
def delete_role(self, role_name): | ||
try: | ||
self._client.delete_role(RoleName=role_name) | ||
except Exception as e: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
log.error(e) | ||
raise e | ||
|
||
def put_consumption_role_policy(self, role_name): | ||
self._client.put_role_policy( | ||
RoleName=role_name, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import json | ||
import boto3 | ||
|
||
from tests_new.integration_tests.aws_clients.sts import StsClient | ||
|
||
|
||
# it's here and not in Env test module, because it's used only here and we don't want circular dependencies | ||
def get_environment_access_token(client, env_uri, group_uri): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wouldn't mix that. To avoid the circular dependency I'd add access_token as a parameter in the get_group_session |
||
query = { | ||
'operationName': 'generateEnvironmentAccessToken', | ||
'variables': { | ||
'environmentUri': env_uri, | ||
'groupUri': group_uri, | ||
}, | ||
'query': """ | ||
query generateEnvironmentAccessToken( | ||
$environmentUri: String! | ||
$groupUri: String | ||
) { | ||
generateEnvironmentAccessToken( | ||
environmentUri: $environmentUri | ||
groupUri: $groupUri | ||
) | ||
} | ||
""", | ||
} | ||
response = client.query(query=query) | ||
return response.data.generateEnvironmentAccessToken | ||
|
||
|
||
def get_group_session(client, env_uri, group): | ||
credentials = json.loads(get_environment_access_token(client, env_uri, group)) | ||
|
||
return boto3.Session( | ||
aws_access_key_id=credentials['AccessKey'], | ||
aws_secret_access_key=credentials['SessionKey'], | ||
aws_session_token=credentials['sessionToken'], | ||
) | ||
|
||
|
||
def get_role_session(session, role_arn, region): | ||
sts_client = StsClient(session=session, region=region) | ||
return sts_client.get_role_session(role_arn) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -167,6 +167,11 @@ def session_id() -> str: | |
return datetime.datetime.utcnow().isoformat() | ||
|
||
|
||
@pytest.fixture(scope='session', autouse=True) | ||
def session_start_timestamp(session_id) -> float: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is unused |
||
yield datetime.datetime.fromisoformat(session_id).timestamp() | ||
|
||
|
||
@pytest.fixture(scope='session') | ||
def resources_prefix(session_id) -> str: | ||
re.sub('[^a-zA-Z0-9-]', '', session_id).lower() | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,10 +12,13 @@ | |
remove_consumption_role, | ||
remove_group_from_env, | ||
) | ||
from integration_tests.core.stack.queries import update_stack | ||
from integration_tests.core.stack.utils import check_stack_in_progress, check_stack_ready | ||
|
||
from integration_tests.errors import GqlError | ||
|
||
from integration_tests.core.environment.utils import update_env_stack | ||
from integration_tests.core.stack.queries import get_stack | ||
|
||
|
||
log = logging.getLogger(__name__) | ||
|
||
|
||
|
@@ -51,15 +54,18 @@ def test_list_envs_invited(client2, session_env1, session_env2, session_id): | |
|
||
|
||
def test_persistent_env_update(client1, persistent_env1): | ||
# wait for stack to get to a final state before triggering an update | ||
stack_uri = persistent_env1.stack.stackUri | ||
env_uri = persistent_env1.environmentUri | ||
check_stack_ready(client1, env_uri, stack_uri) | ||
update_stack(client1, env_uri, 'environment') | ||
# wait for stack to move to "in_progress" state | ||
check_stack_in_progress(client1, env_uri, stack_uri) | ||
stack = check_stack_ready(client1, env_uri, stack_uri) | ||
assert_that(stack.status).is_equal_to('UPDATE_COMPLETE') | ||
stack = get_stack( | ||
client1, | ||
persistent_env1.environmentUri, | ||
persistent_env1.stack.stackUri, | ||
persistent_env1.environmentUri, | ||
target_type='environment', | ||
) | ||
updated_before = datetime.strptime(stack.updated, '%Y-%m-%d %H:%M:%S.%f').timestamp() | ||
stack = update_env_stack(client1, persistent_env1) | ||
assert_that(stack).contains_entry(status='UPDATE_COMPLETE') | ||
updated = datetime.strptime(stack.updated, '%Y-%m-%d %H:%M:%S.%f').timestamp() | ||
assert_that(updated).is_greater_than_or_equal_to(updated_before) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
i.e... nn1 = datetime.datetime.fromisoformat('2024-10-01 08:12:27.732312') # this is the format we write in the db
nn2 = datetime.datetime.now()
assert_that(nn2).is_greater_than(nn1) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. wrt Ideally we would want to be able to tell wether an update was issued but at the moment I don't think it's possible as this is a limitation of the backend. |
||
|
||
|
||
def test_invite_group_on_env_no_org(client1, session_env2, group4): | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: to avoid all those changes in the backend you could have used
listEnvironmentConsumptionRoles
with a filter