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

Remove deprecated modules from Amazon provider package #25609

Merged
merged 6 commits into from
Aug 9, 2022

Conversation

vincbeck
Copy link
Contributor

@vincbeck vincbeck commented Aug 8, 2022

Follow up of #25543. @potiuk

@potiuk
Copy link
Member

potiuk commented Aug 8, 2022

Yep. Waiting for the tests to complete :)

@potiuk
Copy link
Member

potiuk commented Aug 8, 2022

stilll a number of tests failing :( @vincbeck

@Taragolis
Copy link
Contributor

Taragolis commented Aug 8, 2022

@vincbeck

Selected tests not relevant anymore and could be removed

test_get_client_type_returns_a_boto3_client_of_the_requested_type

@unittest.skipIf(mock_emr is None, 'mock_emr package not present')
@mock_emr
def test_get_client_type_returns_a_boto3_client_of_the_requested_type(self):
client = boto3.client('emr', region_name='us-east-1')
if client.list_clusters()['Clusters']:
raise ValueError('AWS not properly mocked')
hook = AwsBaseHook(aws_conn_id='aws_default', client_type='emr')
client_from_hook = hook.get_client_type('emr')
assert client_from_hook.list_clusters()['Clusters'] == []

test_get_client_type_overwrite

@unittest.skipIf(mock_emr is None, 'mock_emr package not present')
@mock_emr
def test_get_client_type_overwrite(self):
client = boto3.client('emr', region_name='us-east-1')
if client.list_clusters()['Clusters']:
raise ValueError('AWS not properly mocked')
hook = AwsBaseHook(aws_conn_id='aws_default', client_type='dynamodb')
client_from_hook = hook.get_client_type(client_type='emr')
assert client_from_hook.list_clusters()['Clusters'] == []

test_get_client_type_deprecation_warning

@unittest.skipIf(mock_emr is None, 'mock_emr package not present')
@mock_emr
def test_get_client_type_deprecation_warning(self):
hook = AwsBaseHook(aws_conn_id='aws_default', client_type='emr')
warning_message = """client_type is deprecated. Set client_type from class attribute."""
with pytest.warns(DeprecationWarning) as warnings:
hook.get_client_type(client_type='emr')
assert warning_message in [str(w.message) for w in warnings]

test_get_resource_type_returns_a_boto3_resource_of_the_requested_type

@unittest.skipIf(mock_dynamodb2 is None, 'mock_dynamo2 package not present')
@mock_dynamodb2
def test_get_resource_type_returns_a_boto3_resource_of_the_requested_type(self):
hook = AwsBaseHook(aws_conn_id='aws_default', resource_type='dynamodb')
resource_from_hook = hook.get_resource_type('dynamodb')
# this table needs to be created in production
table = resource_from_hook.create_table(
TableName='test_airflow',
KeySchema=[
{'AttributeName': 'id', 'KeyType': 'HASH'},
],
AttributeDefinitions=[{'AttributeName': 'id', 'AttributeType': 'S'}],
ProvisionedThroughput={'ReadCapacityUnits': 10, 'WriteCapacityUnits': 10},
)
table.meta.client.get_waiter('table_exists').wait(TableName='test_airflow')
assert table.item_count == 0

test_get_resource_type_overwrite

@unittest.skipIf(mock_dynamodb2 is None, 'mock_dynamo2 package not present')
@mock_dynamodb2
def test_get_resource_type_overwrite(self):
hook = AwsBaseHook(aws_conn_id='aws_default', resource_type='s3')
resource_from_hook = hook.get_resource_type('dynamodb')
# this table needs to be created in production
table = resource_from_hook.create_table(
TableName='test_airflow',
KeySchema=[
{'AttributeName': 'id', 'KeyType': 'HASH'},
],
AttributeDefinitions=[{'AttributeName': 'id', 'AttributeType': 'S'}],
ProvisionedThroughput={'ReadCapacityUnits': 10, 'WriteCapacityUnits': 10},
)
table.meta.client.get_waiter('table_exists').wait(TableName='test_airflow')
assert table.item_count == 0

test_get_resource_deprecation_warning

@unittest.skipIf(mock_dynamodb2 is None, 'mock_dynamo2 package not present')
@mock_dynamodb2
def test_get_resource_deprecation_warning(self):
hook = AwsBaseHook(aws_conn_id='aws_default', resource_type='dynamodb')
warning_message = """resource_type is deprecated. Set resource_type from class attribute."""
with pytest.warns(DeprecationWarning) as warnings:
hook.get_resource_type('dynamodb')
assert warning_message in [str(w.message) for w in warnings]


test_refreshable_credentials uses removed attribute

Quick hotfix:

  1. In hook specify client_type='sts'

    mock_get_connection.return_value = mock_connection
    hook = AwsBaseHook(aws_conn_id='aws_default', client_type='airflow_test')

  2. hook.get_client_type('sts') -> hook.get_client_type()

    mock_refresh.side_effect = mock_refresh_credentials
    client = hook.get_client_type('sts')
    client.get_caller_identity()

@vincbeck
Copy link
Contributor Author

vincbeck commented Aug 8, 2022

Awesome! Thank you so much @Taragolis

@eladkal eladkal self-requested a review August 9, 2022 06:17
@eladkal
Copy link
Contributor

eladkal commented Aug 9, 2022

CI is not happy :(
some failures related to TestSsmSecrets

@potiuk
Copy link
Member

potiuk commented Aug 9, 2022

I prepared the #25618 - but I can still include that one if we fix the issues

@potiuk
Copy link
Member

potiuk commented Aug 9, 2022

🤞 @vincbeck - I think this is the last one I want to include in this wave of providers :) (I will make one more pass to see)

@vincbeck
Copy link
Contributor Author

vincbeck commented Aug 9, 2022

Some tests were canceled. Any idea @potiuk ?

@potiuk
Copy link
Member

potiuk commented Aug 9, 2022

Just one - likely an intermittent error. Re-run it @vincbeck

@vincbeck
Copy link
Contributor Author

vincbeck commented Aug 9, 2022

YAY!

@potiuk potiuk merged commit 85137f3 into apache:main Aug 9, 2022
@potiuk
Copy link
Member

potiuk commented Aug 9, 2022

🎉 🎉 🎉 🎉 🎉

@ephraimbuddy ephraimbuddy added the type:misc/internal Changelog: Misc changes that should appear in change log label Aug 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:providers provider:amazon-aws AWS/Amazon - related issues type:misc/internal Changelog: Misc changes that should appear in change log
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants