Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,21 @@ jobs:
verbose: true
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

integration:
runs-on: ubuntu-latest
services:
consul:
image: hashicorp/consul:latest
ports:
- 8500:8500
options: --health-cmd="consul members" --health-interval=2s --health-timeout=5s --health-retries=10
steps:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
go-version: '1.25'
- name: Run integration tests
run: go env -w GOTOOLCHAIN=go1.25.0+auto && go test -v -tags=integration -race ./...
env:
CONSUL_HTTP_ADDR: http://localhost:8500
30 changes: 30 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
.PHONY: build test test-race test-coverage test-integration integration-up integration-down clean

build:
go build -v ./...

test:
go test -v ./...

test-race:
go test -v -race ./...

test-coverage:
go test -coverpkg=./... ./... -race -coverprofile=coverage.out -covermode=atomic
go tool cover -html=coverage.out -o coverage.html

test-integration: integration-up
CONSUL_HTTP_ADDR=http://localhost:8500 go test -v -tags=integration -race ./... ; \
status=$$? ; \
$(MAKE) integration-down ; \
exit $$status

integration-up:
docker compose -f configs/integration/docker-compose.yaml up -d --wait

integration-down:
docker compose -f configs/integration/docker-compose.yaml down -v

clean:
rm -f coverage.out coverage.html
go clean -testcache
12 changes: 12 additions & 0 deletions configs/integration/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
consul:
image: hashicorp/consul:latest
container_name: consul-integration
command: "agent -dev -bind=0.0.0.0 -client=0.0.0.0"
ports:
- "8500:8500"
healthcheck:
test: ["CMD", "consul", "members"]
interval: 2s
timeout: 5s
retries: 10
10 changes: 5 additions & 5 deletions internal/ballot/ballot.go
Original file line number Diff line number Diff line change
Expand Up @@ -767,10 +767,10 @@ func (b *Ballot) releaseSession() error {
return nil
}
sessionID := *sessionIDPtr
_, err := b.client.Session().Destroy(sessionID, nil)
if err != nil {
return err
}
// Always clear the local session state, even if Destroy fails.
// The session may have already been invalidated by Consul (e.g., due to
// health check failure), but we should still clear our local state.
b.sessionID.Store((*string)(nil))
return nil
_, err := b.client.Session().Destroy(sessionID, nil)
return err
}
Loading