Test Discovery and the Service End-to-End

Let’s test that our service discovery and replication works in an end-to-end test. We’ll set up a cluster with three nodes. We’ll produce a record to one server and verify that we can consume the message from the other servers that have (hopefully) replicated for us.

In internal/agent, create an agent_test.go file, beginning with this snippet:

 package​ agent_test
 
 import​ (
 "context"
 "crypto/tls"
 "fmt"
 "io/ioutil"
 "os"
 "testing"
 "time"
 
 "github.com/stretchr/testify/require"
 "github.com/travisjeffery/go-dynaport"
 "google.golang.org/grpc"
 "google.golang.org/grpc/credentials"
 
  api ​"github.com/travisjeffery/proglog/api/v1" ...

Get Distributed Services with Go now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.