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: s3 dataset shares, persistent shares #1580

Merged
merged 115 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 103 commits
Commits
Show all changes
115 commits
Select commit Hold shift + click to select a range
b188538
Add integration tests for datasets - basic queries and conftest
dlpzx Jul 1, 2024
45d1407
add list + get queries, add persistent datasets, begin create/update/…
noah-paige Jul 1, 2024
cd27097
Add integration test role in Environment stack + session in conftest …
dlpzx Jul 2, 2024
d04b525
simplified conftests for datasets
dlpzx Jul 2, 2024
5e5507e
create integration role with region in name
noah-paige Jul 2, 2024
fa69dde
New environment type: IntegrationTests + ssm param with tooling accou…
dlpzx Jul 3, 2024
3e19596
Error on cdk add_to_policy
dlpzx Jul 3, 2024
c05de67
Add filter term include tags datasets
noah-paige Jul 4, 2024
8f2a918
Add sample data and tests for dataset role access
noah-paige Jul 4, 2024
9b2c711
Add sample data and tests for dataset role access
noah-paige Jul 4, 2024
d30c121
set up structure
Jul 4, 2024
2bad8bd
in get_or_create_persistent_env argument of delete_env must be env-ob…
Jul 5, 2024
6214964
create|update|submit simple share
Jul 5, 2024
3972e05
testdata.json -> gitignore
Jul 5, 2024
2dcd60f
Add assume role permissions to codebuild role
dlpzx Jul 8, 2024
c261da7
Add naming checks in clients + create table
dlpzx Jul 8, 2024
1e9732b
Add permissions, confidentiality and commented tests
dlpzx Jul 8, 2024
cf8553c
second share + autoapproval test
Jul 8, 2024
5ea8b6b
revert persistent environment
dlpzx Jul 8, 2024
520a34e
Fix check_stack_ready in dataset creation
dlpzx Jul 8, 2024
0cf4ea7
full cycle test
Jul 8, 2024
972c883
Revert session environment and add tests
dlpzx Jul 8, 2024
7b1c942
fix integration role datasets
noah-paige Jul 8, 2024
d9042dc
Fix presigned URL upload test
noah-paige Jul 9, 2024
928c3aa
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/int…
dlpzx Jul 9, 2024
a996273
decouple tests, test dependencies
Jul 9, 2024
023fbc4
Merge branch 'mda-main' into share-int-tests
Jul 9, 2024
b633938
Uncomment drafted table/folder tests
dlpzx Jul 9, 2024
74cb6fe
Merge branch 'mda-main' into share-int-tests
Aug 29, 2024
c05df65
conftest
Aug 30, 2024
50e1a60
persistent dataset for share testing
Sep 2, 2024
7897028
Merge branch 'feat/integration-tests-datasets-pt2' into share-int-tests
Sep 3, 2024
45f5078
half way
Sep 3, 2024
43cde66
Merge branch 'mda-main' into share-int-tests
Sep 4, 2024
2330021
Merge branch 'refs/heads/main' into feat/integration-tests-datasets-pt2
dlpzx Sep 5, 2024
a857d0a
Ruff and readme
dlpzx Sep 5, 2024
6abe590
all tests fixed
Sep 5, 2024
5968fd3
Split dataset tests and added signature of each test for all APIs. Fi…
dlpzx Sep 5, 2024
e4e9c12
tests for share item types
Sep 5, 2024
052bc7e
Added all dataset query definitions and placeholders for tests
dlpzx Sep 6, 2024
e739a25
ShareableType fix
Sep 6, 2024
9ad774e
Started parametrization of tests
dlpzx Sep 6, 2024
146c45e
Started parametrization of tests
dlpzx Sep 6, 2024
0907ea3
Started parametrization of tests
dlpzx Sep 6, 2024
7f68d3b
Started parametrization of tests
dlpzx Sep 6, 2024
98c7667
Added persistent tables and folders
dlpzx Sep 9, 2024
92f23e3
Remove unnecessary tests in folders
dlpzx Sep 9, 2024
3907001
Fix issues with KMS datasets
dlpzx Sep 9, 2024
3553d12
Temporary changes for persistent datasets
dlpzx Sep 9, 2024
9be25bb
Add paramtrization in profiling, confidentiality, fix issue in glue t…
dlpzx Sep 9, 2024
1709bb5
Fix s3_table tests, parametrized dataset tests
dlpzx Sep 9, 2024
6889c47
Retouch preview_table tests
dlpzx Sep 9, 2024
aba8536
Merge branch 'feat/integration-tests-datasets-pt2' into share-int-tests
Sep 9, 2024
3d67e2e
Fixed profiling tables tests
dlpzx Sep 9, 2024
4fd56af
Fixed profiling tables tests
dlpzx Sep 9, 2024
56b12c5
Fix everything except for persistent-sse-s3 tests
dlpzx Sep 9, 2024
ade89e8
Fix API query to filter by tags + add README detail
dlpzx Sep 10, 2024
72259c4
Wrong SSM parameter in README
dlpzx Sep 10, 2024
3b74b03
Merge remote-tracking branch 'refs/remotes/origin/main' into feat/int…
dlpzx Sep 10, 2024
b31d666
update share request|reject reasons
Sep 10, 2024
c220135
Merge branch 'feat/integration-tests-datasets-pt2' into share-int-tests
Sep 10, 2024
196fb6e
Moving fixture parameters to conftest
dlpzx Sep 10, 2024
d3bb8be
Update requisite in README
dlpzx Sep 10, 2024
fbbccb7
cons role tests
Sep 10, 2024
ec38ec0
PR review comments - functions to create AWS imported resources, names
dlpzx Sep 11, 2024
ccb6887
PR review comments - 2
dlpzx Sep 11, 2024
01c65c8
Merge branch 'refs/heads/main' into feat/integration-tests-datasets-pt2
dlpzx Sep 11, 2024
5358677
Issue persistent buckets
dlpzx Sep 11, 2024
590909b
Rewrite if-clause existing infra and resource for imported dataset
dlpzx Sep 12, 2024
adc48a3
Merge branch 'feat/integration-tests-datasets-pt2' into share-int-tests
Sep 12, 2024
2c8724c
crossaccount shares
Sep 13, 2024
1e3a2af
readme
Sep 13, 2024
c6cfd11
add tables and folders
Sep 16, 2024
b32b269
crossacc cons roles
Sep 16, 2024
3907faa
second_test_aws_profile
Sep 16, 2024
b2f78a0
testdata and readme fix
Sep 16, 2024
4004389
testdata and readme fix
Sep 16, 2024
ae400b1
remove unused
Sep 16, 2024
3b22dab
Merge branch 'mda-main' into share-int-tests
Sep 17, 2024
b3179d7
Merge branch 'mda-main' into share-int-tests
Sep 17, 2024
245ee77
refactoring
Sep 17, 2024
d1b78fb
check folder access and access point
Sep 17, 2024
cf1f1ce
s3 account clean up script
Sep 17, 2024
bfb0ede
verify share item access
Sep 18, 2024
c0e7308
parametrize
Sep 19, 2024
1fb405c
use env test role
Sep 20, 2024
2f2ca9a
add assumed role to trust relations
Sep 20, 2024
5b36c5d
redo parametrization
Sep 20, 2024
f46a6bd
execute query -- hide logic in client
Sep 23, 2024
9bf30c3
PR changes
Sep 23, 2024
9125e05
additional logging
Sep 24, 2024
417f80d
session env instead of persistent env
Sep 24, 2024
29dfca7
cdk
Sep 24, 2024
384317b
typos
Sep 24, 2024
5bf4106
ruff
Sep 24, 2024
6e9e9fd
cdk.json back to default
Sep 24, 2024
34d40f0
Merge branch 'main' into share-int-tests
SofiaSazonova Sep 24, 2024
2ce7bb9
persistent env update test
Sep 25, 2024
1217de0
persistent shares test
Sep 26, 2024
4e94f68
Merge branch 'mda-main' into share-int-tests-2
Sep 26, 2024
367b0c2
Merge branch 'mda-main' into share-int-tests-2
Sep 26, 2024
1b5fd7a
no dataall import
Sep 26, 2024
8db7d65
session consumption role is deleted after tests
Sep 26, 2024
cf8e37a
Merge branch 'mda-main' into share-int-tests-2
Oct 1, 2024
1c749e3
PR comments
Oct 1, 2024
82604e9
remove unused
Oct 1, 2024
b78b1df
bandit install via pip3
Oct 1, 2024
0951632
undo
Oct 1, 2024
6d0e748
one more try
Oct 1, 2024
6533f92
one more try
Oct 1, 2024
60ef47b
didn't work
Oct 1, 2024
e891a64
try not latest version
Oct 1, 2024
0ac0959
explicitly install typing-extensions
Oct 1, 2024
d74f1d7
Merge branch 'mda-main' into share-int-tests-2
Oct 1, 2024
c64c220
fromisoformat
Oct 2, 2024
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
13 changes: 13 additions & 0 deletions backend/dataall/core/environment/api/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
list_groups,
list_valid_environments,
get_consumption_role_policies,
get_consumption_role,
)
from dataall.core.environment.api.types import (
Environment,
Expand Down Expand Up @@ -220,3 +221,15 @@
resolver=get_consumption_role_policies,
test_scope='Environment',
)


