Skip to content

Commit 4a2d37e

Browse files
committed
http2: remove Docker-requiring tests
Remove two tests, one of which uses curl and the other which uses h2load. These tests don't seem worth the complexity of keeping around a Dockerfile and curl/h2load dependencies. Change-Id: I0370af061168e46d8110fa40eba8dabe68acecc3 Reviewed-on: https://go-review.googlesource.com/c/net/+/514597 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
1 parent efb8d7a commit 4a2d37e

File tree

4 files changed

+0
-208
lines changed

4 files changed

+0
-208
lines changed

http2/Dockerfile

-51
This file was deleted.

http2/Makefile

-3
This file was deleted.

http2/http2_test.go

-62
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,13 @@ package http2
66

77
import (
88
"bytes"
9-
"errors"
109
"flag"
1110
"fmt"
1211
"io/ioutil"
1312
"net/http"
1413
"os"
15-
"os/exec"
1614
"path/filepath"
1715
"regexp"
18-
"strconv"
1916
"strings"
2017
"testing"
2118
"time"
@@ -85,44 +82,6 @@ func encodeHeaderNoImplicit(t *testing.T, headers ...string) []byte {
8582
return buf.Bytes()
8683
}
8784

88-
// Verify that curl has http2.
89-
func requireCurl(t *testing.T) {
90-
out, err := dockerLogs(curl(t, "--version"))
91-
if err != nil {
92-
t.Skipf("failed to determine curl features; skipping test")
93-
}
94-
if !strings.Contains(string(out), "HTTP2") {
95-
t.Skip("curl doesn't support HTTP2; skipping test")
96-
}
97-
}
98-
99-
func curl(t *testing.T, args ...string) (container string) {
100-
out, err := exec.Command("docker", append([]string{"run", "-d", "--net=host", "gohttp2/curl"}, args...)...).Output()
101-
if err != nil {
102-
t.Skipf("Failed to run curl in docker: %v, %s", err, out)
103-
}
104-
return strings.TrimSpace(string(out))
105-
}
106-
107-
// Verify that h2load exists.
108-
func requireH2load(t *testing.T) {
109-
out, err := dockerLogs(h2load(t, "--version"))
110-
if err != nil {
111-
t.Skipf("failed to probe h2load; skipping test: %s", out)
112-
}
113-
if !strings.Contains(string(out), "h2load nghttp2/") {
114-
t.Skipf("h2load not present; skipping test. (Output=%q)", out)
115-
}
116-
}
117-
118-
func h2load(t *testing.T, args ...string) (container string) {
119-
out, err := exec.Command("docker", append([]string{"run", "-d", "--net=host", "--entrypoint=/usr/local/bin/h2load", "gohttp2/curl"}, args...)...).Output()
120-
if err != nil {
121-
t.Skipf("Failed to run h2load in docker: %v, %s", err, out)
122-
}
123-
return strings.TrimSpace(string(out))
124-
}
125-
12685
type puppetCommand struct {
12786
fn func(w http.ResponseWriter, r *http.Request)
12887
done chan<- bool
@@ -151,27 +110,6 @@ func (p *handlerPuppet) do(fn func(http.ResponseWriter, *http.Request)) {
151110
p.ch <- puppetCommand{fn, done}
152111
<-done
153112
}
154-
func dockerLogs(container string) ([]byte, error) {
155-
out, err := exec.Command("docker", "wait", container).CombinedOutput()
156-
if err != nil {
157-
return out, err
158-
}
159-
exitStatus, err := strconv.Atoi(strings.TrimSpace(string(out)))
160-
if err != nil {
161-
return out, errors.New("unexpected exit status from docker wait")
162-
}
163-
out, err = exec.Command("docker", "logs", container).CombinedOutput()
164-
exec.Command("docker", "rm", container).Run()
165-
if err == nil && exitStatus != 0 {
166-
err = fmt.Errorf("exit status %d: %s", exitStatus, out)
167-
}
168-
return out, err
169-
}
170-
171-
func kill(container string) {
172-
exec.Command("docker", "kill", container).Run()
173-
exec.Command("docker", "rm", container).Run()
174-
}
175113

176114
func cleanDate(res *http.Response) {
177115
if d := res.Header["Date"]; len(d) == 1 {

http2/server_test.go

-92
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,11 @@ import (
2020
"net/http"
2121
"net/http/httptest"
2222
"os"
23-
"os/exec"
2423
"reflect"
2524
"runtime"
2625
"strconv"
2726
"strings"
2827
"sync"
29-
"sync/atomic"
3028
"testing"
3129
"time"
3230

@@ -2704,96 +2702,6 @@ func readBodyHandler(t *testing.T, want string) func(w http.ResponseWriter, r *h
27042702
}
27052703
}
27062704

2707-
// TestServerWithCurl currently fails, hence the LenientCipherSuites test. See:
2708-
//
2709-
// https://github.com/tatsuhiro-t/nghttp2/issues/140 &
2710-
// http://sourceforge.net/p/curl/bugs/1472/
2711-
func TestServerWithCurl(t *testing.T) { testServerWithCurl(t, false) }
2712-
func TestServerWithCurl_LenientCipherSuites(t *testing.T) { testServerWithCurl(t, true) }
2713-
2714-
func testServerWithCurl(t *testing.T, permitProhibitedCipherSuites bool) {
2715-
if runtime.GOOS != "linux" {
2716-
t.Skip("skipping Docker test when not on Linux; requires --net which won't work with boot2docker anyway")
2717-
}
2718-
if testing.Short() {
2719-
t.Skip("skipping curl test in short mode")
2720-
}
2721-
requireCurl(t)
2722-
var gotConn int32
2723-
testHookOnConn = func() { atomic.StoreInt32(&gotConn, 1) }
2724-
2725-
const msg = "Hello from curl!\n"
2726-
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2727-
w.Header().Set("Foo", "Bar")
2728-
w.Header().Set("Client-Proto", r.Proto)
2729-
io.WriteString(w, msg)
2730-
}))
2731-
ConfigureServer(ts.Config, &Server{
2732-
PermitProhibitedCipherSuites: permitProhibitedCipherSuites,
2733-
})
2734-
ts.TLS = ts.Config.TLSConfig // the httptest.Server has its own copy of this TLS config
2735-
ts.StartTLS()
2736-
defer ts.Close()
2737-
2738-
t.Logf("Running test server for curl to hit at: %s", ts.URL)
2739-
container := curl(t, "--silent", "--http2", "--insecure", "-v", ts.URL)
2740-
defer kill(container)
2741-
res, err := dockerLogs(container)
2742-
if err != nil {
2743-
t.Fatal(err)
2744-
}
2745-
2746-
body := string(res)
2747-
// Search for both "key: value" and "key:value", since curl changed their format
2748-
// Our Dockerfile contains the latest version (no space), but just in case people
2749-
// didn't rebuild, check both.
2750-
if !strings.Contains(body, "foo: Bar") && !strings.Contains(body, "foo:Bar") {
2751-
t.Errorf("didn't see foo: Bar header")
2752-
t.Logf("Got: %s", body)
2753-
}
2754-
if !strings.Contains(body, "client-proto: HTTP/2") && !strings.Contains(body, "client-proto:HTTP/2") {
2755-
t.Errorf("didn't see client-proto: HTTP/2 header")
2756-
t.Logf("Got: %s", res)
2757-
}
2758-
if !strings.Contains(string(res), msg) {
2759-
t.Errorf("didn't see %q content", msg)
2760-
t.Logf("Got: %s", res)
2761-
}
2762-
2763-
if atomic.LoadInt32(&gotConn) == 0 {
2764-
t.Error("never saw an http2 connection")
2765-
}
2766-
}
2767-
2768-
var doh2load = flag.Bool("h2load", false, "Run h2load test")
2769-
2770-
func TestServerWithH2Load(t *testing.T) {
2771-
if !*doh2load {
2772-
t.Skip("Skipping without --h2load flag.")
2773-
}
2774-
if runtime.GOOS != "linux" {
2775-
t.Skip("skipping Docker test when not on Linux; requires --net which won't work with boot2docker anyway")
2776-
}
2777-
requireH2load(t)
2778-
2779-
msg := strings.Repeat("Hello, h2load!\n", 5000)
2780-
ts := httptest.NewUnstartedServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
2781-
io.WriteString(w, msg)
2782-
w.(http.Flusher).Flush()
2783-
io.WriteString(w, msg)
2784-
}))
2785-
ts.StartTLS()
2786-
defer ts.Close()
2787-
2788-
cmd := exec.Command("docker", "run", "--net=host", "--entrypoint=/usr/local/bin/h2load", "gohttp2/curl",
2789-
"-n100000", "-c100", "-m100", ts.URL)
2790-
cmd.Stdout = os.Stdout
2791-
cmd.Stderr = os.Stderr
2792-
if err := cmd.Run(); err != nil {
2793-
t.Fatal(err)
2794-
}
2795-
}
2796-
27972705
func TestServer_MaxDecoderHeaderTableSize(t *testing.T) {
27982706
wantHeaderTableSize := uint32(initialHeaderTableSize * 2)
27992707
st := newServerTester(t, func(w http.ResponseWriter, r *http.Request) {}, func(s *Server) {

0 commit comments

Comments
 (0)