@@ -35,44 +35,44 @@ def test_common_container_fixture_configurators(
35
35
]
36
36
)
37
37
38
- with container .start () as running_container :
39
- wait_for_localstack_ready (running_container )
40
- url = get_gateway_url (container )
41
-
42
- # port was exposed correctly
43
- response = requests .get (f"{ url } /_localstack/health" )
44
- assert response .ok
45
-
46
- # volume was mounted and directories were created correctly
47
- assert (volume / "cache" / "machine.json" ).exists ()
48
-
49
- inspect = running_container .inspect ()
50
- # volume was mounted correctly
51
- assert {
52
- "Type" : "bind" ,
53
- "Source" : str (volume ),
54
- "Destination" : "/var/lib/localstack" ,
55
- "Mode" : "" ,
56
- "RW" : True ,
57
- "Propagation" : "rprivate" ,
58
- } in inspect ["Mounts" ]
59
- # docker socket was mounted correctly
60
- assert {
61
- "Type" : "bind" ,
62
- "Source" : "/var/run/docker.sock" ,
63
- "Destination" : "/var/run/docker.sock" ,
64
- "Mode" : "" ,
65
- "RW" : True ,
66
- "Propagation" : "rprivate" ,
67
- } in inspect ["Mounts" ]
68
-
69
- # debug was set
70
- assert "DEBUG=1" in inspect ["Config" ]["Env" ]
71
- # environment variables were set
72
- assert "FOOBAR=foobar" in inspect ["Config" ]["Env" ]
73
- assert "MY_TEST_ENV=test" in inspect ["Config" ]["Env" ]
74
- # container name was set
75
- assert f"MAIN_CONTAINER_NAME={ container .config .name } " in inspect ["Config" ]["Env" ]
38
+ running_container = container .start ()
39
+ wait_for_localstack_ready (running_container )
40
+ url = get_gateway_url (container )
41
+
42
+ # port was exposed correctly
43
+ response = requests .get (f"{ url } /_localstack/health" )
44
+ assert response .ok
45
+
46
+ # volume was mounted and directories were created correctly
47
+ assert (volume / "cache" / "machine.json" ).exists ()
48
+
49
+ inspect = running_container .inspect ()
50
+ # volume was mounted correctly
51
+ assert {
52
+ "Type" : "bind" ,
53
+ "Source" : str (volume ),
54
+ "Destination" : "/var/lib/localstack" ,
55
+ "Mode" : "" ,
56
+ "RW" : True ,
57
+ "Propagation" : "rprivate" ,
58
+ } in inspect ["Mounts" ]
59
+ # docker socket was mounted correctly
60
+ assert {
61
+ "Type" : "bind" ,
62
+ "Source" : "/var/run/docker.sock" ,
63
+ "Destination" : "/var/run/docker.sock" ,
64
+ "Mode" : "" ,
65
+ "RW" : True ,
66
+ "Propagation" : "rprivate" ,
67
+ } in inspect ["Mounts" ]
68
+
69
+ # debug was set
70
+ assert "DEBUG=1" in inspect ["Config" ]["Env" ]
71
+ # environment variables were set
72
+ assert "FOOBAR=foobar" in inspect ["Config" ]["Env" ]
73
+ assert "MY_TEST_ENV=test" in inspect ["Config" ]["Env" ]
74
+ # container name was set
75
+ assert f"MAIN_CONTAINER_NAME={ container .config .name } " in inspect ["Config" ]["Env" ]
76
76
77
77
78
78
def test_custom_command_configurator (container_factory , tmp_path , stream_container_logs ):
@@ -101,9 +101,9 @@ def test_custom_command_configurator(container_factory, tmp_path, stream_contain
101
101
remove = False ,
102
102
)
103
103
104
- with container .start () as running_container :
105
- assert running_container .wait_until_ready (timeout = 5 )
106
- assert running_container .get_logs ().strip () == "foobar\n hello world"
104
+ running_container = container .start ()
105
+ assert running_container .wait_until_ready (timeout = 5 )
106
+ assert running_container .get_logs ().strip () == "foobar\n hello world"
107
107
108
108
109
109
def test_default_localstack_container_configurator (
@@ -125,41 +125,40 @@ def test_default_localstack_container_configurator(
125
125
container : Container = container_factory ()
126
126
configure_container (container )
127
127
128
- with container .start () as running_container :
129
- stream_container_logs (container )
130
- wait_for_localstack_ready (running_container )
131
-
132
- # check startup works correctly
133
- response = requests .get ("http://localhost:4566/_localstack/health" )
134
- assert response .ok
135
-
136
- # check docker-flags was created correctly
137
- response = requests .get ("http://localhost:23456/_localstack/health" )
138
- assert response .ok , "couldn't reach localstack on port 23456 - does DOCKER_FLAGS work?"
139
-
140
- response = requests .get ("http://localhost:4566/_localstack/diagnose" )
141
- assert response .ok , "couldn't reach diagnose endpoint. is DEBUG=1 set?"
142
- diagnose = response .json ()
143
-
144
- # a few smoke tests of important configs
145
- assert diagnose ["config" ]["GATEWAY_LISTEN" ] == ["0.0.0.0:4566" ]
146
- # check that docker-socket was mounted correctly
147
- assert diagnose ["docker-inspect" ], "was the docker socket mounted?"
148
- assert diagnose ["docker-inspect" ]["Config" ]["Image" ] == "localstack/localstack"
149
- assert diagnose ["docker-inspect" ]["Path" ] == "docker-entrypoint.sh"
150
- assert {
151
- "Type" : "bind" ,
152
- "Source" : str (volume ),
153
- "Destination" : "/var/lib/localstack" ,
154
- "Mode" : "" ,
155
- "RW" : True ,
156
- "Propagation" : "rprivate" ,
157
- } in diagnose ["docker-inspect" ]["Mounts" ]
158
-
159
- # from DOCKER_FLAGS
160
- assert "MY_TEST_VAR=foobar" in diagnose ["docker-inspect" ]["Config" ]["Env" ]
161
-
162
- # check that external service ports were mapped correctly
163
- ports = diagnose ["docker-inspect" ]["NetworkSettings" ]["Ports" ]
164
- for port in external_service_ports :
165
- assert ports [f"{ port } /tcp" ] == [{"HostIp" : "127.0.0.1" , "HostPort" : f"{ port } " }]
128
+ stream_container_logs (container )
129
+ wait_for_localstack_ready (container .start ())
130
+
131
+ # check startup works correctly
132
+ response = requests .get ("http://localhost:4566/_localstack/health" )
133
+ assert response .ok
134
+
135
+ # check docker-flags was created correctly
136
+ response = requests .get ("http://localhost:23456/_localstack/health" )
137
+ assert response .ok , "couldn't reach localstack on port 23456 - does DOCKER_FLAGS work?"
138
+
139
+ response = requests .get ("http://localhost:4566/_localstack/diagnose" )
140
+ assert response .ok , "couldn't reach diagnose endpoint. is DEBUG=1 set?"
141
+ diagnose = response .json ()
142
+
143
+ # a few smoke tests of important configs
144
+ assert diagnose ["config" ]["GATEWAY_LISTEN" ] == ["0.0.0.0:4566" ]
145
+ # check that docker-socket was mounted correctly
146
+ assert diagnose ["docker-inspect" ], "was the docker socket mounted?"
147
+ assert diagnose ["docker-inspect" ]["Config" ]["Image" ] == "localstack/localstack"
148
+ assert diagnose ["docker-inspect" ]["Path" ] == "docker-entrypoint.sh"
149
+ assert {
150
+ "Type" : "bind" ,
151
+ "Source" : str (volume ),
152
+ "Destination" : "/var/lib/localstack" ,
153
+ "Mode" : "" ,
154
+ "RW" : True ,
155
+ "Propagation" : "rprivate" ,
156
+ } in diagnose ["docker-inspect" ]["Mounts" ]
157
+
158
+ # from DOCKER_FLAGS
159
+ assert "MY_TEST_VAR=foobar" in diagnose ["docker-inspect" ]["Config" ]["Env" ]
160
+
161
+ # check that external service ports were mapped correctly
162
+ ports = diagnose ["docker-inspect" ]["NetworkSettings" ]["Ports" ]
163
+ for port in external_service_ports :
164
+ assert ports [f"{ port } /tcp" ] == [{"HostIp" : "127.0.0.1" , "HostPort" : f"{ port } " }]
0 commit comments