getConsumptionRole = gql.QueryField(
Copy link
Contributor

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

name='getConsumptionRole',
args=[
gql.Argument(name='environmentUri', type=gql.NonNullableType(gql.String)),
gql.Argument(name='IAMRoleName', type=gql.NonNullableType(gql.String)),
],
type=gql.Ref('ConsumptionRole'),
resolver=get_consumption_role,
test_scope='Environment',
)
4 changes: 4 additions & 0 deletions backend/dataall/core/environment/api/resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,3 +285,7 @@ def resolve_parameters(context, source: Environment, **kwargs):
if not source:
return None
return EnvironmentService.get_environment_parameters(source.environmentUri)


def get_consumption_role(context, source, environmentUri, IAMRoleName):
return EnvironmentService.get_consumption_role_by_name(uri=environmentUri, IAMRoleName=IAMRoleName)
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 @@ -657,7 +657,7 @@ def create_integration_tests_role(self):

self.test_role.add_to_policy(
iam.PolicyStatement(
actions=['iam:GetRole', 'iam:CreateRole', 'iam:PutRolePolicy'],
actions=['iam:GetRole', 'iam:CreateRole', 'iam:DeleteRole', 'iam:PutRolePolicy'],
effect=iam.Effect.ALLOW,
resources=[f'arn:aws:iam::{self.account}:role/dataall-test-*'],
),
Expand Down
13 changes: 13 additions & 0 deletions backend/dataall/core/environment/db/environment_repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,3 +310,16 @@ def query_all_active_environments(session) -> List[Environment]:
@staticmethod
def query_environment_groups(session, uri):
return session.query(EnvironmentGroup).filter(EnvironmentGroup.environmentUri == uri).all()

@staticmethod
def get_environment_consumption_role_by_name(session, uri, IAMRoleName):
return (
session.query(ConsumptionRole)
.filter(
and_(
ConsumptionRole.environmentUri == uri,
ConsumptionRole.IAMRoleName == IAMRoleName,
)
)
.first()
)
Original file line number Diff line number Diff line change
Expand Up @@ -1147,3 +1147,9 @@ def resolve_consumption_role_policies(uri, IAMRoleName):
region=environment.region,
resource_prefix=environment.resourcePrefix,
).get_all_policies()

