Skip to content

Commit

Permalink
fix: use longer timeout for deployment
Browse files Browse the repository at this point in the history
This can result in image pulls so it needs to be longer
  • Loading branch information
stuartwdouglas committed Dec 17, 2024
1 parent 2e686b6 commit 010c4c0
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
7 changes: 6 additions & 1 deletion internal/integration/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

"connectrpc.com/connect"
"github.com/alecthomas/assert/v2"
"github.com/alecthomas/types/optional"
_ "github.com/jackc/pgx/v5/stdlib" // SQL driver
"github.com/kballard/go-shellquote"
"github.com/otiai10/copy"
Expand All @@ -31,6 +32,7 @@ import (
timelinepb "github.com/block/ftl/backend/protos/xyz/block/ftl/timeline/v1"
ftlv1 "github.com/block/ftl/backend/protos/xyz/block/ftl/v1"
schemapb "github.com/block/ftl/common/protos/xyz/block/ftl/schema/v1"
"github.com/block/ftl/internal/dev"
"github.com/block/ftl/internal/dsn"
ftlexec "github.com/block/ftl/internal/exec"
"github.com/block/ftl/internal/log"
Expand Down Expand Up @@ -236,7 +238,7 @@ func Deploy(module string) Action {

Exec("ftl", args...)(t, ic)
},
Wait(module),
WaitWithTimeout(module, time.Minute*2),
)
}

Expand Down Expand Up @@ -575,7 +577,10 @@ func DropDBAction(t testing.TB, dbName string) Action {

func DropDB(t testing.TB, dbName string) {
Infof("Dropping database %s", dbName)

db, err := sql.Open("pgx", dsn.PostgresDSN("postgres"))
assert.NoError(t, err, "failed to setup database")
err = dev.SetupPostgres(context.Background(), optional.None[string](), 15432, false)
assert.NoError(t, err, "failed to open database connection")

terminateDanglingConnections(t, db, dbName)
Expand Down
32 changes: 19 additions & 13 deletions internal/integration/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,26 +377,16 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
}
defer dumpKubePods(ctx, ic.kubeClient, ic.kubeNamespace)

if opts.startTimeline && !opts.kube {
ic.Timeline = rpc.Dial(timelinepbconnect.NewTimelineServiceClient, "http://localhost:8894", log.Debug)

Infof("Waiting for timeline to be ready")
ic.AssertWithRetry(t, func(t testing.TB, ic TestContext) {
_, err := ic.Timeline.Ping(ic, connect.NewRequest(&ftlv1.PingRequest{}))
assert.NoError(t, err)
})
}

if opts.startController || opts.kube {
ic.Controller = controller
ic.Schema = schema
ic.Console = console

Infof("Waiting for controller to be ready")
ic.AssertWithRetry(t, func(t testing.TB, ic TestContext) {
ic.AssertWithSpecificRetry(t, func(t testing.TB, ic TestContext) {
_, err := ic.Controller.Status(ic, connect.NewRequest(&ftlv1.StatusRequest{}))
assert.NoError(t, err)
})
}, time.Minute*2)
}

if opts.startProvisioner {
Expand All @@ -409,6 +399,16 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
})
}

if opts.startTimeline && !opts.kube {
ic.Timeline = rpc.Dial(timelinepbconnect.NewTimelineServiceClient, "http://localhost:8894", log.Debug)

Infof("Waiting for timeline to be ready")
ic.AssertWithRetry(t, func(t testing.TB, ic TestContext) {
_, err := ic.Timeline.Ping(ic, connect.NewRequest(&ftlv1.PingRequest{}))
assert.NoError(t, err)
})
}

if opts.resetPubSub {
Infof("Resetting pubsub")
envars := []string{"COMPOSE_IGNORE_ORPHANS=True"}
Expand Down Expand Up @@ -543,7 +543,13 @@ func (i TestContext) WorkingDir() string { return i.workDir }
// AssertWithRetry asserts that the given action passes within the timeout.
func (i TestContext) AssertWithRetry(t testing.TB, assertion Action) {
t.Helper()
waitCtx, done := context.WithTimeout(i, i.integrationTestTimeout())
i.AssertWithSpecificRetry(t, assertion, i.integrationTestTimeout())
}

// AssertWithSpecificRetry asserts that the given action passes within the timeout.
func (i TestContext) AssertWithSpecificRetry(t testing.TB, assertion Action, timeout time.Duration) {
t.Helper()
waitCtx, done := context.WithTimeout(i, timeout)
defer done()
for {
err := i.runAssertionOnce(t, assertion)
Expand Down

0 comments on commit 010c4c0

Please sign in to comment.