MCPcopy Index your code
hub / github.com/FunctionStream/function-stream / TestFMWithGRPCRuntime

Function TestFMWithGRPCRuntime

fs/runtime/grpc/grpc_func_test.go:31–117  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

29)
30
31func TestFMWithGRPCRuntime(t *testing.T) {
32 ctx, closeFSReconcile := context.WithCancel(context.Background())
33 fsService := NewFSReconcile(ctx)
34 addr := "localhost:17401"
35 s, err := StartGRPCServer(fsService, addr)
36 if err != nil {
37 t.Fatal(err)
38 return
39 }
40 defer s.Stop()
41 go StartMockGRPCFunc(t, addr)
42 select {
43 case <-fsService.WaitForReady():
44 t.Logf("ready")
45 case <-time.After(1 * time.Second):
46 t.Fatal("timeout waiting for fs service ready")
47 return
48 }
49
50 fm, err := fs.NewFunctionManager(
51 fs.WithRuntimeFactory("grpc", fsService),
52 fs.WithTubeFactory("memory", contube.NewMemoryQueueFactory(ctx)),
53 )
54 if err != nil {
55 t.Fatal(err)
56 }
57
58 inputTopic := "input"
59 outputTopic := "output"
60 f := &model.Function{
61 Name: "test",
62 Runtime: model.RuntimeConfig{
63 Type: "grpc",
64 Config: map[string]interface{}{
65 "addr": addr,
66 },
67 },
68 Sources: []model.TubeConfig{
69 {
70 Type: common.MemoryTubeType,
71 Config: (&contube.SourceQueueConfig{
72 Topics: []string{inputTopic},
73 SubName: "test",
74 }).ToConfigMap(),
75 },
76 },
77 Sink: model.TubeConfig{
78 Type: common.MemoryTubeType,
79 Config: (&contube.SinkQueueConfig{
80 Topic: outputTopic,
81 }).ToConfigMap(),
82 },
83 Replicas: 1,
84 }
85
86 err = fm.StartFunction(f)
87 if err != nil {
88 t.Fatal(err)

Callers

nothing calls this directly

Calls 15

StartFunctionMethod · 0.95
GetStateStoreMethod · 0.95
ProduceEventMethod · 0.95
ConsumeEventMethod · 0.95
DeleteFunctionMethod · 0.95
NewFunctionManagerFunction · 0.92
WithRuntimeFactoryFunction · 0.92
WithTubeFactoryFunction · 0.92
NewMemoryQueueFactoryFunction · 0.92
NewRecordImplFunction · 0.92
NewFSReconcileFunction · 0.85
StartGRPCServerFunction · 0.85

Tested by

no test coverage detected