(t *testing.T)
| 29 | ) |
| 30 | |
| 31 | func 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) |
nothing calls this directly
no test coverage detected