Use socket instead of TCP for etcd config

When we make dummy test servers, we should make them using sockets
for etcd rather than TCP ports so we don't run into problems like
the test always failing if anything else is on that port already,
which it can totally legitimately be. For instance, if you ran
an existing featurebase server, and then tried "go test" in the
server directory, this would fail.
This commit is contained in:
Seebs 2022-08-18 11:19:01 -05:00 committed by seebs
parent 36a4fb2cb7
commit f066fcb33c

View file

@ -52,6 +52,11 @@ func newCommand(tb testing.TB, opts ...server.CommandOption) *Command {
m := &Command{commandOptions: opts}
m.Command = server.NewCommand(bytes.NewReader(nil), ioutil.Discard, ioutil.Discard, opts...)
// pick etcd ports using a socket rather than a real port
err = GetPortsGenConfigs(tb, []*Command{m})
if err != nil {
tb.Fatalf("generating config: %v", err)
}
m.Config.DataDir = path
defaultConf := server.NewConfig()