4141
4242# Global constants used in tests
4343APP_NAME = "test_app"
44- IP_ADDRESS = AWS = AZURE = GCP = PCF = BOOT_ID = DOCKER = KUBERNETES = None
44+ IP_ADDRESS = AWS = AZURE = ECS = GCP = PCF = BOOT_ID = DOCKER = KUBERNETES = None
4545BROWSER_MONITORING_DEBUG = "debug"
4646BROWSER_MONITORING_LOADER = "loader"
4747CAPTURE_PARAMS = "capture_params"
@@ -116,9 +116,10 @@ def clear_sent_values():
116116
117117@pytest .fixture (autouse = True )
118118def override_utilization (monkeypatch ):
119- global AWS , AZURE , GCP , PCF , BOOT_ID , DOCKER , KUBERNETES
119+ global AWS , AZURE , ECS , GCP , PCF , BOOT_ID , DOCKER , KUBERNETES
120120 AWS = {"id" : "foo" , "type" : "bar" , "zone" : "baz" }
121121 AZURE = {"location" : "foo" , "name" : "bar" , "vmId" : "baz" , "vmSize" : "boo" }
122+ ECS = {"ecsDockerId" : "foobar" }
122123 GCP = {"id" : 1 , "machineType" : "trmntr-t1000" , "name" : "arnold" , "zone" : "abc" }
123124 PCF = {"cf_instance_guid" : "1" , "cf_instance_ip" : "7" , "memory_limit" : "0" }
124125 BOOT_ID = "cca356a7d72737f645a10c122ebbe906"
@@ -133,8 +134,12 @@ def detect(cls):
133134 output = BOOT_ID
134135 elif name .startswith ("AWS" ):
135136 output = AWS
137+ elif name .startswith ("ECS" ):
138+ output = ECS
136139 elif name .startswith ("Azure" ):
137140 output = AZURE
141+ elif name .startswith ("ECS" ):
142+ output = ECS
138143 elif name .startswith ("GCP" ):
139144 output = GCP
140145 elif name .startswith ("PCF" ):
@@ -289,6 +294,7 @@ def test_close_connection():
289294def connect_payload_asserts (
290295 payload ,
291296 with_aws = True ,
297+ with_ecs = True ,
292298 with_gcp = True ,
293299 with_pcf = True ,
294300 with_azure = True ,
@@ -326,7 +332,7 @@ def connect_payload_asserts(
326332 else :
327333 assert "ip_address" not in payload_data ["utilization" ]
328334
329- utilization_len = utilization_len + any ([with_aws , with_pcf , with_gcp , with_azure , with_docker , with_kubernetes ])
335+ utilization_len = utilization_len + any ([with_aws , with_ecs , with_pcf , with_gcp , with_azure , with_docker , with_kubernetes ])
330336 assert len (payload_data ["utilization" ]) == utilization_len
331337 assert payload_data ["utilization" ]["hostname" ] == HOST
332338
@@ -343,11 +349,13 @@ def connect_payload_asserts(
343349 assert harvest_limits ["error_event_data" ] == ERROR_EVENT_DATA
344350
345351 vendors_len = 0
346-
347352 if any ([with_aws , with_pcf , with_gcp , with_azure ]):
348353 vendors_len += 1
349354
350- if with_docker :
355+ if with_ecs :
356+ vendors_len += 1
357+
358+ if with_docker and not with_ecs :
351359 vendors_len += 1
352360
353361 if with_kubernetes :
@@ -366,7 +374,10 @@ def connect_payload_asserts(
366374 elif with_azure :
367375 assert payload_data ["utilization" ]["vendors" ]["azure" ] == AZURE
368376
369- if with_docker :
377+ if with_ecs :
378+ assert payload_data ["utilization" ]["vendors" ]["ecs" ] == ECS
379+
380+ if with_docker and not with_ecs :
370381 assert payload_data ["utilization" ]["vendors" ]["docker" ] == DOCKER
371382
372383 if with_kubernetes :
@@ -376,24 +387,25 @@ def connect_payload_asserts(
376387
377388
378389@pytest .mark .parametrize (
379- "with_aws,with_pcf,with_gcp,with_azure,with_docker,with_kubernetes,with_ip" ,
390+ "with_aws,with_ecs, with_pcf,with_gcp,with_azure,with_docker,with_kubernetes,with_ip" ,
380391 [
381- (False , False , False , False , False , False , False ),
382- (False , False , False , False , False , False , True ),
383- (True , False , False , False , True , True , True ),
384- (False , True , False , False , True , True , True ),
385- (False , False , True , False , True , True , True ),
386- (False , False , False , True , True , True , True ),
387- (True , False , False , False , False , False , True ),
388- (False , True , False , False , False , False , True ),
389- (False , False , True , False , False , False , True ),
390- (False , False , False , True , False , False , True ),
391- (True , True , True , True , True , True , True ),
392- (True , True , True , True , True , False , True ),
393- (True , True , True , True , False , True , True ),
392+ (False , False , False , False , False , False , False , False ),
393+ (False , False , False , False , False , False , False , True ),
394+ (True , True , False , False , False , True , False , True ),
395+ (True , True , False , False , False , True , True , True ),
396+ (False , False , True , False , False , True , True , True ),
397+ (False , False , False , True , False , True , True , True ),
398+ (False , False , False , False , True , True , True , True ),
399+ (True , True , False , False , False , False , False , True ),
400+ (False , False , True , False , False , False , False , True ),
401+ (False , False , False , True , False , False , False , True ),
402+ (False , False , False , False , True , False , False , True ),
403+ (True , True , True , True , True , True , True , True ),
404+ (True , True , True , True , True , True , False , True ),
405+ (True , True , True , True , True , False , True , True ),
394406 ],
395407)
396- def test_connect (with_aws , with_pcf , with_gcp , with_azure , with_docker , with_kubernetes , with_ip ):
408+ def test_connect (with_aws , with_ecs , with_pcf , with_gcp , with_azure , with_docker , with_kubernetes , with_ip ):
397409 global AWS , AZURE , GCP , PCF , BOOT_ID , DOCKER , KUBERNETES , IP_ADDRESS
398410 if not with_aws :
399411 AWS = Exception
@@ -403,6 +415,8 @@ def test_connect(with_aws, with_pcf, with_gcp, with_azure, with_docker, with_kub
403415 GCP = Exception
404416 if not with_azure :
405417 AZURE = Exception
418+ if not with_ecs :
419+ ECS = Exception
406420 if not with_docker :
407421 DOCKER = Exception
408422 if not with_kubernetes :
@@ -460,6 +474,7 @@ def test_connect(with_aws, with_pcf, with_gcp, with_azure, with_docker, with_kub
460474 with_pcf = with_pcf ,
461475 with_gcp = with_gcp ,
462476 with_azure = with_azure ,
477+ with_ecs = with_ecs ,
463478 with_docker = with_docker ,
464479 with_kubernetes = with_kubernetes ,
465480 )
0 commit comments