diff options
author | feistel <6742251-feistel@users.noreply.gitlab.com> | 2022-05-30 00:52:55 +0300 |
---|---|---|
committer | feistel <6742251-feistel@users.noreply.gitlab.com> | 2022-05-30 00:52:55 +0300 |
commit | 224025547ace9ee83b1cb154728ab825f92ea297 (patch) | |
tree | 238f9501ec7315dc3be0f963218e461790829035 /test/acceptance/helpers_test.go | |
parent | 2da055bf835b14238360754753e42c384ac98988 (diff) |
Add acceptance tests for socket listeners
Diffstat (limited to 'test/acceptance/helpers_test.go')
-rw-r--r-- | test/acceptance/helpers_test.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/acceptance/helpers_test.go b/test/acceptance/helpers_test.go index 8a81553d..0ac4a40b 100644 --- a/test/acceptance/helpers_test.go +++ b/test/acceptance/helpers_test.go @@ -151,11 +151,23 @@ func (l ListenSpec) httpsDialContext() dialContext { } } +func (l ListenSpec) unixSocketDialContext() dialContext { + return func(ctx context.Context, _, _ string) (net.Conn, error) { + var d net.Dialer + + return d.DialContext(ctx, "unix", l.Host) + } +} + func (l ListenSpec) dialContext() dialContext { if l.Type == "https-proxyv2" { return l.proxyV2DialContext() } + if l.Type == "unix" { + return l.unixSocketDialContext() + } + return l.httpsDialContext() } @@ -213,6 +225,15 @@ func (l ListenSpec) WaitUntilRequestSucceeds(done chan struct{}) error { } func (l ListenSpec) JoinHostPort() string { + if l.Type == "unix" { + // The dialer ignores the addr parameter and uses + // the socket path directly. + // This is a stub used by ListenSpec#URL() + // ListenSpec.Host cannot be used because it is + // not a valid hostname. + return "unix" + } + return net.JoinHostPort(l.Host, l.Port) } @@ -328,6 +349,11 @@ func getPagesArgs(t *testing.T, listeners []ListenSpec, promPort string, extraAr args = append(args, "-log-verbose=true") for _, spec := range listeners { + if spec.Type == "unix" { + args = append(args, "-listen-http", spec.Host) + continue + } + args = append(args, "-listen-"+spec.Type, spec.JoinHostPort()) if strings.Contains(spec.Type, request.SchemeHTTPS) { |