Skip to content

Commit

Permalink
Update ec2_vpc_vpn to use a connection with an AWSRetry decorator
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Feb 11, 2021
1 parent f9819f0 commit 7b440b5
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions tests/unit/plugins/modules/test_ec2_vpc_vpn.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@

import pytest
import os
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify, maybe_sleep
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import placeboify
from ansible_collections.amazon.aws.tests.unit.utils.amazon_placebo_fixtures import maybe_sleep

import ansible_collections.amazon.aws.plugins.module_utils.core as aws_core
import ansible_collections.amazon.aws.plugins.module_utils.ec2 as aws_ec2
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_aws_connection_info
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_conn
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict

from ansible_collections.community.aws.plugins.modules import ec2_vpc_vpn
from ansible_collections.amazon.aws.plugins.module_utils.ec2 import get_aws_connection_info, boto3_conn, boto3_tag_list_to_ansible_dict


class FakeModule(object):
def __init__(self, **kwargs):
self.params = kwargs

def fail_json_aws(self, *args, **kwargs):
self.exit_args = args
self.exit_kwargs = kwargs
raise Exception('FAIL')

def fail_json(self, *args, **kwargs):
self.exit_args = args
self.exit_kwargs = kwargs
Expand Down Expand Up @@ -68,8 +80,10 @@ def get_dependencies():

def setup_mod_conn(placeboify, params):
conn = placeboify.client('ec2')
retry_decorator = aws_ec2.AWSRetry.jittered_backoff()
wrapped_conn = aws_core._RetryingBotoClientWrapper(conn, retry_decorator)
m = FakeModule(**params)
return m, conn
return m, wrapped_conn


def make_params(cgw, vgw, tags=None, filters=None, routes=None):
Expand Down

0 comments on commit 7b440b5

Please sign in to comment.