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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.