Skip to content

Commit 64f7303

Browse files
authored
integration test coverage (#1382)
Signed-off-by: Angelo De Caro <adc@zurich.ibm.com>
1 parent b07fd4b commit 64f7303

7 files changed

Lines changed: 99 additions & 11 deletions

File tree

.github/workflows/tests.yml

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,16 @@ jobs:
7070
run: make testing-docker-images
7171

7272
- name: Unit Tests with Coverage
73-
run: make unit-tests
73+
run: |
74+
make unit-tests
75+
./ci/scripts/filter-coverage.sh profile.cov profile.cov
7476
7577
- name: Send coverage to Coveralls
7678
uses: shogo82148/actions-goveralls@v1
7779
with:
7880
path-to-profile: profile.cov
81+
flag-name: utest-${{ matrix.tests }}
82+
parallel: true
7983

8084
- name: Run ${{ matrix.tests }}
8185
run: make ${{ matrix.tests }}
@@ -165,4 +169,24 @@ jobs:
165169
make fxconfig configtxgen fabricx-docker-images
166170
167171
- name: Run ${{ matrix.tests }}
168-
run: make integration-tests-${{ matrix.tests }}
172+
run: |
173+
mkdir -p covdata
174+
GOCOVERDIR=$(realpath covdata) make integration-tests-${{ matrix.tests }}
175+
go tool covdata textfmt -i=covdata -o coverage.profile
176+
./ci/scripts/filter-coverage.sh coverage.profile coverage.profile
177+
178+
- name: Send coverage to Coveralls
179+
uses: shogo82148/actions-goveralls@v1
180+
with:
181+
path-to-profile: coverage.profile
182+
flag-name: itest-${{ matrix.tests }}
183+
parallel: true
184+
185+
publish-coverage:
186+
needs: [ utest, itest ]
187+
runs-on: ubuntu-latest
188+
steps:
189+
- name: Finish coverage report
190+
uses: shogo82148/actions-goveralls@v1
191+
with:
192+
parallel-finished: true

Makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ FAB_BINS ?= $(FABRIC_BINARY_BASE)/bin
1111

1212
# integration test options
1313
GINKGO_TEST_OPTS ?=
14-
GINKGO_TEST_OPTS += --keep-going
14+
GINKGO_TEST_OPTS += --keep-going -cover
1515

1616
TOP = .
1717

@@ -39,11 +39,13 @@ install-tools:
3939
download-fabric:
4040
./ci/scripts/download_fabric.sh $(FABRIC_BINARY_BASE) $(FABRIC_VERSION) $(FABRIC_CA_VERSION)
4141

42+
GO_TEST_PARAMS ?= -coverpkg=./... -coverprofile=profile.cov
43+
GO_PACKAGES = $(shell go list ./... | grep -v '/integration/' | grep -v 'regression' | grep -v 'mock' | grep -v 'protos-go' | grep -v 'testutils'; go list ./integration/nwo/...)
44+
4245
.PHONY: unit-tests
4346
# run standard unit tests
4447
unit-tests:
45-
@go test -coverprofile=profile.cov $(shell go list ./... | grep -v '/integration/' | grep -v 'regression' | grep -v 'mock' | grep -v 'protos-go' | grep -v 'testutils')
46-
cd integration/nwo/; go test -cover ./...
48+
@go test $(GO_TEST_PARAMS) $(GO_PACKAGES)
4749
cd token/services/storage/db/kvs/hashicorp/; go test -cover ./...
4850

4951
.PHONY: unit-tests-race

ci/scripts/filter-coverage.sh

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Copyright IBM Corp. All Rights Reserved.
4+
#
5+
# SPDX-License-Identifier: Apache-2.0
6+
#
7+
8+
set -euo pipefail
9+
10+
if [ "$#" -ne 2 ]; then
11+
echo "Usage: $0 <input-coverage-file> <output-file>"
12+
exit 1
13+
fi
14+
15+
INPUT="$1"
16+
OUTPUT="$2"
17+
18+
if [ ! -f "$INPUT" ]; then
19+
echo "Error: Input file '$INPUT' does not exist."
20+
exit 1
21+
fi
22+
23+
tmp="$(mktemp)"
24+
25+
# Ensure temp file is cleaned up on failure
26+
trap 'rm -f "$tmp"' EXIT
27+
28+
# We filter some of the files for test coverage reporting.
29+
awk '
30+
# Preserve mode line
31+
/^mode:/ { print; next }
32+
33+
# Exclude main.go
34+
/main\.go/ { next }
35+
36+
# Exclude generated protobuf files (*.pb.go)
37+
/\.pb\.go/ { next }
38+
39+
# Exclude mock and fake packages
40+
/\/mocks?\// { next } # Matches both /mock/ and /mocks/
41+
/\/fakes?\// { next } # Matches both /fake/ and /fakes/
42+
/[^\/]*mock[^\/]*\.go:/ { next } # Matches any file with mock in filename
43+
/[^\/]*fake[^\/]*\.go:/ { next } # Matches any file with fake in filename
44+
45+
# Exclude integration
46+
/\/integration\// { next }
47+
48+
# Exclude tools and docs
49+
/\/tools\// { next }
50+
/\/docs\// { next }
51+
52+
# Keep everything else
53+
{ print }
54+
' "$INPUT" > "$tmp"
55+
56+
# Atomically replace output
57+
mv "$tmp" "$OUTPUT"
58+
59+
# Disable trap since mv succeeded
60+
trap - EXIT
61+
62+
echo "Filtered coverage written to $OUTPUT"

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ require (
1313
github.com/gin-gonic/gin v1.11.0
1414
github.com/google/pprof v0.0.0-20260202012954-cb029daf43ef
1515
github.com/hashicorp/go-uuid v1.0.3
16-
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260217192656-b86312cc3cea
16+
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260219175226-8f512e10d1a0
1717
github.com/hyperledger/fabric-chaincode-go/v2 v2.3.0
1818
github.com/hyperledger/fabric-lib-go v1.1.3-0.20240523144151-25edd1eaf5f5
1919
github.com/hyperledger/fabric-protos-go-apiv2 v0.3.7

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,8 @@ github.com/huin/goupnp v1.3.0 h1:UvLUlWDNpoUdYzb2TCn+MuTWtcjXKSza2n6CBdQ0xXc=
10251025
github.com/huin/goupnp v1.3.0/go.mod h1:gnGPsThkYa7bFi/KWmEysQRf48l2dvR5bxr2OFckNX8=
10261026
github.com/hyperledger-labs/SmartBFT v0.0.0-20250503203013-eb005eef8866 h1:Mu/6NJsfl9g3wM15Ue7hqPq4LtgYDoABh8MO4u8aW4g=
10271027
github.com/hyperledger-labs/SmartBFT v0.0.0-20250503203013-eb005eef8866/go.mod h1:9aNHNXsCVy/leGz2gpTC1eOL5QecxbSAGjqsLh4T1LM=
1028-
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260217192656-b86312cc3cea h1:JEOjVR410ND4Ol26pUzMs9KkLicg2A89DBEZa7UrvcI=
1029-
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260217192656-b86312cc3cea/go.mod h1:DHm6Q7lmQC6TIEy++a/hmDNRi6q05bAfRt0v2wfzFGQ=
1028+
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260219175226-8f512e10d1a0 h1:iXfHzs9I08/ok4XuAbcxEcz5qa7nQF6+oImB5VOMo/0=
1029+
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260219175226-8f512e10d1a0/go.mod h1:DHm6Q7lmQC6TIEy++a/hmDNRi6q05bAfRt0v2wfzFGQ=
10301030
github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc h1:3Ykk6MtyfnlzMOQry9zkxsoLWpCWZwDPqehO/BJwArM=
10311031
github.com/hyperledger/aries-bbs-go v0.0.0-20240528084656-761671ea73bc/go.mod h1:Kofn6A6WWea1ZM8Rys5aBW9dszwJ7Ywa0kyyYL0TPYw=
10321032
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 h1:B1Nt8hKb//KvgGRprk0h1t4lCnwhE9/ryb1WqfZbV+M=

token/services/storage/db/kvs/hashicorp/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ require (
88
github.com/docker/docker v28.3.3+incompatible
99
github.com/docker/go-connections v0.6.0
1010
github.com/hashicorp/vault/api v1.16.0
11-
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260217192656-b86312cc3cea
11+
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260219175226-8f512e10d1a0
1212
github.com/hyperledger-labs/fabric-token-sdk v0.4.1-0.20250528165839-032fb9265504
1313
github.com/stretchr/testify v1.11.1
1414
github.com/test-go/testify v1.1.4

token/services/storage/db/kvs/hashicorp/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4=
140140
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
141141
github.com/hashicorp/vault/api v1.16.0 h1:nbEYGJiAPGzT9U4oWgaaB0g+Rj8E59QuHKyA5LhwQN4=
142142
github.com/hashicorp/vault/api v1.16.0/go.mod h1:KhuUhzOD8lDSk29AtzNjgAu2kxRA9jL9NAbkFlqvkBA=
143-
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260217192656-b86312cc3cea h1:JEOjVR410ND4Ol26pUzMs9KkLicg2A89DBEZa7UrvcI=
144-
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260217192656-b86312cc3cea/go.mod h1:DHm6Q7lmQC6TIEy++a/hmDNRi6q05bAfRt0v2wfzFGQ=
143+
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260219175226-8f512e10d1a0 h1:iXfHzs9I08/ok4XuAbcxEcz5qa7nQF6+oImB5VOMo/0=
144+
github.com/hyperledger-labs/fabric-smart-client v0.8.3-0.20260219175226-8f512e10d1a0/go.mod h1:DHm6Q7lmQC6TIEy++a/hmDNRi6q05bAfRt0v2wfzFGQ=
145145
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2 h1:B1Nt8hKb//KvgGRprk0h1t4lCnwhE9/ryb1WqfZbV+M=
146146
github.com/hyperledger/fabric-amcl v0.0.0-20230602173724-9e02669dceb2/go.mod h1:X+DIyUsaTmalOpmpQfIvFZjKHQedrURQ5t4YqquX7lE=
147147
github.com/hyperledger/fabric-lib-go v1.1.3-0.20240523144151-25edd1eaf5f5 h1:RPWTL5wxAb+xDOrsCU3QYZP65305F8v3PaOyzdbPVMU=

0 commit comments

Comments
 (0)