Skip to content

Commit

Permalink
Workflow to run S3 tests. Fixes #782
Browse files Browse the repository at this point in the history
Signed-off-by: Maksim Gelbakhiani <[email protected]>
  • Loading branch information
Maksim Gelbakhiani committed Sep 6, 2023
1 parent 6a3ccfe commit 2eec379
Show file tree
Hide file tree
Showing 2 changed files with 383 additions and 0 deletions.
69 changes: 69 additions & 0 deletions .github/test-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# Basenet settings
LOCAL_DOMAIN=neofs.devenv
IPV4_PREFIX=192.168.130
CA_CERTS_TRUSTED_STORE=./vendor/certs

# Bastion image
BASTION_VERSION=10
BASTION_IMAGE=debian

# NeoGo privnet
#CHAIN_PATH="/path/to/devenv.dump.gz"
CHAIN_URL="https://github.com/nspcc-dev/neofs-contract/releases/download/v0.17.0/devenv_mainchain.gz"

#NEOGO
NEOGO_VERSION=0.101.1
NEOGO_IMAGE=nspccdev/neo-go
NEO_GO_PLATFORM=linux-amd64
NEO_GO_URL=https://github.com/nspcc-dev/neo-go/releases/download/v${NEOGO_VERSION}/neo-go-${NEO_GO_PLATFORM}

# NeoFS InnerRing nodes
IR_VERSION=0.37.0
IR_IMAGE=nspccdev/neofs-ir

# NeoFS Storage nodes
NODE_VERSION=0.37.0
NODE_IMAGE=nspccdev/neofs-storage
NODE_PLATFORM=amd64

# NATS Server
NATS_VERSION=2.7.2
NATS_IMAGE=nats

# HTTP Gate
HTTP_GW_VERSION=0.27.0
HTTP_GW_IMAGE=nspccdev/neofs-http-gw

# REST Gate
REST_GW_VERSION=0.5.0
REST_GW_IMAGE=nspccdev/neofs-rest-gw

# S3 Gate
S3_GW_VERSION=_TAG_
S3_GW_IMAGE=nspccdev/neofs-s3-gw
S3_GW_PLATFORM=linux-amd64
S3_GW_HOST=s3.neofs.devenv

# Coredns
COREDNS_VERSION=v016
COREDNS_IMAGE=nspccdev/coredns

# NeoFS LOCODE database
LOCODE_DB_URL=https://github.com/nspcc-dev/neofs-locode-db/releases/download/v0.3.0/locode_db.gz

# NeoFS CLI binary
NEOFS_CLI_URL=https://github.com/nspcc-dev/neofs-node/releases/download/v${NODE_VERSION}/neofs-cli-${NODE_PLATFORM}.tar.gz

# Compiled NeoFS Smart Contracts
NEOFS_CONTRACTS_VERSION=v0.17.0
NEOFS_CONTRACTS_URL=https://github.com/nspcc-dev/neofs-contract/releases/download/${NEOFS_CONTRACTS_VERSION}/neofs-contract-${NEOFS_CONTRACTS_VERSION}.tar.gz

# NeoFS adm binary
NEOFS_ADM_URL=https://github.com/nspcc-dev/neofs-node/releases/download/v${NODE_VERSION}/neofs-adm-${NODE_PLATFORM}.tar.gz

# Control service addresses used for healthchecks
NEOFS_IR_CONTROL_GRPC_ENDPOINT=127.0.0.1:16512
NEOFS_STORAGE_CONTROL_GRPC_ENDPOINT_1=s01.${LOCAL_DOMAIN}:8081
NEOFS_STORAGE_CONTROL_GRPC_ENDPOINT_2=s02.${LOCAL_DOMAIN}:8081
NEOFS_STORAGE_CONTROL_GRPC_ENDPOINT_3=s03.${LOCAL_DOMAIN}:8081
NEOFS_STORAGE_CONTROL_GRPC_ENDPOINT_4=s04.${LOCAL_DOMAIN}:8081
314 changes: 314 additions & 0 deletions .github/workflows/s3-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,314 @@
name: S3 tests

on:
push:
branches:
- master
pull_request:
branches:
- master
- support/**
types: [opened, synchronize]
paths-ignore:
- '**/*.md'
release:
types:
- published
workflow_dispatch:
inputs:
neofs-s3-gw_ref:
description: 'neofs-s3-gw ref. Default ref - latest master. Examples: v0.27.0, 8fdcc6d7e798e6511be8806b81894622e72d7fdc, branch_name'
required: false
default: ''

permissions: write-all

