@@ -164,8 +164,11 @@ func TestFnInvokeRunnerExecution(t *testing.T) {
164164
165165 srv := testServer (ds , rnr , ServerTypeFull , LimitRequestBody (32256 ))
166166
167+ inStripHeaders := map [string ][]string {"Keep-Alive" : {"true" }}
168+
167169 expHeaders := map [string ][]string {"Content-Type" : {"application/json; charset=utf-8" }}
168170 expCTHeaders := map [string ][]string {"Content-Type" : {"foo/bar" }}
171+ expStripHeaders := map [string ][]string {"Keep-Alive" : {"" }}
169172
170173 // Checking for EndOfLogs currently depends on scheduling of go-routines (in docker/containerd) that process stderr & stdout.
171174 // Therefore, not testing for EndOfLogs for hot containers (which has complex I/O processing) anymore.
@@ -186,41 +189,46 @@ func TestFnInvokeRunnerExecution(t *testing.T) {
186189 bigoutput := `{"echoContent": "_TRX_ID_", "isDebug": true, "trailerRepeat": 1000}` // 1000 trailers to exceed 2K
187190
188191 bighdroutput := `{"echoContent": "_TRX_ID_", "isDebug": true, "returnHeaders": {"zoo": ["` + strings .Repeat ("a" , 1024 ) + `"]}}` // big header to exceed
192+ striphdr := `{"echoContent": "_TRX_ID_", "isDebug": true, "returnHeaders": {"Keep-Alive": ["true"]}}` // this should get stripped
193+ striphdrin := `{"echoContent": "_TRX_ID_", "isDebug": true, "expectHeaders": {"Keep-Alive": [""]}}` // this should get stripped
189194
190195 smalloutput := `{"echoContent": "_TRX_ID_", "isDebug": true, "responseContentType":"application/json; charset=utf-8", "trailerRepeat": 1}` // 1 trailer < 2K
191196
192197 testCases := []struct {
193198 path string
194199 body string
200+ headers map [string ][]string
195201 method string
196202 expectedCode int
197203 expectedHeaders map [string ][]string
198204 expectedErrSubStr string
199205 expectedLogsSubStr []string
200206 }{
201- {"/invoke/http_stream_fn_id" , ok , http .MethodPost , http .StatusOK , expHeaders , "" , nil },
202- // NOTE: we can't test bad response framing anymore easily (eg invalid http response), should we even worry about it?
203- {"/invoke/http_stream_fn_id" , respTypeLie , http .MethodPost , http .StatusOK , expCTHeaders , "" , nil },
204- {"/invoke/http_stream_fn_id" , crasher , http .MethodPost , http .StatusBadGateway , expHeaders , "error receiving function response" , nil },
205- // XXX(reed): we could stop buffering function responses so that we can stream things?
206- {"/invoke/http_stream_fn_id" , bighdroutput , http .MethodPost , http .StatusBadGateway , nil , "function response header too large" , nil },
207- {"/invoke/http_stream_fn_id" , bigoutput , http .MethodPost , http .StatusBadGateway , nil , "function response too large" , nil },
208- {"/invoke/http_stream_fn_id" , smalloutput , http .MethodPost , http .StatusOK , expHeaders , "" , nil },
209- // XXX(reed): meh we really should try to get oom out, but maybe it's better left to the logs?
210- {"/invoke/http_stream_fn_id" , oomer , http .MethodPost , http .StatusBadGateway , nil , "error receiving function response" , nil },
211- {"/invoke/http_stream_fn_id" , bigbuf , http .MethodPost , http .StatusRequestEntityTooLarge , nil , "" , nil },
212-
213- {"/invoke/dne_fn_id" , `` , http .MethodPost , http .StatusNotFound , nil , "pull access denied" , nil },
214- {"/invoke/dnereg_fn_id" , `` , http .MethodPost , http .StatusBadGateway , nil , "connection refused" , nil },
215-
216- // XXX(reed): what are these?
217- {"/invoke/http_stream_fn_id" , multiLog , http .MethodPost , http .StatusOK , nil , "" , multiLogExpectHot },
218-
219- {"/invoke/fail_fn_quick" , ok , http .MethodPost , http .StatusBadGateway , nil , "container failed to initialize" , nil },
220- {"/invoke/fail_fn_timeout" , ok , http .MethodPost , http .StatusGatewayTimeout , nil , "Container initialization timed out" , nil },
221- {"/invoke/fn_id" , ok , http .MethodPut , http .StatusMethodNotAllowed , nil , "Method not allowed" , nil },
222-
223- {"/invoke/bigmem" , ok , http .MethodPost , http .StatusBadRequest , nil , "cannot be allocated" , nil },
207+ {"/invoke/http_stream_fn_id" , ok , nil , http .MethodPost , http .StatusOK , expHeaders , "" , nil },
208+ // NOTE: nil, we can't test bad response framing anymore easily (eg invalid http response), should we even worry about it?
209+ {"/invoke/http_stream_fn_id" , respTypeLie , nil , http .MethodPost , http .StatusOK , expCTHeaders , "" , nil },
210+ {"/invoke/http_stream_fn_id" , crasher , nil , http .MethodPost , http .StatusBadGateway , expHeaders , "error receiving function response" , nil },
211+ // XXX(reed): nil, we could stop buffering function responses so that we can stream things?
212+ {"/invoke/http_stream_fn_id" , bighdroutput , nil , http .MethodPost , http .StatusBadGateway , nil , "function response header too large" , nil },
213+ {"/invoke/http_stream_fn_id" , striphdr , nil , http .MethodPost , http .StatusOK , expStripHeaders , "" , nil },
214+ {"/invoke/http_stream_fn_id" , striphdrin , inStripHeaders , http .MethodPost , http .StatusOK , nil , "" , nil },
215+ {"/invoke/http_stream_fn_id" , bigoutput , nil , http .MethodPost , http .StatusBadGateway , nil , "function response too large" , nil },
216+ {"/invoke/http_stream_fn_id" , smalloutput , nil , http .MethodPost , http .StatusOK , expHeaders , "" , nil },
217+ // XXX(reed): nil, meh we really should try to get oom out, but maybe it's better left to the logs?
218+ {"/invoke/http_stream_fn_id" , oomer , nil , http .MethodPost , http .StatusBadGateway , nil , "error receiving function response" , nil },
219+ {"/invoke/http_stream_fn_id" , bigbuf , nil , http .MethodPost , http .StatusRequestEntityTooLarge , nil , "" , nil },
220+
221+ {"/invoke/dne_fn_id" , `` , nil , http .MethodPost , http .StatusNotFound , nil , "pull access denied" , nil },
222+ {"/invoke/dnereg_fn_id" , `` , nil , http .MethodPost , http .StatusBadGateway , nil , "connection refused" , nil },
223+
224+ // XXX(reed): nil, nil, what are these?
225+ {"/invoke/http_stream_fn_id" , multiLog , nil , http .MethodPost , http .StatusOK , nil , "" , multiLogExpectHot },
226+
227+ {"/invoke/fail_fn_quick" , ok , nil , http .MethodPost , http .StatusBadGateway , nil , "container failed to initialize" , nil },
228+ {"/invoke/fail_fn_timeout" , ok , nil , http .MethodPost , http .StatusGatewayTimeout , nil , "Container initialization timed out" , nil },
229+ {"/invoke/fn_id" , ok , nil , http .MethodPut , http .StatusMethodNotAllowed , nil , "Method not allowed" , nil },
230+
231+ {"/invoke/bigmem" , ok , nil , http .MethodPost , http .StatusBadRequest , nil , "cannot be allocated" , nil },
224232 }
225233
226234 callIds := make ([]string , len (testCases ))
@@ -229,7 +237,11 @@ func TestFnInvokeRunnerExecution(t *testing.T) {
229237 t .Run (fmt .Sprintf ("Test_%d_%s" , i , strings .Replace (test .path , "/" , "_" , - 1 )), func (t * testing.T ) {
230238 trx := fmt .Sprintf ("_trx_%d_" , i )
231239 body := strings .NewReader (strings .Replace (test .body , "_TRX_ID_" , trx , 1 ))
232- _ , rec := routerRequest (t , srv .Router , test .method , test .path , body )
240+ req := createRequest (t , test .method , test .path , body )
241+ if test .headers != nil {
242+ req .Header = test .headers
243+ }
244+ _ , rec := routerRequest2 (t , srv .Router , req )
233245 respBytes , _ := ioutil .ReadAll (rec .Body )
234246 respBody := string (respBytes )
235247 maxBody := len (respBody )
0 commit comments