Skip to content

Commit 6e41410

Browse files
neildgopherbot
authored andcommitted
http2: fix benchmarks using common frame read/write functions
CL 586249 unified frame read/write functions used by client and server tests, but inadvertently broke some benchmarks. Fix those benchmarks. This mostly restores the previous behavior of the affected benchmarks (for example, testing only to see that a DATA frame contains an END_STREAM marker, ignoring the number of bytes in the frame). Fixes golang/go#70647 Change-Id: I2b0099c3513ac8754d11c4e37b7d63277a0fb0b1 Reviewed-on: https://go-review.googlesource.com/c/net/+/633055 Auto-Submit: Damien Neil <[email protected]> Reviewed-by: Jonathan Amsterdam <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Antonio Ojea <[email protected]>
1 parent 4be1253 commit 6e41410

File tree

1 file changed

+15
-35
lines changed

1 file changed

+15
-35
lines changed

http2/server_test.go

+15-35
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,9 @@ func newServerTesterWithRealConn(t testing.TB, handler http.HandlerFunc, opts ..
333333

334334
// sync waits for all goroutines to idle.
335335
func (st *serverTester) sync() {
336-
st.group.Wait()
336+
if st.group != nil {
337+
st.group.Wait()
338+
}
337339
}
338340

339341
// advance advances synthetic time by a duration.
@@ -2896,15 +2898,10 @@ func BenchmarkServerGets(b *testing.B) {
28962898
EndStream: true,
28972899
EndHeaders: true,
28982900
})
2899-
st.wantHeaders(wantHeader{
2900-
streamID: 1,
2901-
endStream: true,
2902-
})
2903-
st.wantData(wantData{
2904-
streamID: 1,
2905-
endStream: true,
2906-
size: 0,
2907-
})
2901+
st.wantFrameType(FrameHeaders)
2902+
if df := readFrame[*DataFrame](b, st); !df.StreamEnded() {
2903+
b.Fatalf("DATA didn't have END_STREAM; got %v", df)
2904+
}
29082905
}
29092906
}
29102907

@@ -2939,15 +2936,10 @@ func BenchmarkServerPosts(b *testing.B) {
29392936
EndHeaders: true,
29402937
})
29412938
st.writeData(id, true, nil)
2942-
st.wantHeaders(wantHeader{
2943-
streamID: 1,
2944-
endStream: false,
2945-
})
2946-
st.wantData(wantData{
2947-
streamID: 1,
2948-
endStream: true,
2949-
size: 0,
2950-
})
2939+
st.wantFrameType(FrameHeaders)
2940+
if df := readFrame[*DataFrame](b, st); !df.StreamEnded() {
2941+
b.Fatalf("DATA didn't have END_STREAM; got %v", df)
2942+
}
29512943
}
29522944
}
29532945

@@ -3289,14 +3281,8 @@ func BenchmarkServer_GetRequest(b *testing.B) {
32893281
EndStream: true,
32903282
EndHeaders: true,
32913283
})
3292-
st.wantHeaders(wantHeader{
3293-
streamID: streamID,
3294-
endStream: false,
3295-
})
3296-
st.wantData(wantData{
3297-
streamID: streamID,
3298-
endStream: true,
3299-
})
3284+
st.wantFrameType(FrameHeaders)
3285+
st.wantFrameType(FrameData)
33003286
}
33013287
}
33023288

@@ -3327,14 +3313,8 @@ func BenchmarkServer_PostRequest(b *testing.B) {
33273313
EndHeaders: true,
33283314
})
33293315
st.writeData(streamID, true, nil)
3330-
st.wantHeaders(wantHeader{
3331-
streamID: streamID,
3332-
endStream: false,
3333-
})
3334-
st.wantData(wantData{
3335-
streamID: streamID,
3336-
endStream: true,
3337-
})
3316+
st.wantFrameType(FrameHeaders)
3317+
st.wantFrameType(FrameData)
33383318
}
33393319
}
33403320

0 commit comments

Comments
 (0)