Skip to content

Commit 8ef5083

Browse files
committed
ci: configure binary coverage on cluster chaos integration tests and upload to Codecov
1 parent 8856ffa commit 8ef5083

3 files changed

Lines changed: 20 additions & 6 deletions

File tree

.github/workflows/test.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,12 @@ jobs:
3535
- name: Run unit & integration tests
3636
run: go test -v -race -coverprofile=coverage.txt -covermode=atomic ./...
3737

38+
- name: Run cluster chaos tests
39+
run: ./test-cluster-chaos.sh
40+
3841
- name: Upload coverage to Codecov
3942
uses: codecov/codecov-action@v4
4043
with:
4144
token: ${{ secrets.CODECOV_TOKEN }}
42-
files: ./coverage.txt
45+
files: ./coverage.txt,./coverage-chaos.txt
4346
fail_ci_if_error: true
44-
45-
- name: Run cluster chaos tests
46-
run: ./test-cluster-chaos.sh

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
*.pid
55
tmp-node*.etcd/
66
/default.etcd/
7+
/coverage-*.txt
8+
/coverage.txt
9+
/tmp-coverage/
710

811
# Go binary and build files
912
*.exe

test-cluster-chaos.sh

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
# test-cluster-chaos.sh - Automated 3-node etcd cluster chaos testing for conch
33
set -euo pipefail
44

5+
export GOCOVERDIR="./tmp-coverage"
6+
rm -rf "$GOCOVERDIR"
7+
mkdir -p "$GOCOVERDIR"
8+
9+
510
# Colors for log output
611
RED='\033[0;31m'
712
GREEN='\033[0;32m'
@@ -122,6 +127,12 @@ cleanup() {
122127
for port in 2379 2380 2381 2382 2383 2384; do
123128
fuser -k -n tcp "$port" &>/dev/null || true
124129
done
130+
131+
# Extract coverage data if any exists
132+
if [ -d "$GOCOVERDIR" ] && [ "$(ls -A "$GOCOVERDIR")" ]; then
133+
log "Generating binary coverage report from chaos tests..."
134+
go tool covdata textfmt -i="$GOCOVERDIR" -o=coverage-chaos.txt
135+
fi
125136
}
126137

127138
# Delete data dirs and log files strictly on a fresh start
@@ -198,8 +209,8 @@ success "3-node etcd cluster is HEALTHY and clustered!"
198209
"$ETCDCTL_BIN" --endpoints=127.0.0.1:2379 member list
199210

200211
# Re-compile to ensure conch binary is up to date
201-
log "Rebuilding conch binary..."
202-
go build -o conch cmd/conch/main.go
212+
log "Rebuilding conch binary with coverage instrumentation..."
213+
go build -cover -o conch cmd/conch/main.go
203214

204215
# ---------------------------------------------------------
205216
# Phase 1: Leadership Election with 3-node Consensus

0 commit comments

Comments
 (0)