Skip to content

Commit

Permalink
test: TestAppsV2Example was broken (#3874)
Browse files Browse the repository at this point in the history
* test: waiting for a minute is not enough for `fly pg import`

`fly pg import` makes an ephemeral machine which could linger for
more than a minute sometimes.

* test: TestAppsV2Example was broken

The test is broken since #3733.

* test: don't skip TestAppsV2Example

This might be the reason the test was broken.
  • Loading branch information
kzys authored Aug 21, 2024
1 parent a30f319 commit 34699b2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
13 changes: 7 additions & 6 deletions test/preflight/apps_v2_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,14 @@ import (
"testing"
"time"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
fly "github.com/superfly/fly-go"
"github.com/superfly/flyctl/internal/appconfig"
"github.com/superfly/flyctl/test/preflight/testlib"
)

func TestAppsV2Example(t *testing.T) {
if testing.Short() {
t.Skip()
}

f := testlib.NewTestEnvFromEnv(t)
appName := f.CreateRandomAppName()
appUrl := fmt.Sprintf("https://%s.fly.dev", appName)
Expand All @@ -50,9 +47,13 @@ func TestAppsV2Example(t *testing.T) {
require.Nil(t, firstMachine.Config.DisableMachineAutostart)
require.Equal(t, 1, len(firstMachine.Config.Services))
require.NotNil(t, firstMachine.Config.Services[0].Autostart)
require.NotNil(t, firstMachine.Config.Services[0].Autostop)
require.True(t, *firstMachine.Config.Services[0].Autostart)
require.Equal(t, fly.MachineAutostopOff, *firstMachine.Config.Services[0].Autostop)

require.NotNil(t, firstMachine.Config.Services[0].Autostop)
assert.Equal(
t, fly.MachineAutostopStop, *firstMachine.Config.Services[0].Autostop,
"autostop must be enabled",
)

secondReg := f.PrimaryRegion()
if len(f.OtherRegions()) > 0 {
Expand Down
9 changes: 5 additions & 4 deletions test/preflight/fly_postgres_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package preflight

import (
"fmt"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -158,12 +159,12 @@ func assertMachineCount(tb testing.TB, f *testlib.FlyctlTestEnv, appName string,
tb.Helper()

machines := f.MachinesList(appName)
var s string

var xs []string
for _, m := range machines {
s += fmt.Sprintf("machine %s (image: %s)", m.ID, m.FullImageRef())
xs = append(xs, fmt.Sprintf("machine %s (image: %s)", m.ID, m.FullImageRef()))
}
assert.Len(tb, machines, expected, "expected %d machine(s) but got %s", expected, s)
assert.Len(tb, machines, expected, "expected %d machine(s) but got %s", expected, strings.Join(xs, ", "))
}

// assertPostgresIsUp checks that the given Postgres server is really up.
Expand Down Expand Up @@ -223,7 +224,7 @@ func TestPostgres_ImportSuccess(t *testing.T) {
// Wait for the importer machine to be destroyed.
assert.EventuallyWithT(t, func(c *assert.CollectT) {
assertMachineCount(t, f, secondAppName, 1)
}, 1*time.Minute, 10*time.Second, "import machine not destroyed")
}, 2*time.Minute, 10*time.Second, "import machine not destroyed")
}

func TestPostgres_ImportFailure(t *testing.T) {
Expand Down

0 comments on commit 34699b2

Please sign in to comment.