Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Add cruft #125

Merged
merged 3 commits into from
Oct 14, 2022
Merged

Add cruft #125

merged 3 commits into from
Oct 14, 2022

Conversation

ahuang11
Copy link
Contributor

@ahuang11 ahuang11 commented Oct 12, 2022

Summary

Relevant Issue(s)

Closes #111

Checklist

  • Summarized PR's changes in the Unreleased section of the CHANGELOG.md

@ahuang11
Copy link
Contributor Author

ahuang11 commented Oct 12, 2022

Tests failling on:



__________________________ test_launch_types[FARGATE] __________________________

aws_credentials = AwsCredentials(aws_access_key_id='access_key_id', aws_secret_access_key=SecretStr('**********'), aws_session_token=None, profile_name=None, region_name='us-east-1')
launch_type = 'FARGATE'

    @pytest.mark.usefixtures("ecs_mocks")
    @pytest.mark.parametrize("launch_type", ["EC2", "FARGATE", "FARGATE_SPOT"])
    async def test_launch_types(aws_credentials, launch_type: str):
        task = ECSTask(
            aws_credentials=aws_credentials,
            auto_deregister_task_definition=False,
            command=["prefect", "version"],
            launch_type=launch_type,
        )
        print(task.preview())
    
        session = aws_credentials.get_boto3_session()
        ecs_client = session.client("ecs")
    
>       task_arn = await run_then_stop_task(task)

...
self = <moto.ecs.models.Task object at 0x7fce6af6cf10>
cluster = <moto.ecs.models.Cluster object at 0x7fce65f7d190>
task_definition = <moto.ecs.models.TaskDefinition object at 0x7fce691a6e10>
container_instance_arn = 'arn:aws:ecs:us-east-1:123456789012:container-instance/default/e2f46c39-c747-4a71-af62-7426d6d1c898'
resource_requirements = {'CPU': 0, 'MEMORY': 0, 'PORTS': [], 'PORTS_UDP': []}
backend = <moto.ecs.models.EC2ContainerServiceBackend object at 0x7fce6aaa9610>
launch_type = 'FARGATE'
overrides = {'containerOverrides': [{'command': ['prefect', 'version'], 'environment': [{'name': 'PREFECT_ORION_DATABASE_CONNECTION_URL', 'value': 'sqlite+aiosqlite:////tmp/tmp9xu65h5q/orion.db'}], 'name': 'prefect'}]}
started_by = '', tags = []
networking_configuration = {'awsvpcConfiguration': {'assignPublicIp': 'ENABLED', 'subnets': ['subnet-5b085f7a', 'subnet-57e3fb65', 'subnet-544405f4', 'subnet-7be12aee', 'subnet-c47aeb59', 'subnet-0b5523d7']}}

    def __init__(
        self,
        cluster,
        task_definition,
        container_instance_arn,
        resource_requirements,
        backend,
        launch_type="",
        overrides=None,
        started_by="",
        tags=None,
        networking_configuration=None,
    ):
        self.id = str(mock_random.uuid4())
        self.cluster_name = cluster.name
        self.cluster_arn = cluster.arn
        self.container_instance_arn = container_instance_arn
        self.last_status = "RUNNING"
        self.desired_status = "RUNNING"
        self.task_definition_arn = task_definition.arn
        self.overrides = overrides or {}
        self.containers = []
        self.started_by = started_by
        self.tags = tags or []
        self.launch_type = launch_type
        self.stopped_reason = ""
        self.resource_requirements = resource_requirements
        self.region_name = cluster.region_name
        self._account_id = backend.account_id
        self._backend = backend
        self.attachments = []
    
        if task_definition.network_mode == "awsvpc":
            if not networking_configuration:
    
                raise InvalidParameterException(
                    "Network Configuration must be provided when networkMode 'awsvpc' is specified."
                )
    
            self.network_configuration = networking_configuration
            net_conf = networking_configuration["awsvpcConfiguration"]
            ec2_backend = ec2_backends[self._account_id][self.region_name]
    
            eni = ec2_backend.create_network_interface(
                subnet=net_conf["subnets"][0],
                private_ip_address=random_private_ip(),
>               group_ids=net_conf["securityGroups"],
                description="moto ECS",
            )
E           KeyError: 'securityGroups'

@desertaxle desertaxle merged commit 11aedc4 into main Oct 14, 2022
@desertaxle desertaxle deleted the add_cruft branch October 14, 2022 19:51
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add collection sync workflow using cruft
2 participants