Tests refactoring (using docker compose) and upgrade clickhouse-server to 24.8 in examples and test manifests #613
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: run_tests | |
on: | |
pull_request: | |
branches: | |
- '*' | |
workflow_dispatch: | |
inputs: | |
test_mode: | |
description: 'Test mode' | |
type: choice | |
options: | |
- Run all | |
- Fail fast | |
test_mask: | |
description: 'Wildcard mask to run only some tests. Empty means all.' | |
type: string | |
required: false | |
jobs: | |
run_tests: | |
name: Run Tests | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Cache python | |
uses: actions/cache@v4 | |
id: cache-python | |
with: | |
path: ~/venv/qa | |
key: python-${{ hashFiles('tests/image/requirements.txt') }} | |
- name: Install python dependencies | |
run: | | |
set -x | |
python3 -m venv ~/venv/qa | |
~/venv/qa/bin/pip3 install -U -r ./tests/image/requirements.txt | |
if: | | |
steps.cache-python.outputs.cache-hit != 'true' | |
- name: Setup required Ubuntu packages | |
run: | | |
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 8919F6BD2B48D754 | |
echo "deb https://packages.clickhouse.com/deb stable main" | sudo tee /etc/apt/sources.list.d/clickhouse.list | |
sudo apt-get update | |
sudo apt-get install -y conntrack clickhouse-client | |
- uses: medyagh/setup-minikube@master | |
with: | |
driver: docker | |
container-runtime: containerd | |
kubernetes-version: v1.31.2 | |
cpus: max | |
memory: max | |
- name: Build clickhouse-operator locally without push to registry | |
run: | | |
minikube status | |
export CHO_RELEASE=$(cat release) | |
echo "current release=$CHO_RELEASE" | |
docker build -f dockerfile/operator/Dockerfile -t altinity/clickhouse-operator:${CHO_RELEASE} --pull . | |
docker build -f dockerfile/metrics-exporter/Dockerfile -t altinity/metrics-exporter:${CHO_RELEASE} --pull . | |
docker image save altinity/clickhouse-operator:${CHO_RELEASE} -o operator.tar | |
docker image save altinity/metrics-exporter:${CHO_RELEASE} -o metrics-exporter.tar | |
minikube image load operator.tar | |
minikube image load metrics-exporter.tar | |
- name: Deploy prometheus | |
run: | | |
cp ./deploy/prometheus/prometheus-sensitive-data.example.sh ./deploy/prometheus/prometheus-sensitive-data.sh | |
NO_WAIT=1 bash ./deploy/prometheus/create-prometheus.sh | |
- name: Deploy minio | |
run: | | |
NO_WAIT=1 bash ./deploy/minio/create-minio.sh | |
- name: Run Tests | |
id: run-tests | |
continue-on-error: true | |
run: | | |
echo "Test run settings:" | |
echo " test mode: ${{ github.event.inputs.test_mode }}" | |
echo " test mask: ${{ github.event.inputs.test_mask }}" | |
echo | |
source ~/venv/qa/bin/activate | |
set -x | |
set +e # disable the "exit on failure" | |
sudo ln -snvf ~/venv/qa/bin/tfs /bin/tfs | |
if [[ "${{ github.event.inputs.test_mask }}" != '' ]] | |
then | |
ONLY="${{ github.event.inputs.test_mask }}" | |
else | |
ONLY="*" | |
fi | |
if [[ "${{ github.event.inputs.test_mode }}" == 'Run all' ]] | |
then | |
test_mode="--test-to-end" | |
fi | |
for test_file in ./tests/e2e/test_operator*.py; do | |
name=$(basename "$test_file" .py | sed 's/^test_//') | |
run_cmd="~/venv/qa/bin/python3 ./tests/regression.py --only=/regression/e2e?test_${name}/${ONLY} $test_mode --trim-results on -o short --native --log ./tests/raw_${name}.log && " | |
run_cmd+="~/venv/qa/bin/tfs --no-colors transform compact ./tests/raw_${name}.log ./tests/compact_${name}.log.txt && " | |
run_cmd+="~/venv/qa/bin/tfs --no-colors transform nice ./tests/raw_${name}.log ./tests/nice_${name}.log.txt && " | |
run_cmd+="~/venv/qa/bin/tfs --no-colors transform short ./tests/raw_${name}.log ./tests/short_${name}.log.txt && " | |
run_cmd+="bash -xec '~/venv/qa/bin/tfs --no-colors report results -a '${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}/' ./tests/raw_${name}.log - --confidential --copyright 'Altinity Inc.' --logo ./tests/altinity.png | ~/venv/qa/bin/tfs --debug --no-colors document convert > ./tests/report_${name}.html'" | |
run_tests+=( | |
"${run_cmd}" | |
) | |
done | |
printf "%s\n" "${run_tests[@]}" | xargs -P 2 -I {} bash -xec '{}' | |
test_result=$? | |
echo "test_result=$test_result" >> $GITHUB_OUTPUT | |
exit "$test_result" | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: testflows-logs | |
path: | | |
tests/*.log | |
tests/*.log.txt | |
if-no-files-found: error | |
retention-days: 7 | |
- uses: actions/upload-artifact@v4 | |
with: | |
name: testflows-report | |
path: | | |
tests/*_report.html | |
if-no-files-found: error | |
retention-days: 90 | |
- name: Test Failed | |
if: ${{ steps.vars.outputs.test_result != '0' }} | |
uses: actions/github-script@v3 | |
with: | |
script: | | |
core.setFailed('Test suite has failures! Check test run status and logs.') |