4242
4343# Global constants used in tests
4444APP_NAME = "test_app"
45- IP_ADDRESS = AWS = AZURE = GCP = PCF = BOOT_ID = DOCKER = KUBERNETES = None
45+ IP_ADDRESS = AWS = AZURE = ECS = GCP = PCF = BOOT_ID = DOCKER = KUBERNETES = None
4646BROWSER_MONITORING_DEBUG = "debug"
4747BROWSER_MONITORING_LOADER = "loader"
4848CAPTURE_PARAMS = "capture_params"
@@ -117,9 +117,10 @@ def clear_sent_values():
117117
118118@pytest .fixture (autouse = True )
119119def override_utilization (monkeypatch ):
120- global AWS , AZURE , GCP , PCF , BOOT_ID , DOCKER , KUBERNETES
120+ global AWS , AZURE , ECS , GCP , PCF , BOOT_ID , DOCKER , KUBERNETES
121121 AWS = {"id" : "foo" , "type" : "bar" , "zone" : "baz" }
122122 AZURE = {"location" : "foo" , "name" : "bar" , "vmId" : "baz" , "vmSize" : "boo" }
123+ ECS = {"ecsDockerId" : "foobar" }
123124 GCP = {"id" : 1 , "machineType" : "trmntr-t1000" , "name" : "arnold" , "zone" : "abc" }
124125 PCF = {"cf_instance_guid" : "1" , "cf_instance_ip" : "7" , "memory_limit" : "0" }
125126 BOOT_ID = "cca356a7d72737f645a10c122ebbe906"
@@ -134,8 +135,12 @@ def detect(cls):
134135 output = BOOT_ID
135136 elif name .startswith ("AWS" ):
136137 output = AWS
138+ elif name .startswith ("ECS" ):
139+ output = ECS
137140 elif name .startswith ("Azure" ):
138141 output = AZURE
142+ elif name .startswith ("ECS" ):
143+ output = ECS
139144 elif name .startswith ("GCP" ):
140145 output = GCP
141146 elif name .startswith ("PCF" ):
@@ -290,6 +295,7 @@ def test_close_connection():
290295def connect_payload_asserts (
291296 payload ,
292297 with_aws = True ,
298+ with_ecs = True ,
293299 with_gcp = True ,
294300 with_pcf = True ,
295301 with_azure = True ,
@@ -332,7 +338,7 @@ def connect_payload_asserts(
332338 else :
333339 assert "ip_address" not in payload_data ["utilization" ]
334340
335- utilization_len = utilization_len + any ([with_aws , with_pcf , with_gcp , with_azure , with_docker , with_kubernetes ])
341+ utilization_len = utilization_len + any ([with_aws , with_ecs , with_pcf , with_gcp , with_azure , with_docker , with_kubernetes ])
336342 assert len (payload_data ["utilization" ]) == utilization_len
337343 assert payload_data ["utilization" ]["hostname" ] == HOST
338344
@@ -349,11 +355,13 @@ def connect_payload_asserts(
349355 assert harvest_limits ["error_event_data" ] == ERROR_EVENT_DATA
350356
351357 vendors_len = 0
352-
353358 if any ([with_aws , with_pcf , with_gcp , with_azure ]):
354359 vendors_len += 1
355360
356- if with_docker :
361+ if with_ecs :
362+ vendors_len += 1
363+
364+ if with_docker and not with_ecs :
357365 vendors_len += 1
358366
359367 if with_kubernetes :
@@ -372,7 +380,10 @@ def connect_payload_asserts(
372380 elif with_azure :
373381 assert payload_data ["utilization" ]["vendors" ]["azure" ] == AZURE
374382
375- if with_docker :
383+ if with_ecs :
384+ assert payload_data ["utilization" ]["vendors" ]["ecs" ] == ECS
385+
386+ if with_docker and not with_ecs :
376387 assert payload_data ["utilization" ]["vendors" ]["docker" ] == DOCKER
377388
378389 if with_kubernetes :
@@ -382,24 +393,25 @@ def connect_payload_asserts(
382393
383394
384395@pytest .mark .parametrize (
385- "with_aws,with_pcf,with_gcp,with_azure,with_docker,with_kubernetes,with_ip" ,
396+ "with_aws,with_ecs, with_pcf,with_gcp,with_azure,with_docker,with_kubernetes,with_ip" ,
386397 [
387- (False , False , False , False , False , False , False ),
388- (False , False , False , False , False , False , True ),
389- (True , False , False , False , True , True , True ),
390- (False , True , False , False , True , True , True ),
391- (False , False , True , False , True , True , True ),
392- (False , False , False , True , True , True , True ),
393- (True , False , False , False , False , False , True ),
394- (False , True , False , False , False , False , True ),
395- (False , False , True , False , False , False , True ),
396- (False , False , False , True , False , False , True ),
397- (True , True , True , True , True , True , True ),
398- (True , True , True , True , True , False , True ),
399- (True , True , True , True , False , True , True ),
398+ (False , False , False , False , False , False , False , False ),
399+ (False , False , False , False , False , False , False , True ),
400+ (True , True , False , False , False , True , False , True ),
401+ (True , True , False , False , False , True , True , True ),
402+ (False , False , True , False , False , True , True , True ),
403+ (False , False , False , True , False , True , True , True ),
404+ (False , False , False , False , True , True , True , True ),
405+ (True , True , False , False , False , False , False , True ),
406+ (False , False , True , False , False , False , False , True ),
407+ (False , False , False , True , False , False , False , True ),
408+ (False , False , False , False , True , False , False , True ),
409+ (True , True , True , True , True , True , True , True ),
410+ (True , True , True , True , True , True , False , True ),
411+ (True , True , True , True , True , False , True , True ),
400412 ],
401413)
402- def test_connect (with_aws , with_pcf , with_gcp , with_azure , with_docker , with_kubernetes , with_ip ):
414+ def test_connect (with_aws , with_ecs , with_pcf , with_gcp , with_azure , with_docker , with_kubernetes , with_ip ):
403415 global AWS , AZURE , GCP , PCF , BOOT_ID , DOCKER , KUBERNETES , IP_ADDRESS
404416 if not with_aws :
405417 AWS = Exception
@@ -409,6 +421,8 @@ def test_connect(with_aws, with_pcf, with_gcp, with_azure, with_docker, with_kub
409421 GCP = Exception
410422 if not with_azure :
411423 AZURE = Exception
424+ if not with_ecs :
425+ ECS = Exception
412426 if not with_docker :
413427 DOCKER = Exception
414428 if not with_kubernetes :
@@ -466,6 +480,7 @@ def test_connect(with_aws, with_pcf, with_gcp, with_azure, with_docker, with_kub
466480 with_pcf = with_pcf ,
467481 with_gcp = with_gcp ,
468482 with_azure = with_azure ,
483+ with_ecs = with_ecs ,
469484 with_docker = with_docker ,
470485 with_kubernetes = with_kubernetes ,
471486 )
0 commit comments