Fix sending oversided data frames to spdy stream
This commit is contained in:
@@ -108,7 +108,7 @@ func (ex *fakeExecutor) run(name string, uid types.UID, container string, cmd []
|
||||
return nil
|
||||
}
|
||||
|
||||
func fakeServer(t *testing.T, testName string, exec bool, stdinData, stdoutData, stderrData, errorData string, tty bool, messageCount int, serverProtocols []string) http.HandlerFunc {
|
||||
func fakeServer(t *testing.T, requestReceived chan struct{}, testName string, exec bool, stdinData, stdoutData, stderrData, errorData string, tty bool, messageCount int, serverProtocols []string) http.HandlerFunc {
|
||||
return http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||
executor := &fakeExecutor{
|
||||
t: t,
|
||||
@@ -134,6 +134,7 @@ func fakeServer(t *testing.T, testName string, exec bool, stdinData, stdoutData,
|
||||
if e, a := strings.Repeat(stdinData, messageCount), executor.stdinReceived.String(); e != a {
|
||||
t.Errorf("%s: stdin: expected %q, got %q", testName, e, a)
|
||||
}
|
||||
close(requestReceived)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -165,6 +166,15 @@ func TestStream(t *testing.T) {
|
||||
ClientProtocols: []string{remotecommandconsts.StreamProtocolV2Name},
|
||||
ServerProtocols: []string{remotecommandconsts.StreamProtocolV2Name},
|
||||
},
|
||||
{
|
||||
TestName: "oversized stdin",
|
||||
Stdin: strings.Repeat("a", 20*1024*1024),
|
||||
Stdout: "b",
|
||||
Stderr: "",
|
||||
MessageCount: 1,
|
||||
ClientProtocols: []string{remotecommandconsts.StreamProtocolV2Name},
|
||||
ServerProtocols: []string{remotecommandconsts.StreamProtocolV2Name},
|
||||
},
|
||||
{
|
||||
TestName: "in/out/tty",
|
||||
Stdin: "a",
|
||||
@@ -218,7 +228,8 @@ func TestStream(t *testing.T) {
|
||||
localOut := &bytes.Buffer{}
|
||||
localErr := &bytes.Buffer{}
|
||||
|
||||
server := httptest.NewServer(fakeServer(t, name, exec, testCase.Stdin, testCase.Stdout, testCase.Stderr, testCase.Error, testCase.Tty, testCase.MessageCount, testCase.ServerProtocols))
|
||||
requestReceived := make(chan struct{})
|
||||
server := httptest.NewServer(fakeServer(t, requestReceived, name, exec, testCase.Stdin, testCase.Stdout, testCase.Stderr, testCase.Error, testCase.Tty, testCase.MessageCount, testCase.ServerProtocols))
|
||||
|
||||
url, _ := url.ParseRequestURI(server.URL)
|
||||
config := restclient.ContentConfig{
|
||||
@@ -305,6 +316,12 @@ func TestStream(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
select {
|
||||
case <-requestReceived:
|
||||
case <-time.After(time.Minute):
|
||||
t.Errorf("%s: expected fakeServerInstance to receive request", name)
|
||||
}
|
||||
|
||||
server.Close()
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user