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

CICD Integration tests: new shares for pre-existing datasets #1611

Merged
merged 11 commits into from
Dec 23, 2024
2 changes: 1 addition & 1 deletion backend/dataall/core/environment/cdk/environment_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def create_integration_tests_role(self):
],
effect=iam.Effect.ALLOW,
resources=[
f'arn:aws:iam::{self.account}:role/dataall-test-*',
f'arn:aws:iam::{self.account}:role/dataall-test*',
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was made, so the int test role could ListPolicies for role dataall-testgroup-*

f'arn:aws:iam::{self.account}:role/dataall-session*',
],
),
Expand Down
18 changes: 14 additions & 4 deletions tests_new/integration_tests/aws_clients/athena.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,19 @@ def list_work_groups(self):
result = self._client.list_work_groups()
return [x['Name'] for x in result['WorkGroups']]

def get_env_work_group(self, env_name):
def get_work_group(self, env_name, group):
workgroups = self.list_work_groups()
group_snakify = group.lower().replace('-', '_')
env_name_snakify = env_name.lower().replace('-', '_')
default_workgroup = 'primary'
env_workgroup, group_workgroup = None, None
for workgroup in workgroups:
if env_name in workgroup:
return workgroup
return workgroups[0] if workgroups else None
if env_name_snakify in workgroup:
env_workgroup = workgroup
if group_snakify in workgroup:
group_workgroup = workgroup
if group_workgroup:
return group_workgroup
elif env_workgroup:
return env_workgroup
return default_workgroup
Copy link
Contributor

Choose a reason for hiding this comment

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

If here we are returning the workgroup for groups (not for consumption roles) we should throw an error instead of returning the primary if no group_workgroup or env_workgroup is found

2 changes: 1 addition & 1 deletion tests_new/integration_tests/aws_clients/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def put_consumption_role_policy(self, role_name):
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Sid": "TestPolicyDoc",
"Effect": "Allow",
"Action": [
"s3:*",
Expand Down
18 changes: 18 additions & 0 deletions tests_new/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,12 @@ def user5(userdata):
yield userdata['testUser5']


@pytest.fixture(scope='session', autouse=True)
def user6(userdata):
# Existing user with name and password
yield userdata['testUser6']


@pytest.fixture(scope='session', autouse=True)
def group1():
# Existing Cognito group with name testGroup1
Expand Down Expand Up @@ -143,6 +149,13 @@ def group5():
yield 'testGroup5'


@pytest.fixture(scope='session', autouse=True)
def group6():
# Existing Cognito group with name testGroup5
# Add user5
yield 'testGroup6'


@pytest.fixture(scope='session')
def client1(user1) -> Client:
yield Client(user1.username, user1.password)
Expand All @@ -168,6 +181,11 @@ def client5(user5) -> Client:
yield Client(user5.username, user5.password)


@pytest.fixture(scope='session')
def client6(user6) -> Client:
yield Client(user6.username, user6.password)


@pytest.fixture(scope='session')
def clientTenant(userTenant) -> Client:
yield Client(userTenant.username, userTenant.password)
Expand Down
31 changes: 28 additions & 3 deletions tests_new/integration_tests/core/environment/global_conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import pytest
import logging
from contextlib import contextmanager

import pytest
from assertpy import assert_that

from integration_tests.aws_clients.sts import STSClient
Expand All @@ -13,7 +13,11 @@
list_environments,
invite_group_on_env,
)
from integration_tests.core.organizations.queries import create_organization
from integration_tests.core.organizations.queries import (
create_organization,
list_organizations,
invite_team_to_organization,
)
from integration_tests.core.stack.utils import check_stack_ready
from tests_new.integration_tests.aws_clients.s3 import S3Client
from tests_new.integration_tests.core.environment.utils import update_env_stack
Expand Down Expand Up @@ -192,8 +196,29 @@ def persistent_env1(client1, group1, testdata):


@pytest.fixture(scope='session')
def persistent_cross_acc_env_1(client5, group5, testdata):
def persistent_cross_acc_env_1(client5, group5, client6, group6, testdata):
with get_or_create_persistent_env('persistent_cross_acc_env_1', client5, group5, testdata) as env:
orgs = [org.organizationUri for org in list_organizations(client6).nodes]
envs = [org.environmentUri for org in list_environments(client6).nodes]
if env.organization.organizationUri not in orgs:
invite_team_to_organization(client5, env.organization.organizationUri, group6)
if env.environmentUri not in envs:
invite_group_on_env(
client5,
env.environmentUri,
group6,
[
'UPDATE_ENVIRONMENT',
'GET_ENVIRONMENT',
'ADD_ENVIRONMENT_CONSUMPTION_ROLES',
'LIST_ENVIRONMENT_CONSUMPTION_ROLES',
'LIST_ENVIRONMENT_GROUPS',
'CREDENTIALS_ENVIRONMENT',
'CREATE_SHARE_OBJECT',
'LIST_ENVIRONMENT_SHARED_WITH_OBJECTS',
],
)
update_env_stack(client5, env)
yield env


Expand Down
Loading
Loading