(t *testing.T)
| 96 | } |
| 97 | |
| 98 | func TestInvocationWithStream(t *testing.T) { |
| 99 | rtID := "runtime" |
| 100 | rtMap := NewRuntimeManager(getFuncletNode(), &RuntimeManagerParameters{MaxRuntimeIdle: 10, MaxRunnerDefunct: 30}) |
| 101 | rtParams := &NewRuntimeParameters{ |
| 102 | RuntimeID: rtID, |
| 103 | ConcurrentMode: true, |
| 104 | StreamMode: false, |
| 105 | WaitRuntimeAliveTimeout: 3, |
| 106 | Resource: &api.Resource{}, |
| 107 | } |
| 108 | rt := rtMap.NewRuntime(rtParams) |
| 109 | rt.SetState(RuntimeStateWarm) |
| 110 | |
| 111 | rc := NewRuntimeConfigOptions() |
| 112 | ds := &DispatcherV2Options{ |
| 113 | RunnerServerAddress: getTmpSock(), |
| 114 | RuntimeServerAddress: getTmpSock(), |
| 115 | UserLogFileDir: defaultUserLogFilePath, |
| 116 | UserLogType: string(UserLogTypePlain), |
| 117 | } |
| 118 | cli, _ := NewRuntimeClient(rc, ds, rtMap) |
| 119 | |
| 120 | <-time.NewTicker(time.Second).C |
| 121 | cmID := "xxx" |
| 122 | ver := "1" |
| 123 | funN := "test" |
| 124 | reqid := id.GetRequestID() |
| 125 | rt.SetCommitID(cmID) |
| 126 | rt.updateStreamMode(true) |
| 127 | go initRuntime(cli.dispatchServer, rt.RuntimeID, cmID, reqid) |
| 128 | |
| 129 | input := &InvocationInput{ |
| 130 | Runtime: rt, |
| 131 | RequestID: reqid, |
| 132 | Configuration: &api.FunctionConfiguration{ |
| 133 | CommitID: &cmID, |
| 134 | FunctionConfiguration: lambda.FunctionConfiguration{ |
| 135 | FunctionName: &funN, |
| 136 | Version: &ver, |
| 137 | }, |
| 138 | }, |
| 139 | User: &api.User{ |
| 140 | ID: "xxx", |
| 141 | }, |
| 142 | WithStreamMode: true, |
| 143 | Request: &api.InvokeProxyRequest{ |
| 144 | Headers: make(map[string]string, 0), |
| 145 | Body: []byte("test"), |
| 146 | }, |
| 147 | Response: api.NewInvokeProxyResponse(), |
| 148 | EnableMetrics: true, |
| 149 | Logger: logs.NewLogger().WithField("request_id", reqid), |
| 150 | } |
| 151 | output := cli.InvokeFunction(input) |
| 152 | t.Logf("%+v", output) |
| 153 | } |
| 154 | |
| 155 | func initRuntime(s *DispatchServerV2, runtimeID string, commitID string, requestID string) { |
nothing calls this directly
no test coverage detected