Skip to content

Commit

Permalink
feat: run tests on different port
Browse files Browse the repository at this point in the history
This should stop tests from interferring with ftl dev

fixes #2577
  • Loading branch information
stuartwdouglas committed Sep 2, 2024
1 parent 58ce5a0 commit 042df9d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
4 changes: 2 additions & 2 deletions internal/integration/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ func ExpectError(action Action, expectedErrorMsg ...string) Action {
// Deploy a module from the working directory and wait for it to become available.
func Deploy(module string) Action {
return Chain(
Exec("ftl", "deploy", module),
Exec("ftl", "deploy", "--endpoint", "http://127.0.0.1:"+TestPort, module),
Wait(module),
)
}
Expand Down Expand Up @@ -521,7 +521,7 @@ func JsonData(t testing.TB, body interface{}) []byte {
func HttpCall(method string, path string, headers map[string][]string, body []byte, onResponse func(t testing.TB, resp *HTTPResponse)) Action {
return func(t testing.TB, ic TestContext) {
Infof("HTTP %s %s", method, path)
baseURL, err := url.Parse(fmt.Sprintf("http://localhost:8891"))
baseURL, err := url.Parse(fmt.Sprintf("http://localhost:" + TestIngressPort))
assert.NoError(t, err)

u, err := baseURL.Parse(path)
Expand Down
11 changes: 7 additions & 4 deletions internal/integration/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ import (
"github.com/TBD54566975/ftl/internal/rpc"
)

const TestPort = "9892"
const TestIngressPort = "9891"

func integrationTestTimeout() time.Duration {
timeout := optional.Zero(os.Getenv("FTL_INTEGRATION_TEST_TIMEOUT")).Default("5s")
d, err := time.ParseDuration(timeout)
Expand Down Expand Up @@ -174,16 +177,16 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
t.Run(language, func(t *testing.T) {
tmpDir := initWorkDir(t, cwd, opts)

verbs := rpc.Dial(ftlv1connect.NewVerbServiceClient, "http://localhost:8892", log.Debug)
verbs := rpc.Dial(ftlv1connect.NewVerbServiceClient, "http://localhost:"+TestPort, log.Debug)

var controller ftlv1connect.ControllerServiceClient
var console pbconsoleconnect.ConsoleServiceClient
if opts.startController {
controller = rpc.Dial(ftlv1connect.NewControllerServiceClient, "http://localhost:8892", log.Debug)
console = rpc.Dial(pbconsoleconnect.NewConsoleServiceClient, "http://localhost:8892", log.Debug)
controller = rpc.Dial(ftlv1connect.NewControllerServiceClient, "http://localhost:"+TestPort, log.Debug)
console = rpc.Dial(pbconsoleconnect.NewConsoleServiceClient, "http://localhost:"+TestPort, log.Debug)

Infof("Starting ftl cluster")
ctx = startProcess(ctx, t, filepath.Join(binDir, "ftl"), "serve", "--recreate")
ctx = startProcess(ctx, t, filepath.Join(binDir, "ftl"), "serve", "--recreate", "--bind", "http://127.0.0.1:"+TestIngressPort)
}

testData := filepath.Join(cwd, "testdata", language)
Expand Down

0 comments on commit 042df9d

Please sign in to comment.