env:
S3_TESTS_CONFIG: s3tests.conf
S3_GW_IP: 192.168.130.82
S3_GW_PORT: 8080

jobs:
build-and-test:
runs-on: ubuntu-latest

steps:

- name: Set RUN_ID
env:
TIMESTAMP: ${{ steps.date.outputs.timestamp }}
run: echo "RUN_ID=${{ github.run_number }}-$TIMESTAMP" >> $GITHUB_ENV

- name: Checkout neofs-s3-gw repository
uses: actions/checkout@v3
with:
repository: nspcc-dev/neofs-s3-gw
ref: ${{ github.sha }}
path: neofs-s3-gw

- name: Checkout s3-tests repository
uses: actions/checkout@v3
with:
repository: nspcc-dev/s3-tests
ref: master
path: s3-tests

- name: Checkout neofs-dev-env repository
uses: actions/checkout@v3
with:
repository: nspcc-dev/neofs-dev-env
ref: master
path: neofs-dev-env

- name: Checkout neofs-s3-dev-env repository
uses: actions/checkout@v3
with:
repository: nspcc-dev/neofs-s3-dev-env
ref: master
path: neofs-s3-dev-env

- name: Download latest stable neofs-cli for uploading reports to NeoFS
uses: dsaltares/[email protected]
with:
repo: 'nspcc-dev/neofs-node'
version: 'tags/v0.37.0'
file: 'neofs-cli-amd64'
target: 'neofs-node-stable/neofs-cli'

- name: Checkout neofs-testcases repository
uses: actions/checkout@v3
with:
repository: nspcc-dev/neofs-testcases
ref: 'master'
path: neofs-testcases

################################################################
- name: Set up Go
uses: actions/setup-go@v4
with:
cache: true
go-version: '1.20'
- run: go version

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.8'
- run: python --version

################################################################
- name: Get TAG for docker images
run: |
echo "CURRENT_TAG=$( make version | sed 's/^v//' )" >> $GITHUB_ENV
working-directory: neofs-s3-gw

################################################################

- name: Build neofs-s3-gw docker image
run: |
cp .github/test-env .env
make
working-directory: neofs-s3-gw

- name: Build neofs-s3-gw binaries
run: |
make image
working-directory: neofs-s3-gw


#################################################################

- name: Add NeoFS S3-gw TAGs to s3-gw-test env config
run: |
sed -i -e 's/S3_GW_VERSION=.*$/S3_GW_VERSION=${{ env.CURRENT_TAG }}/' .github/test-env
working-directory: neofs-s3-gw

- name: Copy test-env file to .env for neofs-dev-env
run: |
cp .github/test-env ${GITHUB_WORKSPACE}/neofs-dev-env/.env
working-directory: neofs-s3-gw

################################################################

- name: Prepare hosts
timeout-minutes: 5
run: |
make get
sudo ./bin/update_hosts.sh
sudo chmod a+w vendor/hosts
working-directory: neofs-dev-env

- name: Prepare Dev-Env to run tests
id: prepare_test_env
timeout-minutes: 30
run: |
make prepare-test-env
echo "$(pwd)/vendor" >> $GITHUB_PATH
working-directory: neofs-dev-env

- name: Set zero fee
run: |
make update.container_fee val=0 && make update.container_alias_fee val=0
working-directory: neofs-dev-env

