Skip to content

Commit

Permalink
bugfix: avoid test parallelism as it will cause issues with sockets (…
Browse files Browse the repository at this point in the history
…port 8443 already in use)

bugfix: When awaiting health it should actually shut down the server if not healthy after a while.
  • Loading branch information
Peter Van Bouwel committed Feb 6, 2025
1 parent bfced7b commit c2eb2e1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,5 @@ jobs:
- name: Test
# As we use config files from time to time we always want to run without cache
run: go clean -testcache && go test -coverprofile cover.out -v ./...
# We avoid parallelism as otherwise we risk conflicts on ports for sockets
run: go clean -testcache && go test -p 1 -coverprofile cover.out -v ./...
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ RUN go mod download
RUN go mod tidy
ADD . /usr/src/fakes3pp/
ENV NO_TESTING_BACKENDS=container_build
RUN go test -coverprofile cover.out ./...
RUN go test -p 1 -coverprofile cover.out ./...
RUN go vet
RUN CGO_ENABLED=0 GOOS=linux go build -o main .

Expand Down
7 changes: 6 additions & 1 deletion server/server.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package server

import (
"context"
"crypto/tls"
"fmt"
"log/slog"
Expand Down Expand Up @@ -63,7 +64,11 @@ func CreateAndAwaitHealthy(s Serverable) (*sync.WaitGroup, *http.Server, error)
tlsEnabled, _, _ := s.GetTls()
err = awaitServerOnPort(s.GetPort(), tlsEnabled)
if err != nil {
serverDone.Done()
err2 := srv.Shutdown(context.Background())
if err2 != nil {
err = fmt.Errorf("error shutting down unhealthy server: %w", err2)
}
serverDone.Wait()
return nil, nil, err
}

Expand Down

0 comments on commit c2eb2e1

Please sign in to comment.