(t *testing.T)
| 36 | ) |
| 37 | |
| 38 | func TestSendHTTPRequestLoop(t *testing.T) { |
| 39 | ts := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { |
| 40 | w.WriteHeader(http.StatusOK) |
| 41 | w.Write([]byte("hello world")) |
| 42 | return |
| 43 | })) |
| 44 | defer ts.Close() |
| 45 | |
| 46 | id := "runtime-id" |
| 47 | cmid := "commit-xxx" |
| 48 | reqid := utilID.GetRequestID() |
| 49 | rtMap := NewRuntimeManager(getFuncletNode(), &RuntimeManagerParameters{MaxRuntimeIdle: 10, MaxRunnerDefunct: 30}) |
| 50 | rtParams := &NewRuntimeParameters{ |
| 51 | RuntimeID: id, |
| 52 | ConcurrentMode: false, |
| 53 | StreamMode: false, |
| 54 | WaitRuntimeAliveTimeout: 3, |
| 55 | Resource: &api.Resource{}, |
| 56 | } |
| 57 | rt := rtMap.NewRuntime(rtParams) |
| 58 | req, resp := buildRequestResponse(id, cmid, reqid) |
| 59 | conn, _, ok := setupHijackConn(resp, req) |
| 60 | if !ok { |
| 61 | t.Error("setup hijack connect failed") |
| 62 | return |
| 63 | } |
| 64 | rt.SetState(RuntimeStateCold) |
| 65 | rt.updateStreamMode(true) |
| 66 | params := &startRuntimeParams{ |
| 67 | commitID: cmid, |
| 68 | hostIP: "127.0.0.1", |
| 69 | conn: conn, |
| 70 | warmNotify: make(chan struct{}), |
| 71 | urlParams: req.URL.Query(), |
| 72 | } |
| 73 | if err := rt.initRuntime(params); err != nil { |
| 74 | t.Errorf("init runtime failed: %s", err) |
| 75 | return |
| 76 | } |
| 77 | rt.httpClient = ts.Client() |
| 78 | |
| 79 | now := time.Now().UnixNano() |
| 80 | ver := "1" |
| 81 | timeout := int64(3) |
| 82 | reqinfo := RequestInfo{ |
| 83 | RequestID: reqid, |
| 84 | Runtime: rt, |
| 85 | InvokeStartTimeNS: now, |
| 86 | InvokeStartTimeMS: now / int64(time.Millisecond), |
| 87 | SyncChannel: make(chan struct{}, 1), |
| 88 | TimeoutChannel: make(chan struct{}, 1), |
| 89 | Input: &InvocationInput{ |
| 90 | Runtime: rt, |
| 91 | RequestID: reqid, |
| 92 | Configuration: &api.FunctionConfiguration{ |
| 93 | CommitID: &cmid, |
| 94 | FunctionConfiguration: lambda.FunctionConfiguration{ |
| 95 | Version: &ver, |
nothing calls this directly
no test coverage detected