- name: Copy neofs-s3-gw binaries to vendor directory
run: |
cp bin/* ${GITHUB_WORKSPACE}/neofs-dev-env/vendor/
working-directory: neofs-s3-gw

################################################################

- name: Log environment
run: |
echo "Check free space"
df -h
echo "=========================================="
echo "Check /etc/hosts"
cat /etc/hosts
echo "=========================================="
echo "Check docker images"
docker images
echo "=========================================="
echo "Check docker ps"
docker ps
echo "=========================================="
echo "Check neo-go version"
neo-go --version
echo "=========================================="
echo "Check neofs-s3-authmate version"
neofs-s3-authmate --version
echo "=========================================="
echo "Check neofs-s3-gw version"
echo "=========================================="
neofs-s3-gw --version
echo "=========================================="
echo "Check neofs-adm version"
neofs-adm --version
echo "=========================================="
echo "Check neofs-cli version"
neofs-cli --version
echo "=========================================="
echo "Check vendor dir"
ls -lah "${GITHUB_WORKSPACE}/neofs-dev-env/vendor"
echo "=========================================="
working-directory: neofs-dev-env

################################################################

- name: Copy test-env file to .env for neofs-s3-dev-env
run: |
cp .env ${GITHUB_WORKSPACE}/neofs-s3-dev-env/.env
working-directory: neofs-dev-env

- name: Copy neofs-s3-authmate for neofs-s3-dev-env
run: |
cp ${GITHUB_WORKSPACE}/neofs-dev-env/vendor/neofs-s3-authmate bin/s3-authmate
working-directory: neofs-s3-dev-env

- name: Prepare test S3-gw test env
run: |
make prepare.s3-gw
working-directory: neofs-s3-dev-env

- name: Copy s3tests config to s3-tests directory
run: |
cp services/s3-gw/s3tests.conf ${GITHUB_WORKSPACE}/s3-tests/${S3_TESTS_CONFIG}
working-directory: neofs-s3-dev-env

- name: Prepare s3tests config
run: |
sed -i -E "s/host =.*?$/host = ${S3_GW_IP}/" ${S3_TESTS_CONFIG}
sed -i -E "s/port =.*?$/port = ${S3_GW_PORT}/" ${S3_TESTS_CONFIG}
sed -i -E "s/is_secure =.*?$/is_secure = True/" ${S3_TESTS_CONFIG}
sed -i -E "s/ssl_verify =.*?$/ssl_verify = False/" ${S3_TESTS_CONFIG}
working-directory: s3-tests

- name: Test config
run: |
cat ${S3_TESTS_CONFIG}
working-directory: s3-tests

- name: Setup test env
run: |
python3.8 -m venv virtualenv
./bootstrap
working-directory: s3-tests

- name: Run Sanity tests for pull requests
timeout-minutes: 60
if: github.event_name == 'pull_request'
run: |
source virtualenv/bin/activate
S3TEST_CONF=${S3_TESTS_CONFIG} pytest --alluredir=${GITHUB_WORKSPACE}/allure-results -v -s s3tests_boto3/functional/test_s3.py --timeout 300 -a "sanity"
working-directory: s3-tests

- name: Run All tests
if: github.event_name != 'pull_request'
run: |
source virtualenv/bin/activate
S3TEST_CONF=${S3_TESTS_CONFIG} pytest --alluredir=${GITHUB_WORKSPACE}/allure-results -v -s s3tests_boto3/functional/test_s3.py --timeout 300
working-directory: s3-tests


################################################################
- name: Generate Allure report
timeout-minutes: 60
uses: simple-elf/[email protected]
if: always()
id: allure-report
with:
keep_reports: 100000
allure_results: allure-results
allure_report: allure-report
allure_history: allure-history

- name: Enable stable neofs-cli
if: always()
run: |
echo "$(pwd)" >> $GITHUB_PATH
working-directory: neofs-node-stable

- name: Create wallet
if: always()
env:
TEST_RESULTS_WALLET: ${{ secrets.TEST_RESULTS_WALLET }}
run: |
echo "$TEST_RESULTS_WALLET" | base64 -d > wallet.json
working-directory: neofs-testcases

- name: Put allure report to NeoFS
id: put_report
if: always() && steps.prepare_test_env.outcome == 'success'
env:
TEST_RESULTS_PASSWORD: ${{ secrets.TEST_RESULTS_PASSWORD }}
TEST_RESULTS_NEOFS_NETWORK_DOMAIN: ${{ vars.TEST_RESULTS_NEOFS_NETWORK_DOMAIN }}
TEST_RESULTS_CID: ${{ vars.TEST_RESULTS_CID }}
run: |
sudo chmod -R a+rw ${GITHUB_WORKSPACE}/allure-report
source ${GITHUB_WORKSPACE}/s3-tests/virtualenv/bin/activate && python3.8 ./tools/src/process-allure-reports.py --neofs_domain $TEST_RESULTS_NEOFS_NETWORK_DOMAIN --run_id $RUN_ID --cid $TEST_RESULTS_CID --allure_report ${GITHUB_WORKSPACE}/allure-report --wallet wallet.json
working-directory: neofs-testcases

- name: Post the link to the report
id: post_report_link
timeout-minutes: 60
if: always() && steps.put_report.outcome == 'success'
env:
TEST_RESULTS_HTTP_GATE: ${{ vars.TEST_RESULTS_HTTP_GATE }}
TEST_RESULTS_CID: ${{ vars.TEST_RESULTS_CID }}
uses: Sibz/github-status-action@v1
with:
authToken: ${{secrets.GITHUB_TOKEN}}
context: 'Test report'
state: 'success'
sha: ${{github.event.pull_request.head.sha || github.sha}}
target_url: https://${{ env.TEST_RESULTS_HTTP_GATE }}/${{ env.TEST_RESULTS_CID }}/${{ env.RUN_ID }}/index.html

0 comments on commit 2eec379

Please sign in to comment.