fix passing of the quic.Config in the interop client

This commit is contained in:
Marten Seemann
2020-02-27 16:25:58 +07:00
parent d53c75f05f
commit 99292576ca
2 changed files with 22 additions and 21 deletions

View File

@@ -67,25 +67,13 @@ func runTestcase(testcase string) error {
} }
quicConf := &quic.Config{GetLogWriter: getLogWriter} quicConf := &quic.Config{GetLogWriter: getLogWriter}
switch testcase { if testcase == "http3" {
case "http3":
r := &http3.RoundTripper{ r := &http3.RoundTripper{
TLSClientConfig: tlsConf, TLSClientConfig: tlsConf,
QuicConfig: quicConf, QuicConfig: quicConf,
} }
defer r.Close() defer r.Close()
return downloadFiles(r, urls, false) return downloadFiles(r, urls, false)
case "handshake", "transfer", "retry":
case "multiconnect":
return runMultiConnectTest(urls)
case "versionnegotiation":
return runVersionNegotiationTest(urls)
case "resumption":
return runResumptionTest(urls, false)
case "zerortt":
return runResumptionTest(urls, true)
default:
return errUnsupported
} }
r := &http09.RoundTripper{ r := &http09.RoundTripper{
@@ -93,15 +81,30 @@ func runTestcase(testcase string) error {
QuicConfig: quicConf, QuicConfig: quicConf,
} }
defer r.Close() defer r.Close()
switch testcase {
case "handshake", "transfer", "retry":
case "multiconnect":
return runMultiConnectTest(r, urls)
case "versionnegotiation":
return runVersionNegotiationTest(r, urls)
case "resumption":
return runResumptionTest(r, urls, false)
case "zerortt":
return runResumptionTest(r, urls, true)
default:
return errUnsupported
}
return downloadFiles(r, urls, false) return downloadFiles(r, urls, false)
} }
func runVersionNegotiationTest(urls []string) error { func runVersionNegotiationTest(r *http09.RoundTripper, urls []string) error {
if len(urls) != 1 { if len(urls) != 1 {
return errors.New("expected at least 2 URLs") return errors.New("expected at least 2 URLs")
} }
protocol.SupportedVersions = []protocol.VersionNumber{0x1a2a3a4a} protocol.SupportedVersions = []protocol.VersionNumber{0x1a2a3a4a}
err := downloadFile(&http09.RoundTripper{}, urls[0], false) err := downloadFile(r, urls[0], false)
if err == nil { if err == nil {
return errors.New("expected version negotiation to fail") return errors.New("expected version negotiation to fail")
} }
@@ -111,9 +114,8 @@ func runVersionNegotiationTest(urls []string) error {
return nil return nil
} }
func runMultiConnectTest(urls []string) error { func runMultiConnectTest(r *http09.RoundTripper, urls []string) error {
for _, url := range urls { for _, url := range urls {
r := &http09.RoundTripper{TLSClientConfig: tlsConf}
if err := downloadFile(r, url, false); err != nil { if err := downloadFile(r, url, false); err != nil {
return err return err
} }
@@ -124,7 +126,7 @@ func runMultiConnectTest(urls []string) error {
return nil return nil
} }
func runResumptionTest(urls []string, use0RTT bool) error { func runResumptionTest(r *http09.RoundTripper, urls []string, use0RTT bool) error {
if len(urls) < 2 { if len(urls) < 2 {
return errors.New("expected at least 2 URLs") return errors.New("expected at least 2 URLs")
} }
@@ -132,14 +134,12 @@ func runResumptionTest(urls []string, use0RTT bool) error {
tlsConf.ClientSessionCache = tls.NewLRUClientSessionCache(1) tlsConf.ClientSessionCache = tls.NewLRUClientSessionCache(1)
// do the first transfer // do the first transfer
r := &http09.RoundTripper{TLSClientConfig: tlsConf}
if err := downloadFiles(r, urls[:1], false); err != nil { if err := downloadFiles(r, urls[:1], false); err != nil {
return err return err
} }
r.Close() r.Close()
// reestablish the connection, using the session ticket that the server (hopefully provided) // reestablish the connection, using the session ticket that the server (hopefully provided)
r = &http09.RoundTripper{TLSClientConfig: tlsConf}
defer r.Close() defer r.Close()
return downloadFiles(r, urls[1:], use0RTT) return downloadFiles(r, urls[1:], use0RTT)
} }

View File

@@ -66,10 +66,11 @@ func (r *RoundTripper) Close() error {
r.mutex.Lock() r.mutex.Lock()
defer r.mutex.Unlock() defer r.mutex.Unlock()
for _, c := range r.clients { for id, c := range r.clients {
if err := c.Close(); err != nil { if err := c.Close(); err != nil {
return err return err
} }
delete(r.clients, id)
} }
return nil return nil
} }