diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 760ae1b..a21cb30 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -7,7 +7,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-latest] + os: [macos-13, ubuntu-latest] steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 @@ -21,7 +21,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-latest] + os: [macos-13, ubuntu-latest] steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 @@ -29,7 +29,7 @@ jobs: go-version-file: go.mod check-latest: true - name: Install certutil on macos - if: ${{ matrix.os == 'macos-latest' }} + if: ${{ matrix.os == 'macos-13' }} run: | brew install nss - name: Test @@ -39,7 +39,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [macos-latest, ubuntu-latest] + os: [macos-13, ubuntu-latest] steps: - uses: actions/checkout@v4 - uses: actions/setup-go@v4 diff --git a/server/server_test.go b/server/server_test.go index e42e01a..d49aba4 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -39,6 +39,7 @@ func Test_Server(t *testing.T) { HttpsAddr: httpsAddr, AdminAddr: adminAddr, DnsAddr: dnsAddr, + Debug: true, }) errch := make(chan error) @@ -54,8 +55,12 @@ func Test_Server(t *testing.T) { errch <- err }() + http := &http.Client{ + Timeout: 2 * time.Second, + } + t.Run("http addr", func(t *testing.T) { - waitUntil(t, 3, func() error { + waitUntil(t, 5*time.Second, 10, func() error { resp, err := http.Get(fmt.Sprintf("http://%s/config/apps/http/servers/http/listen/0", adminAddr)) if err != nil { return err @@ -77,7 +82,7 @@ func Test_Server(t *testing.T) { }) t.Run("https addr", func(t *testing.T) { - waitUntil(t, 3, func() error { + waitUntil(t, 5*time.Second, 10, func() error { resp, err := http.Get(fmt.Sprintf("http://%s/config/apps/http/servers/https/listen/0", adminAddr)) if err != nil { return err @@ -99,7 +104,7 @@ func Test_Server(t *testing.T) { }) t.Run("tls subjects", func(t *testing.T) { - waitUntil(t, 3, func() error { + waitUntil(t, 5*time.Second, 10, func() error { resp, err := http.Get(fmt.Sprintf("http://%s/config/apps/tls/automation/policies/0/subjects", adminAddr)) if err != nil { return nil @@ -144,7 +149,7 @@ func Test_Server(t *testing.T) { t.Fatal(err) } - waitUntil(t, 3, func() error { + waitUntil(t, 5*time.Second, 10, func() error { r := &net.Resolver{ PreferGo: true, Dial: func(ctx context.Context, network, address string) (net.Conn, error) { @@ -302,7 +307,7 @@ func randomPort(t *testing.T) string { return strconv.Itoa(listener.Addr().(*net.TCPAddr).Port) } -func waitUntil(tb testing.TB, times int, fn func() error) { +func waitUntil(tb testing.TB, waitInterval time.Duration, times int, fn func() error) { tb.Helper() var err error @@ -312,9 +317,8 @@ func waitUntil(tb testing.TB, times int, fn func() error) { return } - tb.Logf("Failing to execute wait func: %s", err.Error()) - - time.Sleep(time.Duration(tries*tries) * time.Second) + tb.Logf("waiting, got error: %s", err) + time.Sleep(waitInterval) } tb.Fatal(err)