...

Text file src/golang.conradwood.net/go-easyops/router/fanoutrouter_test.go~

Documentation: golang.conradwood.net/go-easyops/router

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

View as plain text