Skip to content

Commit

Permalink
move integration test away from old cli command
Browse files Browse the repository at this point in the history
  • Loading branch information
matt2e committed Mar 5, 2025
1 parent d89eb2f commit 56337c0
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 13 deletions.
1 change: 1 addition & 0 deletions .go-arch-lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ components:
ftl-proxy-pg-cmd: { in: cmd/ftl-proxy-pg/** }
ftl-raft-tester-cmd: { in: cmd/raft-tester/** }
ftl-sqlc-cmd: { in: cmd/ftl-sqlc/** }
ftl-mcp-cmd: { in: cmd/ftl-mcp/** }

go2proto: { in: cmd/go2proto/** }

Expand Down
2 changes: 1 addition & 1 deletion .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ builds:
main: ./cmd/ftl-sqlc
binary: ftl-sqlc
<<: *settings
- id: ftl-language-mcp
- id: ftl-mcp
main: ./cmd/ftl-mcp
binary: ftl-mcp
<<: *settings
Expand Down
26 changes: 20 additions & 6 deletions internal/integration/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,12 @@ import (

"github.com/block/scaffolder"

languagepb "github.com/block/ftl/backend/protos/xyz/block/ftl/language/v1"
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/common/schema"
"github.com/block/ftl/internal/devstate"
"github.com/block/ftl/internal/dsn"
ftlexec "github.com/block/ftl/internal/exec"
"github.com/block/ftl/internal/log"
Expand Down Expand Up @@ -314,13 +316,25 @@ func WaitWithTimeout(module string, timeout time.Duration) Action {

func WaitForDev(noErrors bool, msgAndArgs ...any) Action {
return func(t testing.TB, ic TestContext) {
ExecWithOutput("ftl", []string{"await-summary"}, func(output string) {
if noErrors {
assert.NotContains(t, output, "[Error]", msgAndArgs...)
} else {
assert.Contains(t, output, "[Error]", msgAndArgs...)
if noErrors {
Infof("Waiting for FTL Dev state with no errors")
} else {
Infof("Waiting for FTL Dev state with errors")
}
result, err := devstate.WaitForDevState(ic.Context, ic.BuildEngine, ic.Admin)
assert.NoError(t, err)

var errs []*languagepb.Error
for _, m := range result.Modules {
if m.Errors != nil {
errs = append(errs, m.Errors...)
}
})(t, ic)
}
if noErrors {
assert.Zero(t, errs, msgAndArgs...)
} else {
assert.NotZero(t, errs, msgAndArgs...)
}
}
}

Expand Down
22 changes: 16 additions & 6 deletions internal/integration/harness.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"context"
"errors"
"fmt"
"github.com/jpillora/backoff"
"io"
"os"
"path/filepath"
Expand All @@ -19,6 +18,8 @@ import (
"testing"
"time"

"github.com/jpillora/backoff"

"github.com/IBM/sarama"
"github.com/alecthomas/assert/v2"
"github.com/alecthomas/types/optional"
Expand All @@ -30,6 +31,7 @@ import (

"sigs.k8s.io/yaml"

"github.com/block/ftl/backend/protos/xyz/block/ftl/buildengine/v1/buildenginepbconnect"
"github.com/block/ftl/backend/protos/xyz/block/ftl/console/v1/consolepbconnect"
"github.com/block/ftl/backend/protos/xyz/block/ftl/timeline/v1/timelinepbconnect"
"github.com/block/ftl/backend/protos/xyz/block/ftl/v1/ftlv1connect"
Expand Down Expand Up @@ -378,6 +380,13 @@ func run(t *testing.T, actionsOrOptions ...ActionOrOption) {
assert.NoError(t, rpc.Wait(ctx, backoff.Backoff{Max: time.Millisecond * 50}, time.Minute*2, ic.Timeline))
}

if opts.devMode {
ic.BuildEngine = rpc.Dial(buildenginepbconnect.NewBuildEngineServiceClient, "http://localhost:8900", log.Debug)

Infof("Waiting for build engine client to be ready")
assert.NoError(t, rpc.Wait(ctx, backoff.Backoff{Max: time.Millisecond * 50}, time.Minute*2, ic.Timeline))
}

if opts.resetPubSub {
Infof("Resetting pubsub")
envars := []string{"COMPOSE_IGNORE_ORPHANS=True"}
Expand Down Expand Up @@ -491,11 +500,12 @@ type TestContext struct {
kubeNamespace string
devMode bool

Admin ftlv1connect.AdminServiceClient
Schema ftlv1connect.SchemaServiceClient
Console consolepbconnect.ConsoleServiceClient
Verbs ftlv1connect.VerbServiceClient
Timeline timelinepbconnect.TimelineServiceClient
Admin ftlv1connect.AdminServiceClient
Schema ftlv1connect.SchemaServiceClient
Console consolepbconnect.ConsoleServiceClient
Verbs ftlv1connect.VerbServiceClient
Timeline timelinepbconnect.TimelineServiceClient
BuildEngine buildenginepbconnect.BuildEngineServiceClient

realT *testing.T
}
Expand Down

0 comments on commit 56337c0

Please sign in to comment.