Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run slow tests in parallel #3883

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions test/preflight/apps_v2_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,19 @@ func TestLaunchDetach(t *testing.T) {
require.Contains(f, res.StdOutString(), "success")
}

func TestDeployDetach(t *testing.T) {
func WithParallel(f func(*testing.T)) func(*testing.T) {
return func(t *testing.T) {
t.Parallel()
f(t)
}
}

func TestDeploy(t *testing.T) {
t.Run("Detach", WithParallel(testDeployDetach))
t.Run("DetachBatching", WithParallel(testDeployDetachBatching))
}

func testDeployDetach(t *testing.T) {
f := testlib.NewTestEnvFromEnv(t)
appName := f.CreateRandomAppName()

Expand All @@ -428,7 +440,7 @@ func TestDeployDetach(t *testing.T) {
require.Contains(f, res.StdOutString(), "started")
}

func TestDeployDetachBatching(t *testing.T) {
func testDeployDetachBatching(t *testing.T) {
f := testlib.NewTestEnvFromEnv(t)
appName := f.CreateRandomAppName()

Expand Down
22 changes: 16 additions & 6 deletions test/preflight/fly_postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,12 @@ func assertPostgresIsUp(tb testing.TB, f *testlib.FlyctlTestEnv, appName string)
assert.Equal(tb, 0, ssh.ExitCode(), "failed to connect to postgres at %s: %s", appName, ssh.StdErr())
}

func TestPostgres_ImportSuccess(t *testing.T) {
func TestPostgresImport(t *testing.T) {
t.Run("Success", WithParallel(testPostgresImportSuccess))
t.Run("Failure", WithParallel(testPostgresImportFailure))
}

func testPostgresImportSuccess(t *testing.T) {
f := testlib.NewTestEnvFromEnv(t)

// Since this explicitly sets a size, no need to test on GPUs/alternate
Expand All @@ -188,14 +193,11 @@ func TestPostgres_ImportSuccess(t *testing.T) {
firstAppName := f.CreateRandomAppName()
secondAppName := f.CreateRandomAppName()

t.Logf("Create app_names table on %s", firstAppName)
f.Fly(
"pg create --org %s --name %s --region %s --initial-cluster-size 1 --vm-size %s --volume-size 1 --password x",
f.OrgSlug(), firstAppName, f.PrimaryRegion(), postgresMachineSize,
)
f.Fly(
"pg create --org %s --name %s --region %s --initial-cluster-size 1 --vm-size %s --volume-size 1",
f.OrgSlug(), secondAppName, f.PrimaryRegion(), postgresMachineSize,
)
assert.EventuallyWithT(t, func(c *assert.CollectT) {
assertPostgresIsUp(t, f, firstAppName)
}, 1*time.Minute, 10*time.Second)
Expand All @@ -209,6 +211,14 @@ func TestPostgres_ImportSuccess(t *testing.T) {
firstAppName, firstAppName,
)

t.Logf("Import from %s to %s", firstAppName, secondAppName)
f.Fly(
"pg create --org %s --name %s --region %s --initial-cluster-size 1 --vm-size %s --volume-size 1",
f.OrgSlug(), secondAppName, f.PrimaryRegion(), postgresMachineSize,
)
assert.EventuallyWithT(t, func(c *assert.CollectT) {
assertPostgresIsUp(t, f, secondAppName)
}, 1*time.Minute, 10*time.Second)
f.Fly(
"pg import -a %s --region %s --vm-size %s postgres://postgres:x@%s.internal/postgres",
secondAppName, f.PrimaryRegion(), postgresMachineSize, firstAppName,
Expand All @@ -227,7 +237,7 @@ func TestPostgres_ImportSuccess(t *testing.T) {
}, 2*time.Minute, 10*time.Second, "import machine not destroyed")
}

func TestPostgres_ImportFailure(t *testing.T) {
func testPostgresImportFailure(t *testing.T) {
f := testlib.NewTestEnvFromEnv(t)

// Since this explicitly sets a size, no need to test on GPUs/alternate
Expand Down
Loading