@staticmethod
@ResourcePolicyService.has_resource_permission(environment_permissions.GET_ENVIRONMENT)
def get_consumption_role_by_name(uri, IAMRoleName):
with get_context().db_engine.scoped_session() as session:
return EnvironmentRepository.get_environment_consumption_role_by_name(session, uri, IAMRoleName)
1 change: 1 addition & 0 deletions backend/dataall/core/stacks/api/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
gql.Field(name='region', type=gql.NonNullableType(gql.String)),
gql.Field(name='status', type=gql.String),
gql.Field(name='stackid', type=gql.String),
gql.Field(name='updated', type=gql.AWSDateTime),
petrkalos marked this conversation as resolved.
Show resolved Hide resolved
gql.Field(name='link', type=gql.String, resolver=resolve_link),
gql.Field(name='outputs', type=gql.String, resolver=resolve_outputs),
gql.Field(name='resources', type=gql.String, resolver=resolve_resources),
Expand Down
7 changes: 7 additions & 0 deletions tests_new/integration_tests/aws_clients/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

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

except just for logging isn't really necessary, let the exception bubble up and the runtime will eventually log it with a stacktrace etc

log.error(e)
raise e

def put_consumption_role_policy(self, role_name):
self._client.put_role_policy(
RoleName=role_name,
Expand Down
43 changes: 43 additions & 0 deletions tests_new/integration_tests/aws_clients/utils.py
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):
Copy link
Contributor

