integration: Fix tests + `gofmt`
This commit is contained in:
parent
284691253f
commit
c2ec73302d
|
@ -6,10 +6,10 @@ import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"golang.org/x/net/http2"
|
|
||||||
"golang.org/x/net/http2/hpack"
|
|
||||||
"github.com/tatsuhiro-t/go-nghttp2"
|
"github.com/tatsuhiro-t/go-nghttp2"
|
||||||
"github.com/tatsuhiro-t/spdy"
|
"github.com/tatsuhiro-t/spdy"
|
||||||
|
"golang.org/x/net/http2"
|
||||||
|
"golang.org/x/net/http2/hpack"
|
||||||
"golang.org/x/net/websocket"
|
"golang.org/x/net/websocket"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
@ -30,7 +30,7 @@ const (
|
||||||
serverBin = buildDir + "/src/nghttpx"
|
serverBin = buildDir + "/src/nghttpx"
|
||||||
serverPort = 3009
|
serverPort = 3009
|
||||||
testDir = sourceDir + "/integration-tests"
|
testDir = sourceDir + "/integration-tests"
|
||||||
logDir = buildDir + "/integration-tests"
|
logDir = buildDir + "/integration-tests"
|
||||||
)
|
)
|
||||||
|
|
||||||
func pair(name, value string) hpack.HeaderField {
|
func pair(name, value string) hpack.HeaderField {
|
||||||
|
@ -86,14 +86,18 @@ func newServerTesterTLSConfig(args []string, t *testing.T, handler http.HandlerF
|
||||||
|
|
||||||
// newServerTesterInternal creates test context. If frontendTLS is
|
// newServerTesterInternal creates test context. If frontendTLS is
|
||||||
// true, set up TLS frontend connection.
|
// true, set up TLS frontend connection.
|
||||||
func newServerTesterInternal(args []string, t *testing.T, handler http.Handler, frontendTLS bool, clientConfig *tls.Config) *serverTester {
|
func newServerTesterInternal(src_args []string, t *testing.T, handler http.Handler, frontendTLS bool, clientConfig *tls.Config) *serverTester {
|
||||||
ts := httptest.NewUnstartedServer(handler)
|
ts := httptest.NewUnstartedServer(handler)
|
||||||
|
|
||||||
|
args := []string{}
|
||||||
|
|
||||||
backendTLS := false
|
backendTLS := false
|
||||||
for _, k := range args {
|
for _, k := range src_args {
|
||||||
switch k {
|
switch k {
|
||||||
case "--http2-bridge":
|
case "--http2-bridge":
|
||||||
backendTLS = true
|
backendTLS = true
|
||||||
|
default:
|
||||||
|
args = append(args, k)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if backendTLS {
|
if backendTLS {
|
||||||
|
@ -102,9 +106,9 @@ func newServerTesterInternal(args []string, t *testing.T, handler http.Handler,
|
||||||
// NextProtos separately for ts.TLS. NextProtos set
|
// NextProtos separately for ts.TLS. NextProtos set
|
||||||
// in nghttp2.ConfigureServer is effectively ignored.
|
// in nghttp2.ConfigureServer is effectively ignored.
|
||||||
ts.TLS = new(tls.Config)
|
ts.TLS = new(tls.Config)
|
||||||
ts.TLS.NextProtos = append(ts.TLS.NextProtos, "h2-14")
|
ts.TLS.NextProtos = append(ts.TLS.NextProtos, "h2")
|
||||||
ts.StartTLS()
|
ts.StartTLS()
|
||||||
args = append(args, "-k")
|
args = append(args, "-k", "--backend-tls")
|
||||||
} else {
|
} else {
|
||||||
ts.Start()
|
ts.Start()
|
||||||
}
|
}
|
||||||
|
@ -124,6 +128,9 @@ func newServerTesterInternal(args []string, t *testing.T, handler http.Handler,
|
||||||
// URL.Host looks like "127.0.0.1:8080", but we want
|
// URL.Host looks like "127.0.0.1:8080", but we want
|
||||||
// "127.0.0.1,8080"
|
// "127.0.0.1,8080"
|
||||||
b := "-b" + strings.Replace(backendURL.Host, ":", ",", -1)
|
b := "-b" + strings.Replace(backendURL.Host, ":", ",", -1)
|
||||||
|
if backendTLS {
|
||||||
|
b += ";;proto=h2"
|
||||||
|
}
|
||||||
args = append(args, fmt.Sprintf("-f127.0.0.1,%v", serverPort), b,
|
args = append(args, fmt.Sprintf("-f127.0.0.1,%v", serverPort), b,
|
||||||
"--errorlog-file="+logDir+"/log.txt", "-LINFO")
|
"--errorlog-file="+logDir+"/log.txt", "-LINFO")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue