Skip to content

Commit 3fba644

Browse files
cover
Signed-off-by: Adrian Cole <[email protected]>
1 parent 7516c6c commit 3fba644

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

internal/infrastructure/host/proxy_infra_test.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,53 @@ func TestInfra_runEnvoy_stopEnvoy(t *testing.T) {
124124
}
125125
}
126126

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

0 commit comments

Comments
 (0)