File tree Expand file tree Collapse file tree 5 files changed +471
-5
lines changed
Expand file tree Collapse file tree 5 files changed +471
-5
lines changed Original file line number Diff line number Diff line change 2020 verbose : true
2121 env :
2222 CODECOV_TOKEN : ${{ secrets.CODECOV_TOKEN }}
23+
24+ integration :
25+ runs-on : ubuntu-latest
26+ services :
27+ consul :
28+ image : hashicorp/consul:latest
29+ ports :
30+ - 8500:8500
31+ options : --health-cmd="consul members" --health-interval=2s --health-timeout=5s --health-retries=10
32+ steps :
33+ - uses : actions/checkout@v4.2.2
34+ - uses : actions/setup-go@v5.4.0
35+ with :
36+ go-version : ' 1.25'
37+ - name : Run integration tests
38+ run : go env -w GOTOOLCHAIN=go1.25.0+auto && go test -v -tags=integration -race ./...
39+ env :
40+ CONSUL_HTTP_ADDR : http://localhost:8500
Original file line number Diff line number Diff line change 1+ .PHONY : build test test-race test-coverage test-integration integration-up integration-down clean
2+
3+ build :
4+ go build -v ./...
5+
6+ test :
7+ go test -v ./...
8+
9+ test-race :
10+ go test -v -race ./...
11+
12+ test-coverage :
13+ go test -coverpkg=./... ./... -race -coverprofile=coverage.out -covermode=atomic
14+ go tool cover -html=coverage.out -o coverage.html
15+
16+ test-integration : integration-up
17+ CONSUL_HTTP_ADDR=http://localhost:8500 go test -v -tags=integration -race ./... ; \
18+ status=$$? ; \
19+ $(MAKE ) integration-down ; \
20+ exit $$ status
21+
22+ integration-up :
23+ docker compose -f configs/integration/docker-compose.yaml up -d --wait
24+
25+ integration-down :
26+ docker compose -f configs/integration/docker-compose.yaml down -v
27+
28+ clean :
29+ rm -f coverage.out coverage.html
30+ go clean -testcache
Original file line number Diff line number Diff line change 1+ services :
2+ consul :
3+ image : hashicorp/consul:latest
4+ container_name : consul-integration
5+ command : " agent -dev -bind=0.0.0.0 -client=0.0.0.0"
6+ ports :
7+ - " 8500:8500"
8+ healthcheck :
9+ test : ["CMD", "consul", "members"]
10+ interval : 2s
11+ timeout : 5s
12+ retries : 10
Original file line number Diff line number Diff line change @@ -767,10 +767,10 @@ func (b *Ballot) releaseSession() error {
767767 return nil
768768 }
769769 sessionID := * sessionIDPtr
770- _ , err := b .client .Session ().Destroy (sessionID , nil )
771- if err != nil {
772- return err
773- }
770+ // Always clear the local session state, even if Destroy fails.
771+ // The session may have already been invalidated by Consul (e.g., due to
772+ // health check failure), but we should still clear our local state.
774773 b .sessionID .Store ((* string )(nil ))
775- return nil
774+ _ , err := b .client .Session ().Destroy (sessionID , nil )
775+ return err
776776}
You can’t perform that action at this time.
0 commit comments