|
13 | 13 | "com.amazonaws.ecs.container-name": "fargateapp", |
14 | 14 | "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:123456789012:task/testcluster/1e1698469422439ea356071e581e8545", |
15 | 15 | "com.amazonaws.ecs.task-definition-family": "fargatetestapp", |
16 | | - "com.amazonaws.ecs.task-definition-version": "7" |
| 16 | + "com.amazonaws.ecs.task-definition-version": "7", |
17 | 17 | }, |
18 | 18 | "DesiredStatus": "RUNNING", |
19 | 19 | "KnownStatus": "RUNNING", |
20 | | - "Limits": { |
21 | | - "CPU": 2 |
| 20 | + "Limits": {"CPU": 2}, |
| 21 | + "CreatedAt": "2024-04-25T17:38:31.073208914Z", |
| 22 | + "StartedAt": "2024-04-25T17:38:31.073208914Z", |
| 23 | + "Type": "NORMAL", |
| 24 | + "LogDriver": "awslogs", |
| 25 | + "LogOptions": { |
| 26 | + "awslogs-create-group": "true", |
| 27 | + "awslogs-group": "/ecs/fargatetestapp", |
| 28 | + "awslogs-region": "us-west-2", |
| 29 | + "awslogs-stream": "ecs/fargateapp/1e1698469422439ea356071e581e8545", |
22 | 30 | }, |
| 31 | + "ContainerARN": "arn:aws:ecs:us-west-2:123456789012:container/testcluster/1e1698469422439ea356071e581e8545/050256a5-a7f3-461c-a16f-aca4eae37b01", |
| 32 | + "Networks": [ |
| 33 | + { |
| 34 | + "NetworkMode": "awsvpc", |
| 35 | + "IPv4Addresses": ["10.10.10.10"], |
| 36 | + "AttachmentIndex": 0, |
| 37 | + "MACAddress": "06:d7:3f:49:1d:a7", |
| 38 | + "IPv4SubnetCIDRBlock": "10.10.10.0/20", |
| 39 | + "DomainNameServers": ["10.10.10.2"], |
| 40 | + "DomainNameSearchList": ["us-west-2.compute.internal"], |
| 41 | + "PrivateDNSName": "ip-10-10-10-10.us-west-2.compute.internal", |
| 42 | + "SubnetGatewayIpv4Address": "10.10.10.1/20", |
| 43 | + } |
| 44 | + ], |
| 45 | + "Snapshotter": "overlayfs", |
| 46 | +} |
| 47 | + |
| 48 | +NO_ID_RESPONSE = { |
| 49 | + "Name": "fargateapp", |
| 50 | + "DockerName": "fargateapp", |
| 51 | + "Image": "123456789012.dkr.ecr.us-west-2.amazonaws.com/fargatetest:latest", |
| 52 | + "ImageID": "sha256:1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcd", |
| 53 | + "Labels": { |
| 54 | + "com.amazonaws.ecs.cluster": "arn:aws:ecs:us-west-2:123456789012:cluster/testcluster", |
| 55 | + "com.amazonaws.ecs.container-name": "fargateapp", |
| 56 | + "com.amazonaws.ecs.task-arn": "arn:aws:ecs:us-west-2:123456789012:task/testcluster/1e1698469422439ea356071e581e8545", |
| 57 | + "com.amazonaws.ecs.task-definition-family": "fargatetestapp", |
| 58 | + "com.amazonaws.ecs.task-definition-version": "7", |
| 59 | + }, |
| 60 | + "DesiredStatus": "RUNNING", |
| 61 | + "KnownStatus": "RUNNING", |
| 62 | + "Limits": {"CPU": 2}, |
23 | 63 | "CreatedAt": "2024-04-25T17:38:31.073208914Z", |
24 | 64 | "StartedAt": "2024-04-25T17:38:31.073208914Z", |
25 | 65 | "Type": "NORMAL", |
|
28 | 68 | "awslogs-create-group": "true", |
29 | 69 | "awslogs-group": "/ecs/fargatetestapp", |
30 | 70 | "awslogs-region": "us-west-2", |
31 | | - "awslogs-stream": "ecs/fargateapp/1e1698469422439ea356071e581e8545" |
| 71 | + "awslogs-stream": "ecs/fargateapp/1e1698469422439ea356071e581e8545", |
32 | 72 | }, |
33 | 73 | "ContainerARN": "arn:aws:ecs:us-west-2:123456789012:container/testcluster/1e1698469422439ea356071e581e8545/050256a5-a7f3-461c-a16f-aca4eae37b01", |
34 | 74 | "Networks": [ |
35 | 75 | { |
36 | 76 | "NetworkMode": "awsvpc", |
37 | | - "IPv4Addresses": [ |
38 | | - "10.10.10.10" |
39 | | - ], |
| 77 | + "IPv4Addresses": ["10.10.10.10"], |
40 | 78 | "AttachmentIndex": 0, |
41 | 79 | "MACAddress": "06:d7:3f:49:1d:a7", |
42 | 80 | "IPv4SubnetCIDRBlock": "10.10.10.0/20", |
43 | | - "DomainNameServers": [ |
44 | | - "10.10.10.2" |
45 | | - ], |
46 | | - "DomainNameSearchList": [ |
47 | | - "us-west-2.compute.internal" |
48 | | - ], |
| 81 | + "DomainNameServers": ["10.10.10.2"], |
| 82 | + "DomainNameSearchList": ["us-west-2.compute.internal"], |
49 | 83 | "PrivateDNSName": "ip-10-10-10-10.us-west-2.compute.internal", |
50 | | - "SubnetGatewayIpv4Address": "10.10.10.1/20" |
| 84 | + "SubnetGatewayIpv4Address": "10.10.10.1/20", |
51 | 85 | } |
52 | 86 | ], |
53 | | - "Snapshotter": "overlayfs" |
| 87 | + "Snapshotter": "overlayfs", |
54 | 88 | } |
55 | 89 |
|
56 | 90 |
|
57 | 91 | def simple_get(self): |
58 | | - response = json.dumps(STANDARD_RESPONSE).encode('utf-8') |
| 92 | + response = json.dumps(STANDARD_RESPONSE).encode("utf-8") |
59 | 93 | self.send_response(200) |
60 | 94 | self.end_headers() |
61 | 95 | self.wfile.write(response) |
62 | 96 |
|
63 | 97 |
|
64 | | -@pytest.fixture(scope="session") |
| 98 | +def bad_response_get(self): |
| 99 | + response = json.dumps(NO_ID_RESPONSE).encode("utf-8") |
| 100 | + self.send_response(200) |
| 101 | + self.end_headers() |
| 102 | + self.wfile.write(response) |
| 103 | + |
| 104 | + |
| 105 | +@pytest.fixture(scope="function") |
65 | 106 | def mock_server(): |
66 | 107 | with MockExternalHTTPServer(handler=simple_get) as mock_server: |
67 | 108 | yield mock_server |
| 109 | + |
| 110 | + |
| 111 | +@pytest.fixture(scope="function") |
| 112 | +def bad_response_mock_server(): |
| 113 | + with MockExternalHTTPServer(handler=bad_response_get) as bad_response_mock_server: |
| 114 | + yield bad_response_mock_server |
0 commit comments