Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/github_actions/actions/checkout-4
Browse files Browse the repository at this point in the history
  • Loading branch information
owenthereal authored Oct 2, 2023
2 parents 606f47b + 74fec4c commit 955ce58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -21,15 +21,15 @@ 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
with:
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
Expand All @@ -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
Expand Down
20 changes: 12 additions & 8 deletions server/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func Test_Server(t *testing.T) {
HttpsAddr: httpsAddr,
AdminAddr: adminAddr,
DnsAddr: dnsAddr,
Debug: true,
})
errch := make(chan error)

Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 955ce58

Please sign in to comment.