Skip to content

Commit

Permalink
Bind servers under test to local loopback interface.
Browse files Browse the repository at this point in the history
This eliminates the annoying "wants to accept incoming connections"
popups on macOS.
  • Loading branch information
sengi committed Aug 19, 2023
1 parent b200a7a commit 10d476a
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions integration_tests/router_support.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"net/http"
"os"
"os/exec"
"strconv"
"syscall"
"time"

Expand Down Expand Up @@ -53,8 +54,9 @@ func reloadRoutes(optionalPort ...int) {
var runningRouters = make(map[int]*exec.Cmd)

func startRouter(port, apiPort int, extraEnv []string) error {
pubaddr := fmt.Sprintf(":%d", port)
apiaddr := fmt.Sprintf(":%d", apiPort)
host := "localhost"
pubAddr := net.JoinHostPort(host, strconv.Itoa(port))
apiAddr := net.JoinHostPort(host, strconv.Itoa(apiPort))

bin := os.Getenv("BINARY")
if bin == "" {
Expand All @@ -63,8 +65,8 @@ func startRouter(port, apiPort int, extraEnv []string) error {
cmd := exec.Command(bin)

cmd.Env = append(cmd.Environ(), "ROUTER_MONGO_DB=router_test")
cmd.Env = append(cmd.Env, fmt.Sprintf("ROUTER_PUBADDR=%s", pubaddr))
cmd.Env = append(cmd.Env, fmt.Sprintf("ROUTER_APIADDR=%s", apiaddr))
cmd.Env = append(cmd.Env, fmt.Sprintf("ROUTER_PUBADDR=%s", pubAddr))
cmd.Env = append(cmd.Env, fmt.Sprintf("ROUTER_APIADDR=%s", apiAddr))
cmd.Env = append(cmd.Env, fmt.Sprintf("ROUTER_ERROR_LOG=%s", tempLogfile.Name()))
cmd.Env = append(cmd.Env, extraEnv...)

Expand All @@ -78,7 +80,7 @@ func startRouter(port, apiPort int, extraEnv []string) error {
return err
}

waitForServerUp(pubaddr)
waitForServerUp(pubAddr)

runningRouters[port] = cmd
return nil
Expand Down

0 comments on commit 10d476a

Please sign in to comment.