Compare commits
1
Commits
next
...
b8edfcec37
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b8edfcec37 |
+4
-1
@@ -29,7 +29,10 @@ RUN go mod download
|
|||||||
|
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
RUN go test -count=1 -timeout 90s -race -cover ./... || \
|
# Go's build cache is kept on a tmpfs, out of the image: nothing uses it
|
||||||
|
# after this step, and writing it into the image takes seconds.
|
||||||
|
RUN --mount=type=tmpfs,target=/root/.cache/go-build \
|
||||||
|
go test -count=1 -timeout 90s -race -cover ./... || \
|
||||||
{ echo "--- Rerunning with -v for details ---"; \
|
{ echo "--- Rerunning with -v for details ---"; \
|
||||||
go test -count=1 -timeout 90s -race -v ./...; exit 1; }
|
go test -count=1 -timeout 90s -race -v ./...; exit 1; }
|
||||||
|
|
||||||
|
|||||||
@@ -233,6 +233,7 @@ func TestUpgradedConnectionOutlastsTheTimeouts(t *testing.T) {
|
|||||||
send(t, conn, "GET /socket HTTP/1.1\r\nHost: app\r\n"+
|
send(t, conn, "GET /socket HTTP/1.1\r\nHost: app\r\n"+
|
||||||
"Connection: Upgrade\r\nUpgrade: websocket\r\n\r\n")
|
"Connection: Upgrade\r\nUpgrade: websocket\r\n\r\n")
|
||||||
|
|
||||||
|
sent := time.Now()
|
||||||
reader := bufio.NewReader(conn)
|
reader := bufio.NewReader(conn)
|
||||||
|
|
||||||
res, err := http.ReadResponse(reader, nil)
|
res, err := http.ReadResponse(reader, nil)
|
||||||
@@ -246,9 +247,10 @@ func TestUpgradedConnectionOutlastsTheTimeouts(t *testing.T) {
|
|||||||
t.Fatalf("status %d, want %d", res.StatusCode, http.StatusSwitchingProtocols)
|
t.Fatalf("status %d, want %d", res.StatusCode, http.StatusSwitchingProtocols)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Every timeout started before the upgrade was answered: wait past
|
// Every timeout started by the time smallwebwaf read the request:
|
||||||
// them all, then use the connection.
|
// wait until just past shortTimeout after it was sent, then use the
|
||||||
time.Sleep(3 * shortTimeout / 2)
|
// connection.
|
||||||
|
time.Sleep(time.Until(sent.Add(shortTimeout + 100*time.Millisecond)))
|
||||||
send(t, conn, "still here\n")
|
send(t, conn, "still here\n")
|
||||||
|
|
||||||
echoed, err := reader.ReadString('\n')
|
echoed, err := reader.ReadString('\n')
|
||||||
|
|||||||
@@ -23,9 +23,9 @@ const (
|
|||||||
// shortTimeout is what a test sets a timeout to, to see it run out.
|
// shortTimeout is what a test sets a timeout to, to see it run out.
|
||||||
// It starts before the test has set up its case, such as an upgrade
|
// It starts before the test has set up its case, such as an upgrade
|
||||||
// or the app's buffers filling, so it is as long as the hold-up of the
|
// or the app's buffers filling, so it is as long as the hold-up of the
|
||||||
// test process that wantTimedOut allows, waitLimit/2: a shorter one
|
// test process that wantTimedOut allows: a shorter one can run out
|
||||||
// can run out first on a busy host.
|
// first on a busy host.
|
||||||
shortTimeout = 5 * time.Second
|
shortTimeout = waitLimit / 2
|
||||||
// shortTimeoutSetting is shortTimeout as a setting's value.
|
// shortTimeoutSetting is shortTimeout as a setting's value.
|
||||||
shortTimeoutSetting = "5s"
|
shortTimeoutSetting = "5s"
|
||||||
// longTimeoutSetting is a timeout that does not run out in a test.
|
// longTimeoutSetting is a timeout that does not run out in a test.
|
||||||
|
|||||||
Reference in New Issue
Block a user