...
1 package router
2
3 import (
4 "fmt"
5 "testing"
6 "time"
7
8 "golang.conradwood.net/apis/apitest"
9 "golang.conradwood.net/go-easyops/authremote"
10 "golang.conradwood.net/go-easyops/router"
11 )
12
13 func TestSingle(t *testing.T) {
14 cm := router.NewConnectionManager("apitest.ApiTestService")
15 cm.AllowMultipleInstancesPerIP()
16 fr := router.NewFanoutRouter(cm, func(p *router.ProcessRequest) error {
17 client := apitest.NewApiTestServiceClient(p.GRPCConnection())
18 ctx := authremote.Context()
19 _, err := client.SlowPing(ctx, &apitest.PingRequest{})
20 return err
21 },
22 func(c *router.CompletionNotification) {
23 },
24 )
25 started := time.Now()
26 i := 0
27 for time.Since(started) < time.Duration(30)*time.Second {
28 i++
29 fmt.Printf("submitting %d\n", i)
30 fr.SubmitWork("foo")
31 }
32 fr.Stop()
33 dur := time.Since(started)
34 ps := float64(i) / dur.Seconds()
35 fmt.Printf("Processed %d requests in %0.1fs (%0.1f per second)\n", i, dur.Seconds(), ps)
36 }
37
View as plain text