(t *testing.T)
| 34 | ) |
| 35 | |
| 36 | func TestInvocation(t *testing.T) { |
| 37 | rtID := "runtime" |
| 38 | rtMap := NewRuntimeManager(getFuncletNode(), &RuntimeManagerParameters{MaxRuntimeIdle: 10, MaxRunnerDefunct: 30}) |
| 39 | rtParams := &NewRuntimeParameters{ |
| 40 | RuntimeID: rtID, |
| 41 | ConcurrentMode: true, |
| 42 | StreamMode: false, |
| 43 | WaitRuntimeAliveTimeout: 3, |
| 44 | Resource: &api.Resource{}, |
| 45 | } |
| 46 | rt := rtMap.NewRuntime(rtParams) |
| 47 | rt.SetState(RuntimeStateWarm) |
| 48 | |
| 49 | rc := NewRuntimeConfigOptions() |
| 50 | ds := &DispatcherV2Options{ |
| 51 | RunnerServerAddress: getTmpSock(), |
| 52 | RuntimeServerAddress: getTmpSock(), |
| 53 | UserLogFileDir: defaultUserLogFilePath, |
| 54 | UserLogType: string(UserLogTypePlain), |
| 55 | } |
| 56 | cli, _ := NewRuntimeClient(rc, ds, rtMap) |
| 57 | |
| 58 | <-time.NewTicker(time.Second).C |
| 59 | funN := "test" |
| 60 | cmID := "xxx" |
| 61 | timeout := int64(3) |
| 62 | mem := int64(256) |
| 63 | ver := "1" |
| 64 | reqid := id.GetRequestID() |
| 65 | rt.SetCommitID(cmID) |
| 66 | go initRuntime(cli.dispatchServer, rt.RuntimeID, cmID, reqid) |
| 67 | |
| 68 | input := &InvocationInput{ |
| 69 | Runtime: rt, |
| 70 | RequestID: reqid, |
| 71 | Configuration: &api.FunctionConfiguration{ |
| 72 | CommitID: &cmID, |
| 73 | FunctionConfiguration: lambda.FunctionConfiguration{ |
| 74 | FunctionName: &funN, |
| 75 | Timeout: &timeout, |
| 76 | MemorySize: &mem, |
| 77 | Version: &ver, |
| 78 | }, |
| 79 | }, |
| 80 | User: &api.User{ |
| 81 | ID: "xxx", |
| 82 | }, |
| 83 | WithStreamMode: false, |
| 84 | Request: &api.InvokeProxyRequest{ |
| 85 | Headers: make(map[string]string, 0), |
| 86 | Body: []byte("test"), |
| 87 | }, |
| 88 | Response: api.NewInvokeProxyResponse(), |
| 89 | EnableMetrics: false, |
| 90 | Logger: logs.NewLogger().WithField("request_id", reqid), |
| 91 | } |
| 92 | |
| 93 | output := cli.InvokeFunction(input) |
nothing calls this directly
no test coverage detected