Skip to content

Commit 844229f

Browse files
feat: run tests on different port
This should stop tests from interferring with ftl dev fixes #2577
1 parent c633e59 commit 844229f

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

bin/hermit.hcl

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
env = {
22
"DBMATE_MIGRATIONS_DIR": "${HERMIT_ENV}/backend/controller/sql/schema",
3-
"FTL_ENDPOINT": "http://localhost:8892",
43
"FTL_INIT_GO_REPLACE": "github.com/TBD54566975/ftl=${HERMIT_ENV}",
54
"FTL_SOURCE": "${HERMIT_ENV}",
65
"OTEL_GRPC_PORT": "4317",

internal/integration/actions.go

+6-3
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,9 @@ func DebugShell() Action {
160160
func Exec(cmd string, args ...string) Action {
161161
return func(t testing.TB, ic TestContext) {
162162
Infof("Executing (in %s): %s %s", ic.workDir, cmd, shellquote.Join(args...))
163-
err := ftlexec.Command(ic, log.Debug, ic.workDir, cmd, args...).RunStderrError(ic)
163+
command := ftlexec.Command(ic, log.Debug, ic.workDir, cmd, args...)
164+
command.Env = append(command.Env, "FTL_ENDPOINT=http://127.0.0.1:"+TestPort)
165+
err := command.RunStderrError(ic)
164166
assert.NoError(t, err)
165167
}
166168
}
@@ -181,6 +183,7 @@ func ExecWithExpectedOutput(want string, cmd string, args ...string) Action {
181183
func ExecWithExpectedError(want string, cmd string, args ...string) Action {
182184
return func(t testing.TB, ic TestContext) {
183185
Infof("Executing: %s %s", cmd, shellquote.Join(args...))
186+
t.Setenv("FTL_ENDPOINT", "http://127.0.0.1:"+TestPort)
184187
output, err := ftlexec.Capture(ic, ic.workDir, cmd, args...)
185188
assert.Error(t, err)
186189
assert.Contains(t, string(output), want)
@@ -220,7 +223,7 @@ func ExpectError(action Action, expectedErrorMsg ...string) Action {
220223
// Deploy a module from the working directory and wait for it to become available.
221224
func Deploy(module string) Action {
222225
return Chain(
223-
Exec("ftl", "deploy", module),
226+
Exec("ftl", "deploy", "--endpoint", "http://127.0.0.1:"+TestPort, module),
224227
Wait(module),
225228
)
226229
}
@@ -521,7 +524,7 @@ func JsonData(t testing.TB, body interface{}) []byte {
521524
func HttpCall(method string, path string, headers map[string][]string, body []byte, onResponse func(t testing.TB, resp *HTTPResponse)) Action {
522525
return func(t testing.TB, ic TestContext) {
523526
Infof("HTTP %s %s", method, path)
524-
baseURL, err := url.Parse(fmt.Sprintf("http://localhost:8891"))
527+
baseURL, err := url.Parse(fmt.Sprintf("http://localhost:" + TestIngressPort))
525528
assert.NoError(t, err)
526529

527530
u, err := baseURL.Parse(path)

internal/integration/harness.go

+8-4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ import (
2929
"github.com/TBD54566975/ftl/internal/rpc"
3030
)
3131

32+
const TestPort = "9892"
33+
const TestIngressPort = "9891"
34+
3235
func integrationTestTimeout() time.Duration {
3336
timeout := optional.Zero(os.Getenv("FTL_INTEGRATION_TEST_TIMEOUT")).Default("5s")
3437
d, err := time.ParseDuration(timeout)
@@ -168,22 +171,23 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
168171
assert.NoError(t, err)
169172
}
170173
})
174+
t.Setenv("FTL_ENDPOINT", "http://127.0.0.1:"+TestPort)
171175

172176
for _, language := range opts.languages {
173177
ctx, done := context.WithCancel(ctx)
174178
t.Run(language, func(t *testing.T) {
175179
tmpDir := initWorkDir(t, cwd, opts)
176180

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

179183
var controller ftlv1connect.ControllerServiceClient
180184
var console pbconsoleconnect.ConsoleServiceClient
181185
if opts.startController {
182-
controller = rpc.Dial(ftlv1connect.NewControllerServiceClient, "http://localhost:8892", log.Debug)
183-
console = rpc.Dial(pbconsoleconnect.NewConsoleServiceClient, "http://localhost:8892", log.Debug)
186+
controller = rpc.Dial(ftlv1connect.NewControllerServiceClient, "http://localhost:"+TestPort, log.Debug)
187+
console = rpc.Dial(pbconsoleconnect.NewConsoleServiceClient, "http://localhost:"+TestPort, log.Debug)
184188

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

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

0 commit comments

Comments
 (0)