Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(zombienet): add zombienet testing to github workflow #3192

Merged
merged 8 commits into from
Apr 13, 2023
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
54 changes: 54 additions & 0 deletions .github/workflows/zombienet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: zombienet
run-name: Zombienet tests
on:
pull_request:

jobs:
zombienet-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.19
stable: true
check-latest: true

- name: Set cache variables
id: go-cache-paths
run: |
echo "::set-output name=go-build::$(go env GOCACHE)"
echo "::set-output name=go-mod::$(go env GOMODCACHE)"
- uses: actions/checkout@v3

- name: Go build cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-build }}
key: ${{ runner.os }}-go-build-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-build

- name: Go modules cache
uses: actions/cache@v3
with:
path: ${{ steps.go-cache-paths.outputs.go-mod }}
key: ${{ runner.os }}-go-mod-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-go-mod

- name: Run build
run: |
make build
echo "$HOME/work/gossamer/gossamer/bin" >> $GITHUB_PATH
- name: Install Zombienet
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
wget -O /usr/local/bin/zombienet https://github.com/paritytech/zombienet/releases/download/v1.3.41/zombienet-linux-x64
elif [ "$RUNNER_OS" == "macOS" ]; then
wget -O /usr/local/bin/zombienet https://github.com/paritytech/zombienet/releases/download/v1.3.41/zombienet-macos
else
echo "Zombienet for $RUNNER_OS is not supported"
exit 1
fi
chmod +x /usr/local/bin/zombienet
- name: Zombienet test
run: |
zombienet test -p native zombienet_tests/functional/0001-basic-network.zndsl
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ ifndef VERSION
VERSION=latest
endif
FULLDOCKERNAME=$(COMPANY)/$(NAME):$(VERSION)
OS:=$(shell uname)

.PHONY: help lint test install build clean start docker gossamer build-debug
all: help
Expand Down Expand Up @@ -127,3 +128,17 @@ gossamer: clean build
## install: install the gossamer binary in $GOPATH/bin
install: build
mv ./bin/gossamer $(GOPATH)/bin/gossamer

install-zombienet:
ifeq ($(OS),Darwin)
wget -O /usr/local/bin/zombienet https://github.com/paritytech/zombienet/releases/download/v1.3.41/zombienet-macos
else ifeq ($(OS),Linux)
wget -O $(GOPATH)/bin/zombienet https://github.com/paritytech/zombienet/releases/download/v1.3.41/zombienet-linux-x64
else
@echo "Zombienet for $(OS) is not supported"
exit 1
endif
chmod a+x $(GOPATH)/bin/zombienet

zombienet-test: install install-zombienet
zombienet test -p native zombienet_tests/functional/0001-basic-network.zndsl
4 changes: 2 additions & 2 deletions cmd/gossamer/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ var (
Aliases: []string{"unsafe-ws-external"}, // unsafe-ws-external is argument used by polkadot node
Usage: "Enable external access to websocket unsafe calls",
}
// RPCCorsFlag dummy flag provided to conform to polkadot flags
// RPCCorsFlag dummy flag provided to conform to polkadot flags, TODO: see issue #3205
RPCCorsFlag = cli.StringFlag{
Name: "rpc-cors",
Usage: "dummy place holder to conform with polkadot cli flags",
Expand Down Expand Up @@ -386,7 +386,7 @@ var (
// BABE flags
var (
ValidatorFlag = cli.BoolFlag{
Name: "validator", // TODO(ed) implement
Name: "validator",
}
)

Expand Down
8 changes: 8 additions & 0 deletions dot/network/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ var (
Name: "outbound_total",
Help: "total number of outbound streams",
})
processStartTimeGauge = promauto.NewGauge(prometheus.GaugeOpts{
Namespace: "substrate", // Note: this is using substrate namespace because that is what zombienet uses
// to confirm nodes have started TODO: consider other ways to handle this, see issue #3205
Name: "process_start_time_seconds",
Help: "gossamer process start seconds unix timestamp, " +
"using substrate namespace so zombienet detects node start",
})
)

type (
Expand Down Expand Up @@ -333,6 +340,7 @@ func (s *Service) Start() error {
logger.Info("started network service with supported protocols " + strings.Join(s.host.protocols(), ", "))

if s.Metrics.Publish {
processStartTimeGauge.Set(float64(time.Now().Unix()))
go s.updateMetrics()
}

Expand Down
22 changes: 22 additions & 0 deletions zombienet_tests/functional/0001-basic-network.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[relaychain]
chain_spec_path = "chain/westend-local/westend-local-spec-raw.json"

chain = "westend-local"

[[relaychain.nodes]]
name = "alice"
command = "gossamer"
validator = true
args = ["--key alice"]

[[relaychain.nodes]]
name = "bob"
command = "gossamer"
validator = true
args = ["--key bob"]

[[relaychain.nodes]]
name = "charlie"
command = "gossamer"
validator = true
args = ["--key charlie"]
15 changes: 15 additions & 0 deletions zombienet_tests/functional/0001-basic-network.zndsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Description: Small Network test
Network: ./0001-basic-network.toml
Creds: config

# metrics
alice: reports gossamer_network_node_peer_count_total is 2 within 30 seconds
alice: reports gossamer_network_syncer_is_synced is 1 within 30 seconds
bob: reports gossamer_network_node_peer_count_total is 2 within 30 seconds
bob: reports gossamer_network_syncer_is_synced is 1 within 30 seconds
charlie: reports gossamer_network_node_peer_count_total is 2 within 30 seconds
charlie: reports gossamer_network_syncer_is_synced is 1 within 30 seconds

alice: log line matches "built block [0-9]+" within 30 seconds
bob: log line matches "built block [0-9]+" within 30 seconds
charlie: log line matches "built block [0-9]+" within 30 seconds