@@ -126,6 +126,53 @@ func TestInfra_runEnvoy_stopEnvoy(t *testing.T) {
126126 }
127127}
128128
129+ func TestInfra_Close (t * testing.T ) {
130+ tmpdir := t .TempDir ()
131+ // Ensures that all the required binaries are available.
132+ err := func_e .Run (t .Context (), []string {"--version" }, api .HomeDir (tmpdir ))
133+ require .NoError (t , err )
134+
135+ stdout := & bytes.Buffer {}
136+ stderr := & bytes.Buffer {}
137+ i := & Infra {
138+ HomeDir : tmpdir ,
139+ Logger : logging .DefaultLogger (stdout , egv1a1 .LogLevelInfo ),
140+ Stdout : stdout ,
141+ Stderr : stderr ,
142+ }
143+
144+ // Start multiple proxies
145+ ports := []string {"9901" , "9902" , "9903" }
146+ for idx := range 3 {
147+ args := []string {
148+ "--config-yaml" ,
149+ "admin: {address: {socket_address: {address: '127.0.0.1', port_value: " + ports [idx ] + "}}}" ,
150+ }
151+ name := "test-" + ports [idx ]
152+ i .runEnvoy (t .Context (), "" , name , args )
153+ }
154+
155+ // Verify all proxies are running
156+ count := 0
157+ i .proxyContextMap .Range (func (key , value interface {}) bool {
158+ count ++
159+ return true
160+ })
161+ require .Equal (t , 3 , count , "expected 3 proxies to be running" )
162+
163+ // Close should stop all proxies
164+ err = i .Close ()
165+ require .NoError (t , err )
166+
167+ // Verify all proxies are stopped
168+ count = 0
169+ i .proxyContextMap .Range (func (key , value interface {}) bool {
170+ count ++
171+ return true
172+ })
173+ require .Equal (t , 0 , count , "expected all proxies to be stopped" )
174+ }
175+
129176func TestExtractSemver (t * testing.T ) {
130177 tests := []struct {
131178 image string
0 commit comments