Tests: use separate controller listening ports to prevent conflicts (#58)
This commit is contained in:
parent
63ba8b5532
commit
49753ebf4c
|
|
@ -78,6 +78,7 @@ func CreateDevControllerAndWorker(devDataDirPath string) (*controller.Controller
|
|||
|
||||
devController, err := controller.New(
|
||||
controller.WithDataDir(dataDir),
|
||||
controller.WithListenAddr(":0"),
|
||||
controller.WithInsecureAuthDisabled(),
|
||||
controller.WithLogger(logger),
|
||||
)
|
||||
|
|
|
|||
|
|
@ -161,8 +161,11 @@ func (controller *Controller) Run(ctx context.Context) error {
|
|||
}
|
||||
|
||||
func (controller *Controller) Address() string {
|
||||
if strings.HasPrefix(controller.listenAddr, ":") {
|
||||
return fmt.Sprintf("http://localhost%s", controller.listenAddr)
|
||||
hostPort := strings.ReplaceAll(controller.listener.Addr().String(), "[::]", "127.0.0.1")
|
||||
|
||||
if controller.tlsConfig != nil {
|
||||
return fmt.Sprintf("https://%s", hostPort)
|
||||
}
|
||||
return controller.listenAddr
|
||||
|
||||
return fmt.Sprintf("http://%s", hostPort)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ func StartIntegrationTestEnvironment(t *testing.T) *client.Client {
|
|||
|
||||
time.Sleep(5 * time.Second)
|
||||
|
||||
devClient, err := client.New()
|
||||
devClient, err := client.New(client.WithAddress(devController.Address()))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue