Skip to content

Commit

Permalink
multi: add test coverage for integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
guggero committed Mar 21, 2024
1 parent 15c7686 commit 4e6fcc4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 3 deletions.
11 changes: 10 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,16 @@ jobs:
run: ./scripts/install_bitcoind.sh $BITCOIN_VERSION

- name: run ${{ matrix.name }}
run: make itest-parallel ${{ matrix.args }}
run: make itest-parallel ${{ matrix.args }} cover=true

- name: convert coverage data
run: go tool covdata textfmt -i=itest/cover -o itest/coverage.txt

- name: Send coverage
uses: shogo82148/actions-goveralls@v1
with:
path-to-profile: itest/coverage.txt
parallel: true

- name: Zip log files on failure
if: ${{ failure() }}
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ itest/.minerlogs
itest/lnd-itest
itest/btcd-itest
itest/.logs-*
itest/cover

cmd/cmd
*.key
Expand Down Expand Up @@ -68,6 +69,7 @@ profile.tmp

# Coverage test
coverage.txt
itest/coverage.txt

# Visual Studio cache/options directory
.vs/
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ build:
build-itest:
@$(call print, "Building itest btcd and lnd.")
CGO_ENABLED=0 $(GOBUILD) -tags="integration" -o itest/btcd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(BTCD_PKG)
CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" -o itest/lnd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(PKG)/cmd/lnd
CGO_ENABLED=0 $(GOBUILD) -tags="$(ITEST_TAGS)" $(ITEST_COVERAGE) -o itest/lnd-itest$(EXEC_SUFFIX) $(DEV_LDFLAGS) $(PKG)/cmd/lnd

@$(call print, "Building itest binary for ${backend} backend.")
CGO_ENABLED=0 $(GOTEST) -v ./itest -tags="$(DEV_TAGS) $(RPC_TAGS) integration $(backend)" -c -o itest/itest.test$(EXEC_SUFFIX)
Expand Down
8 changes: 7 additions & 1 deletion make/testing_flags.mk
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ DEV_TAGS = dev
RPC_TAGS = autopilotrpc chainrpc invoicesrpc neutrinorpc peersrpc routerrpc signrpc verrpc walletrpc watchtowerrpc wtclientrpc
LOG_TAGS =
TEST_FLAGS =
ITEST_FLAGS =
ITEST_FLAGS =
ITEST_COVERAGE =
EXEC_SUFFIX =
COVER_PKG = $$(go list -deps -tags="$(DEV_TAGS)" ./... | grep '$(PKG)' | grep -v lnrpc)
NUM_ITEST_TRANCHES = 4
Expand Down Expand Up @@ -77,6 +78,11 @@ ifneq ($(tags),)
DEV_TAGS += ${tags}
endif

# Enable integration test coverage (requires Go >= 1.20.0).
ifneq ($(cover),)
ITEST_COVERAGE = -cover
endif

# Define the log tags that will be applied only when running unit tests. If none
# are provided, we default to "nolog" which will be silent.
ifneq ($(log),)
Expand Down
2 changes: 2 additions & 0 deletions scripts/itest_part.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ shift
EXEC="$WORKDIR"/itest.test"$EXEC_SUFFIX"
LND_EXEC="$WORKDIR"/lnd-itest"$EXEC_SUFFIX"
BTCD_EXEC="$WORKDIR"/btcd-itest"$EXEC_SUFFIX"
export GOCOVERDIR="$WORKDIR/cover"
mkdir -p "$GOCOVERDIR"
echo $EXEC -test.v "$@" -logoutput -logdir=.logs-tranche$TRANCHE -lndexec=$LND_EXEC -btcdexec=$BTCD_EXEC -splittranches=$NUM_TRANCHES -runtranche=$TRANCHE

# Exit code 255 causes the parallel jobs to abort, so if one part fails the
Expand Down

0 comments on commit 4e6fcc4

Please sign in to comment.