From 5ba0d131c461a469b2ad8eddf99aded18efcb3ff Mon Sep 17 00:00:00 2001 From: William Banfield <4561443+williambanfield@users.noreply.github.com> Date: Fri, 2 Dec 2022 13:37:33 -0500 Subject: [PATCH] e2e: setup testing for multi-version (#9819) This pull requests sets up the e2e tests to be able to support multiple versions within the same test network. This is achieved through a few simple changes: * Each node takes a `version` parameter in the testnet manifest. This dictates which version of the testapp to use. If not set, the locally available version is used. * Adds a `testapp-docker.yml` workflow that publishes the testapp to docker hub so that tagged versions may be available for use in a multi-version test network. This change does not actually add a testnetwork that does multi-version testing. Since no previous versions of the testapp have been published to dockerhub, there are not old versions available to test against. We'll either need to configure this after the next minor release which will trigger a testapp to be pushed to dockerhub, or push an image from the previous version of Tendermint so that the multiversion test has an old version to pull. #### PR checklist - [ ] Tests written/updated, or no tests needed - [ ] `CHANGELOG_PENDING.md` updated, or no changelog entry needed - [ ] Updated relevant documentation (`docs/`) and code comments, or no documentation updates needed --- .../{docker.yml => tendermint-docker.yml} | 0 .github/workflows/testapp-docker.yml | 60 +++++++++++++++++++ test/e2e/Makefile | 2 +- test/e2e/pkg/infra/docker/docker.go | 2 +- test/e2e/pkg/manifest.go | 7 +++ test/e2e/pkg/testnet.go | 6 ++ 6 files changed, 75 insertions(+), 2 deletions(-) rename .github/workflows/{docker.yml => tendermint-docker.yml} (100%) create mode 100644 .github/workflows/testapp-docker.yml diff --git a/.github/workflows/docker.yml b/.github/workflows/tendermint-docker.yml similarity index 100% rename from .github/workflows/docker.yml rename to .github/workflows/tendermint-docker.yml diff --git a/.github/workflows/testapp-docker.yml b/.github/workflows/testapp-docker.yml new file mode 100644 index 000000000..9e8e59a47 --- /dev/null +++ b/.github/workflows/testapp-docker.yml @@ -0,0 +1,60 @@ +name: Testapp Docker +# Build & Push rebuilds the Testapp docker image on every push to main and creation of tags +# and pushes the image to https://hub.docker.com/r/tendermint/testapp +on: + push: + branches: + - main + tags: + - "v[0-9]+.[0-9]+.[0-9]+" # Push events to matching v*, i.e. v1.0, v20.15.10 + - "v[0-9]+.[0-9]+.[0-9]+-alpha.[0-9]+" # e.g. v0.37.0-alpha.1, v0.38.0-alpha.10 + - "v[0-9]+.[0-9]+.[0-9]+-beta.[0-9]+" # e.g. v0.37.0-beta.1, v0.38.0-beta.10 + - "v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+" # e.g. v0.37.0-rc1, v0.38.0-rc10 + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Prepare + id: prep + run: | + DOCKER_IMAGE=tendermint/testapp + VERSION=noop + if [[ $GITHUB_REF == refs/tags/* ]]; then + VERSION=${GITHUB_REF#refs/tags/} + elif [[ $GITHUB_REF == refs/heads/* ]]; then + VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g') + if [ "${{ github.event.repository.default_branch }}" = "$VERSION" ]; then + VERSION=latest + fi + fi + TAGS="${DOCKER_IMAGE}:${VERSION}" + if [[ $VERSION =~ ^v[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then + TAGS="$TAGS,${DOCKER_IMAGE}:${VERSION}" + fi + echo "tags=${TAGS}" >> $GITHUB_OUTPUT + + - name: Set up QEMU + uses: docker/setup-qemu-action@master + with: + platforms: all + + - name: Set up Docker Build + uses: docker/setup-buildx-action@v2.2.1 + + - name: Login to DockerHub + if: ${{ github.event_name != 'pull_request' }} + uses: docker/login-action@v2.1.0 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Publish to Docker Hub + uses: docker/build-push-action@v3.2.0 + with: + context: . + file: ./test/e2e/docker/Dockerfile + platforms: linux/amd64,linux/arm64 + push: ${{ github.event_name != 'beep_boop' }} + tags: ${{ steps.prep.outputs.tags }} diff --git a/test/e2e/Makefile b/test/e2e/Makefile index 8bafe7ca9..7a82f8236 100644 --- a/test/e2e/Makefile +++ b/test/e2e/Makefile @@ -1,7 +1,7 @@ all: docker generator runner docker: - docker build --tag tendermint/e2e-node -f docker/Dockerfile ../.. + docker build --tag tendermint/e2e-node --tag tendermint/e2e-node:local-version -f docker/Dockerfile ../.. # We need to build support for database backends into the app in # order to build a binary with a Tendermint node in it (for built-in diff --git a/test/e2e/pkg/infra/docker/docker.go b/test/e2e/pkg/infra/docker/docker.go index 04811aab5..5c118f03b 100644 --- a/test/e2e/pkg/infra/docker/docker.go +++ b/test/e2e/pkg/infra/docker/docker.go @@ -57,7 +57,7 @@ services: labels: e2e: true container_name: {{ .Name }} - image: tendermint/e2e-node + image: tendermint/e2e-node:{{ .Version }} {{- if eq .ABCIProtocol "builtin" }} entrypoint: /usr/bin/entrypoint-builtin {{- end }} diff --git a/test/e2e/pkg/manifest.go b/test/e2e/pkg/manifest.go index 814ae61c7..0a9a1da5f 100644 --- a/test/e2e/pkg/manifest.go +++ b/test/e2e/pkg/manifest.go @@ -81,6 +81,13 @@ type ManifestNode struct { // is generated), and seed nodes run in seed mode with the PEX reactor enabled. Mode string `toml:"mode"` + // Version specifies which version of Tendermint this node is. Specifying different + // versions for different nodes allows for testing the interaction of different + // node's compatibility. Note that in order to use a node at a particular version, + // there must be a docker image of the test app tagged with this version present + // on the machine where the test is being run. + Version string `toml:"version"` + // SyncApp specifies whether this node should use a synchronized application // with an unsynchronized local client. By default this is `false`, meaning // that the node will run an unsynchronized application with a synchronized diff --git a/test/e2e/pkg/testnet.go b/test/e2e/pkg/testnet.go index 8d0d674db..2bd16f8c1 100644 --- a/test/e2e/pkg/testnet.go +++ b/test/e2e/pkg/testnet.go @@ -79,6 +79,7 @@ type Testnet struct { // Node represents a Tendermint node in a testnet. type Node struct { Name string + Version string Testnet *Testnet Mode Mode SyncApp bool // Should we use a synchronized app with an unsynchronized local client? @@ -169,8 +170,13 @@ func LoadTestnet(manifest Manifest, fname string, ifd InfrastructureData) (*Test if !ok { return nil, fmt.Errorf("information for node '%s' missing from infrastucture data", name) } + v := nodeManifest.Version + if v == "" { + v = "local-version" + } node := &Node{ Name: name, + Version: v, Testnet: testnet, PrivvalKey: keyGen.Generate(manifest.KeyType), NodeKey: keyGen.Generate("ed25519"),