From 84c09797b3650821fe9185abdff7d93fdee6cea8 Mon Sep 17 00:00:00 2001 From: Tullio Sebastiani Date: Fri, 9 Feb 2024 15:39:59 +0100 Subject: [PATCH] final functional tests Signed-off-by: Tullio Sebastiani added region Signed-off-by: Tullio Sebastiani env Signed-off-by: Tullio Sebastiani env Signed-off-by: Tullio Sebastiani typo Signed-off-by: Tullio Sebastiani --- .github/workflows/tests.yml | 57 ++++++++++++++++++++++++++----------- CI/tests/test_telemetry.sh | 12 +++++++- 2 files changed, 52 insertions(+), 17 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 151b7b6a9..bac461167 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,8 +1,12 @@ name: Functional & Unit Tests on: pull_request: + push: + branches: + - main jobs: tests: + # Common steps name: Functional & Unit Tests runs-on: ubuntu-latest steps: @@ -47,8 +51,7 @@ jobs: sudo apt-get install build-essential python3-dev pip install --upgrade pip pip install -r requirements.txt -# - name: Run unit tests -# run: python -m coverage run -a -m unittest discover -s tests -v + - name: Deploy test workloads run: | kubectl apply -f CI/templates/outage_pod.yaml @@ -61,30 +64,52 @@ jobs: - name: Get Kind nodes run: | kubectl get nodes --show-labels=true + # Pull request only steps + - name: Run unit tests + if: github.event_name == 'pull_request' + run: python -m coverage run -a -m unittest discover -s tests -v - - name: Setup Functional Tests + - name: Setup Pull Request Functional Tests + if: github.event_name == 'pull_request' run: | yq -i '.kraken.port="8081"' CI/config/common_test_config.yaml yq -i '.kraken.signal_address="0.0.0.0"' CI/config/common_test_config.yaml yq -i '.kraken.performance_monitoring="localhost:9090"' CI/config/common_test_config.yaml - yq -i '.telemetry.username="${{secrets.TELEMETRY_USERNAME}}"' CI/config/common_test_config.yaml - yq -i '.telemetry.password="${{secrets.TELEMETRY_PASSWORD}}"' CI/config/common_test_config.yaml - #echo "test_app_outages" > ./CI/tests/functional_tests - #echo "test_container" >> ./CI/tests/functional_tests - #echo "test_namespace" >> ./CI/tests/functional_tests - #echo "test_net_chaos" >> ./CI/tests/functional_tests - #echo "test_time" >> ./CI/tests/functional_tests - #echo "test_arca_cpu_hog" >> ./CI/tests/functional_tests - #echo "test_arca_memory_hog" >> ./CI/tests/functional_tests - #echo "test_arca_io_hog" >> ./CI/tests/functional_tests - echo "test_telemetry" > ./CI/tests/functional_tests + echo "test_app_outages" > ./CI/tests/functional_tests + echo "test_container" >> ./CI/tests/functional_tests + echo "test_namespace" >> ./CI/tests/functional_tests + echo "test_net_chaos" >> ./CI/tests/functional_tests + echo "test_time" >> ./CI/tests/functional_tests + echo "test_arca_cpu_hog" >> ./CI/tests/functional_tests + echo "test_arca_memory_hog" >> ./CI/tests/functional_tests + echo "test_arca_io_hog" >> ./CI/tests/functional_tests + + # Push on main only steps + - name: Configure AWS Credentials + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region : ${{ secrets.AWS_REGION }} + - name: Setup Post Merge Request Functional Tests + if: github.ref == 'refs/heads/main' && github.event_name == 'push' + run: | + yq -i '.kraken.port="8081"' CI/config/common_test_config.yaml + yq -i '.kraken.signal_address="0.0.0.0"' CI/config/common_test_config.yaml + yq -i '.kraken.performance_monitoring="localhost:9090"' CI/config/common_test_config.yaml + yq -i '.telemetry.username="${{secrets.TELEMETRY_USERNAME}}"' CI/config/common_test_config.yaml + yq -i '.telemetry.password="${{secrets.TELEMETRY_PASSWORD}}"' CI/config/common_test_config.yaml + echo "test_telemetry" > ./CI/tests/functional_tests + + # Final common steps - name: Run Functional tests + env: + AWS_BUCKET: ${{ secrets.AWS_BUCKET }} run: | ./CI/run.sh cat ./CI/results.markdown >> $GITHUB_STEP_SUMMARY echo >> $GITHUB_STEP_SUMMARY - #- name: Run Unit tests - # run: python -m coverage run -a -m unittest discover -s tests -v - name: Upload CI logs uses: actions/upload-artifact@v3 with: diff --git a/CI/tests/test_telemetry.sh b/CI/tests/test_telemetry.sh index f845fc465..531d6942b 100644 --- a/CI/tests/test_telemetry.sh +++ b/CI/tests/test_telemetry.sh @@ -7,8 +7,11 @@ trap finish EXIT function functional_test_telemetry { + AWS_CLI=`which aws` + [ -z "$AWS_CLI" ]&& echo "AWS cli not found in path" && exit 1 + [ -z "$AWS_BUCKET" ] && echo "AWS bucket not set in environment" && exit 1 + export RUN_TAG="funtest-telemetry" - #yq -i '.input_list[0].node_selector={"kubernetes.io/hostname":"kind-worker2"}' scenarios/arcaflow/cpu-hog/input.yaml yq -i '.telemetry.enabled=True' CI/config/common_test_config.yaml yq -i '.telemetry.full_prometheus_backup=True' CI/config/common_test_config.yaml yq -i '.telemetry.run_tag=env(RUN_TAG)' CI/config/common_test_config.yaml @@ -17,6 +20,13 @@ function functional_test_telemetry { export post_config="" envsubst < CI/config/common_test_config.yaml > CI/config/telemetry.yaml python3 -m coverage run -a run_kraken.py -c CI/config/telemetry.yaml + RUN_FOLDER=`cat CI/out/test_telemetry.out | grep amazonaws.com | sed -rn "s#.*https:\/\/.*\/download/(.*)#\1#p"` + $AWS_CLI s3 ls "s3://$AWS_BUCKET/$RUN_FOLDER/" | awk '{ print $4 }' > s3_remote_files + echo "checking if telemetry files are uploaded on s3" + cat s3_remote_files | grep events-00.json || ( echo "FAILED: events-00.json not uploaded" && exit 1 ) + cat s3_remote_files | grep prometheus-00.tar || ( echo "FAILED: prometheus backup not uploaded" && exit 1 ) + cat s3_remote_files | grep telemetry.json || ( echo "FAILED: telemetry.json not uploaded" && exit 1 ) + echo "all files uploaded!" echo "Telemetry Collection: Success" }