Choose a reason for hiding this comment

The 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)
5 changes: 5 additions & 0 deletions tests_new/integration_tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The 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()
Expand Down
30 changes: 30 additions & 0 deletions tests_new/integration_tests/core/environment/global_conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
from datetime import datetime

import pytest
import boto3

Expand All @@ -12,6 +14,7 @@
)
from integration_tests.core.organizations.queries import create_organization
from integration_tests.core.stack.utils import check_stack_ready
from tests_new.integration_tests.core.environment.utils import update_env_stack

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -178,3 +181,30 @@ def get_or_create_persistent_env(env_name, client, group, testdata):
@pytest.fixture(scope='session')
def persistent_env1(client1, group1, testdata):
return get_or_create_persistent_env('persistent_env1', client1, group1, testdata)


@pytest.fixture(scope='session')
def updated_persistent_env1(client1, group1, persistent_env1):
update_env_stack(client1, persistent_env1)
return get_environment(client1, persistent_env1.environmentUri)


@pytest.fixture(scope='session')
def persistent_cross_acc_env_1(client5, group5, testdata):
return get_or_create_persistent_env('persistent_cross_acc_env_1', client5, group5, testdata)


@pytest.fixture(scope='session')
def updated_persistent_cross_acc_env_1(client5, group5, persistent_cross_acc_env_1):
update_env_stack(client5, persistent_cross_acc_env_1)
return get_environment(client5, persistent_cross_acc_env_1.environmentUri)


@pytest.fixture(scope='session')
def persistent_cross_acc_env_1_integration_role_arn(persistent_cross_acc_env_1):
return f'arn:aws:iam::{persistent_cross_acc_env_1.AwsAccountId}:role/dataall-integration-tests-role-{persistent_cross_acc_env_1.region}'


@pytest.fixture(scope='session')
def persistent_cross_acc_env_1_aws_client(persistent_cross_acc_env_1, persistent_cross_acc_env_1_integration_role_arn):
return get_environment_aws_session(persistent_cross_acc_env_1_integration_role_arn, persistent_cross_acc_env_1)
30 changes: 30 additions & 0 deletions tests_new/integration_tests/core/environment/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
accountid
region
stackid
updated
link
outputs
resources
Expand Down Expand Up @@ -244,6 +245,35 @@ def add_consumption_role(client, env_uri, group_uri, consumption_role_name, iam_
return response.data.addConsumptionRoleToEnvironment


def get_consumption_role(client, env_uri, iam_role_name):
query = {
'operationName': 'getConsumptionRole',
'variables': {
'environmentUri': env_uri,
'IAMRoleName': iam_role_name,
},
'query': """
query getConsumptionRole(
$environmentUri: String!
$IAMRoleName: String!
) {
getConsumptionRole(
environmentUri: $environmentUri
IAMRoleName: $IAMRoleName
) {
consumptionRoleUri
consumptionRoleName
environmentUri
groupUri
IAMRoleArn
}
}
""",
}
response = client.query(query=query)
return response.data.getConsumptionRole


def remove_consumption_role(client, env_uri, consumption_role_uri):
query = {
'operationName': 'removeConsumptionRoleFromEnvironment',
Expand Down
28 changes: 17 additions & 11 deletions tests_new/integration_tests/core/environment/test_environment.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)


Expand Down Expand Up @@ -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)
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. we write ISO dates so you can use datetime.fromisoformat(...)
  2. you don't have to convert to timestamps, datetime objects are comparable and errors will much easier to read
  3. depending on whether updated is updated based on CFN or not (see my comment below) we might not want the "equal" part

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)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  1. ok
  2. ok
  3. We need equal)

Copy link
Contributor

