From 0d82dbe2401d4be2430ba24ee3c486f814dd1c41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Soko=C5=82owski?= Date: Thu, 4 Jul 2024 12:50:15 +0200 Subject: [PATCH] feat(ci)_: add Jenkinsfile, Dockerfile for RPC tests MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also add curl to Docker image. Signed-off-by: Jakub SokoĊ‚owski --- Makefile | 6 +- _assets/build/Dockerfile | 2 +- _assets/ci/Jenkinsfile.tests-rpc | 57 +++++++++++++++++++ integration-tests/Dockerfile.tests-rpc | 18 ++++++ .../docker-compose.test.status-go.yml | 18 ++++++ integration-tests/pytest.ini | 2 +- 6 files changed, 100 insertions(+), 3 deletions(-) create mode 100644 _assets/ci/Jenkinsfile.tests-rpc create mode 100644 integration-tests/Dockerfile.tests-rpc diff --git a/Makefile b/Makefile index eda9a6f82..4491e3d66 100644 --- a/Makefile +++ b/Makefile @@ -491,7 +491,11 @@ test-verif-proxy-wrapper: run-integration-tests: SHELL := /bin/sh run-integration-tests: - docker-compose -f integration-tests/docker-compose.anvil.yml -f integration-tests/docker-compose.test.status-go.yml up --remove-orphans --build + docker-compose -f integration-tests/docker-compose.anvil.yml -f integration-tests/docker-compose.test.status-go.yml up -d --build --remove-orphans; \ + docker-compose -f integration-tests/docker-compose.anvil.yml -f integration-tests/docker-compose.test.status-go.yml logs -f tests-rpc; \ + exit_code=$$(docker inspect integration-tests_tests-rpc_1 -f '{{.State.ExitCode}}'); \ + docker-compose -f integration-tests/docker-compose.anvil.yml -f integration-tests/docker-compose.test.status-go.yml down; \ + exit $$exit_code run-anvil: SHELL := /bin/sh run-anvil: diff --git a/_assets/build/Dockerfile b/_assets/build/Dockerfile index 0d0522269..ec54e364e 100644 --- a/_assets/build/Dockerfile +++ b/_assets/build/Dockerfile @@ -22,7 +22,7 @@ LABEL maintainer="support@status.im" LABEL source="https://github.com/status-im/status-go" LABEL description="status-go is an underlying part of Status - a browser, messenger, and gateway to a decentralized world." -RUN apk add --no-cache ca-certificates bash libgcc libstdc++ +RUN apk add --no-cache ca-certificates bash libgcc libstdc++ curl RUN mkdir -p /static/keys RUN mkdir -p /static/configs diff --git a/_assets/ci/Jenkinsfile.tests-rpc b/_assets/ci/Jenkinsfile.tests-rpc new file mode 100644 index 000000000..7ccb680de --- /dev/null +++ b/_assets/ci/Jenkinsfile.tests-rpc @@ -0,0 +1,57 @@ +library 'status-jenkins-lib@v1.8.17' + +pipeline { + agent { label 'linux && x86_64 && nix-2.19' } + + parameters { + string( + name: 'BRANCH', + defaultValue: 'develop', + description: 'Name of branch to build.' + ) + } + + options { + timestamps() + /* Prevent Jenkins jobs from running forever */ + timeout(time: 30, unit: 'MINUTES') + disableConcurrentBuilds() + /* manage how many builds we keep */ + buildDiscarder(logRotator( + numToKeepStr: '5', + daysToKeepStr: '30', + artifactNumToKeepStr: '1', + )) + } + + environment { + PLATFORM = 'tests-rpc' + PKG_URL = "${currentBuild.absoluteUrl}/consoleText" + } + + stages { + stage('RPC Tests') { + steps { script { + sh 'make run-integration-tests' + } } + } + } // stages + + post { + always { + script { + archiveArtifacts artifacts: '**/results.xml', allowEmptyArchive: true + + junit( + testResults: '**/results.xml', + skipOldReports: true, + skipPublishingChecks: true, + skipMarkingBuildUnstable: true + ) + } + } + success { script { github.notifyPR(true) } } + failure { script { github.notifyPR(false) } } + cleanup { sh "make git-clean" } + } // post +} // pipeline diff --git a/integration-tests/Dockerfile.tests-rpc b/integration-tests/Dockerfile.tests-rpc new file mode 100644 index 000000000..28d7b1d71 --- /dev/null +++ b/integration-tests/Dockerfile.tests-rpc @@ -0,0 +1,18 @@ +FROM python:3.10.14-slim AS build + +RUN apt-get update && apt-get install -y gcc python3-dev +RUN python -m venv /opt/venv +ENV PATH="/opt/venv/bin:$PATH" +COPY requirements.txt . +RUN pip install --upgrade pip +RUN pip install -r requirements.txt + +FROM python:3.10.14-slim AS run + +ENV PATH="/opt/venv/bin:$PATH" +COPY --from=build /opt/venv /opt/venv + +WORKDIR tests-rpc +COPY . . + +ENTRYPOINT ["pytest"] diff --git a/integration-tests/docker-compose.test.status-go.yml b/integration-tests/docker-compose.test.status-go.yml index 2cdab3e1b..dfa3a2115 100644 --- a/integration-tests/docker-compose.test.status-go.yml +++ b/integration-tests/docker-compose.test.status-go.yml @@ -14,3 +14,21 @@ services: - 30303:30303/udp - 30304:30304/udp entrypoint: ["statusd", "-c", "/static/configs/config.json", "--seed-phrase=test test test test test test test test test test test junk", "--password=Strong12345"] + healthcheck: + test: ["CMD-SHELL", "curl -X POST --data '{\"jsonrpc\":\"2.0\",\"method\":\"net_version\",\"params\":[],\"id\":1}' -H 'Content-Type: application/json' http://0.0.0.0:3333 || exit 1"] + interval: 5s + timeout: 2s + retries: 120 + + tests-rpc: + depends_on: + status-go: + condition: service_healthy + deploy-communities-contracts: + condition: service_completed_successfully + build: + context: . + dockerfile: Dockerfile.tests-rpc + entrypoint: ["pytest", "-m", "wallet", "--rpc_url=http://status-go:3333"] + volumes: + - .:/tests-rpc diff --git a/integration-tests/pytest.ini b/integration-tests/pytest.ini index 2afe65000..4a77066d7 100644 --- a/integration-tests/pytest.ini +++ b/integration-tests/pytest.ini @@ -1,5 +1,5 @@ [pytest] -addopts = -s -v --tb=short +addopts = -s -v --tb=short --junitxml=results.xml markers = rpc