Choose a reason for hiding this comment

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

wrt 3 and for the record (not to be solved in this PR).

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):
Expand Down
12 changes: 12 additions & 0 deletions tests_new/integration_tests/core/environment/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from integration_tests.core.environment.queries import update_environment
from integration_tests.core.stack.utils import check_stack_ready, check_stack_in_progress
from integration_tests.core.stack.queries import update_stack


def set_env_params(client, env, **new_params):
Expand Down Expand Up @@ -34,3 +35,14 @@ def set_env_params(client, env, **new_params):
)
check_stack_in_progress(client, env_uri, stack_uri)
check_stack_ready(client, env_uri, stack_uri)


def update_env_stack(client, env):
stack_uri = env.stack.stackUri
env_uri = env.environmentUri
# wait for stack to get to a final state before triggering an update
check_stack_ready(client, env_uri, stack_uri)
update_stack(client, env_uri, 'environment')
# wait for stack to move to "in_progress" state
check_stack_in_progress(client, env_uri, stack_uri)
return check_stack_ready(client, env_uri, stack_uri)
1 change: 1 addition & 0 deletions tests_new/integration_tests/core/stack/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ def get_stack(client, env_uri, stack_uri, target_uri, target_type):
accountid
region
stackid
updated
link
outputs
resources
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def list_bucket_objects(self, bucket_name):
return self._client.list_objects(Bucket=bucket_name)
except ClientError as e:
logging.error(f'Error listing objects in S3: {e}')
raise
raise e

def list_accesspoint_folder_objects(self, access_point, folder_name):
try:
Expand Down
32 changes: 30 additions & 2 deletions tests_new/integration_tests/modules/s3_datasets/global_conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import logging
import time

import pytest
import boto3
import json
Expand All @@ -19,6 +21,7 @@
from tests_new.integration_tests.modules.datasets_base.queries import list_datasets

from integration_tests.modules.s3_datasets.aws_clients import S3Client, KMSClient, GlueClient, LakeFormationClient
from integration_tests.core.stack.queries import update_stack

log = logging.getLogger(__name__)

Expand Down Expand Up @@ -398,7 +401,15 @@ def temp_s3_dataset1(client1, group1, org1, session_env1, session_id, testdata):


def get_or_create_persistent_s3_dataset(
dataset_name, client, group, env, autoApprovalEnabled=False, bucket=None, kms_alias='', glue_database=''
dataset_name,
client,
group,
env,
autoApprovalEnabled=False,
bucket=None,
kms_alias='',
glue_database='',
withContent=False,
):
dataset_name = dataset_name or 'persistent_s3_dataset1'
s3_datasets = list_datasets(client, term=dataset_name).nodes
Expand Down Expand Up @@ -431,6 +442,9 @@ def get_or_create_persistent_s3_dataset(
tags=[dataset_name],
autoApprovalEnabled=autoApprovalEnabled,
)
if withContent:
create_tables(client, s3_dataset)
create_folders(client, s3_dataset)

if s3_dataset.stack.status in ['CREATE_COMPLETE', 'UPDATE_COMPLETE']:
return s3_dataset
Expand All @@ -441,7 +455,21 @@ def get_or_create_persistent_s3_dataset(

@pytest.fixture(scope='session')
def persistent_s3_dataset1(client1, group1, persistent_env1, testdata):
return get_or_create_persistent_s3_dataset('persistent_s3_dataset1', client1, group1, persistent_env1)
return get_or_create_persistent_s3_dataset(
'persistent_s3_dataset1', client1, group1, persistent_env1, withContent=True
)


@pytest.fixture(scope='session')
def updated_persistent_s3_dataset1(client1, persistent_s3_dataset1):
target_type = 'dataset'
stack_uri = persistent_s3_dataset1.stack.stackUri
env_uri = persistent_s3_dataset1.environment.environmentUri
dataset_uri = persistent_s3_dataset1.datasetUri
update_stack(client1, dataset_uri, target_type)
time.sleep(120)
check_stack_ready(client1, env_uri=env_uri, stack_uri=stack_uri, target_uri=dataset_uri, target_type=target_type)
return get_dataset(client1, dataset_uri)


@pytest.fixture(scope='session')
Expand Down
Loading
Loading