Files
wlan-testing/.github/workflows/performance.yml
2021-12-16 15:55:06 +01:00

256 lines
8.5 KiB
YAML

name: performance testing
env:
# AWS credentials
AWS_EKS_NAME: tip-wlan-main
AWS_DEFAULT_OUTPUT: json
AWS_DEFAULT_REGION: us-east-2
AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_KEY }}
# Cloud SDK certs
CACERT: ${{ secrets.CACERT }}
CAKEY: ${{ secrets.CAKEY }}
on:
workflow_dispatch:
inputs:
testbed:
default: 'basic-01'
description: 'Testbed to test'
required: false
defaults:
run:
shell: bash
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: build and push Docker image
uses: ./.github/actions/build-and-push-docker
with:
registry: tip-tip-wlan-cloud-docker-repo.jfrog.io
registry_user: wlan-testing-cicd
registry_password: ${{ secrets.DOCKER_USER_PASSWORD }}
test:
runs-on: [ self-hosted, small ]
needs: [ build ]
strategy:
max-parallel: 1
fail-fast: false
matrix:
marker:
- dataplane_throughput_test
- single_station_dual_band_throughput
- wifi_capacity_test
outputs:
testbed: ${{ steps.testbed.outputs.name }}
steps:
- name: install aws CLI tool
run: |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
- name: install kubectl
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
- name: get EKS access credentials
run: aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }}
- name: set job name
id: job
run: echo "::set-output name=name::perf-${{ github.run_id }}"
- name: set testbed
id: testbed
run: echo "::set-output name=name::${{ github.event.inputs.testbed || 'basic-01' }}"
- name: prepare namespace
id: namespace
run: |
NAMESPACE="testing-${{ github.run_id }}-${{ steps.testbed.outputs.name }}"
kubectl create ns $NAMESPACE
kubectl config set-context --current --namespace=$NAMESPACE
echo "::set-output name=name::${NAMESPACE}"
- name: create configuration.py secret
run: |
cat << EOF > configuration.py
${{ secrets.LAB_CONFIGURATION }}
EOF
sed -i -r "s/'password': ('|\")openwifi('|\")/'password': '"${{ secrets.OWSEC_NEW_PASSWORD }}"'/" configuration.py
kubectl create secret generic configuration --from-file=configuration=./configuration.py
- name: run perf tests
run: |
cat <<EOF | kubectl apply -f -
apiVersion: batch/v1
kind: Job
metadata:
name: "${{ steps.job.outputs.name }}"
spec:
template:
metadata:
annotations:
cluster-autoscaler.kubernetes.io/safe-to-evict: "false"
spec:
containers:
- name: tests
image: tip-tip-wlan-cloud-docker-repo.jfrog.io/cloud-sdk-nightly:${{ github.run_id }}
resources:
requests:
memory: "512Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "250m"
command:
- /bin/bash
- -x
- -c
- |
cd tests
pytest -m "performance and ${{ matrix.marker }}" -s -vvv --testbed="${{ steps.testbed.outputs.name }}" --alluredir=/tmp/allure-results
ret=\$?
# sleep some time to be able to download the Allure results
sleep 60
exit \$ret
volumeMounts:
- name: configuration
mountPath: "/wlan-testing/tests/configuration.py"
subPath: configuration
readOnly: true
nodeSelector:
env: tests
tolerations:
- key: "tests"
operator: "Exists"
effect: "NoSchedule"
imagePullSecrets:
- name: tip-docker-registry-key
restartPolicy: Never
volumes:
- name: configuration
secret:
secretName: configuration
backoffLimit: 0
EOF
# wait for pod to spawn
sleep 1
podname=$(kubectl get pods --no-headers -o custom-columns=":metadata.name" -l job-name="${{ steps.job.outputs.name }}" | sed "s/pod\///")
kubectl wait "pod/$podname" --for condition=ready --timeout=600s
#sleep 30 # wait for the pod to come up
until [ -s test_everything.xml ]
do
sleep 10
echo "waiting for tests to complete..."
kubectl cp $podname:/wlan-testing/tests/test_everything.xml test_everything.xml >/dev/null 2>&1
done
echo "tests completed"
echo "downloading allure results..."
kubectl cp $podname:/tmp/allure-results allure-results >/dev/null 2>&1
echo "waiting for pod to exit"
kubectl logs -f $podname >/dev/null 2>&1
exit $(kubectl get pod $podname --output="jsonpath={.status.containerStatuses[].state.terminated.exitCode}")
- name: print logs
if: always()
run: |
podname=$(kubectl get pods --no-headers -o custom-columns=":metadata.name" -l job-name="${{ steps.job.outputs.name }}" | sed "s/pod\///")
kubectl logs $podname
- name: upload Allure results as artifact
if: always()
uses: actions/upload-artifact@v2
with:
name: allure-results-${{ matrix.marker }}
path: allure-results
- name: cleanup
if: always()
run: |
kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true
report:
runs-on: ubuntu-latest
needs: [ test ]
if: always()
steps:
- name: checkout testing repo
uses: actions/checkout@v2
- uses: actions/download-artifact@v2
with:
name: allure-results-dataplane_throughput_test
path: allure-results-dataplane_throughput_test
- uses: actions/download-artifact@v2
with:
name: allure-results-single_station_dual_band_throughput
path: allure-results-single_station_dual_band_throughput
- uses: actions/download-artifact@v2
with:
name: allure-results-wifi_capacity_test
path: allure-results-wifi_capacity_test
- name: merge results
run: |
mkdir allure-results
cp -r allure-results-dataplane_throughput_test/* allure-results/
cp -r allure-results-single_station_dual_band_throughput/* allure-results/
cp -r allure-results-wifi_capacity_test/* allure-results/
- name: download history of previous run
continue-on-error: true
run: |
LAST_RUN_ID=$(aws s3api head-object --bucket openwifi-allure-reports --key performance/${{ needs.test.outputs.testbed }}/latest/index.html | jq -r .Metadata.latest)
aws s3 cp --recursive s3://openwifi-allure-reports/performance/${{ needs.test.outputs.testbed }}/$LAST_RUN_ID/history history
- name: generate Allure report
uses: ./.github/actions/generate-allure-report
with:
results_path: ./allure-results
history_path: ./history
additional_metadata: |
Ap.Model=${{ needs.test.outputs.testbed }}
- name: upload Allure report as artifact
uses: actions/upload-artifact@v2
with:
name: allure-report-${{ needs.test.outputs.testbed }}
path: allure-report
# doing this to be able to aggregate multiple reports together later on
- name: copy results into report
run: cp -r allure-results allure-report/results
- name: upload to S3
if: github.ref == 'refs/heads/master'
uses: ./.github/actions/allure-report-to-s3
with:
test_type: performance
testbed: ${{ needs.test.outputs.testbed }}
report_path: allure-report
s3_access_key_id: ${{ secrets.ALLURE_S3_ACCESS_KEY_ID }}
s3_access_key_secret: ${{ secrets.ALLURE_S3_ACCESS_KEY_SECRET }}
cleanup:
needs: [ test ]
runs-on: ubuntu-latest
if: always()
steps:
- uses: actions/checkout@v2
- name: cleanup Docker image
uses: ./.github/actions/cleanup-docker
with:
registry_user: wlan-testing-cicd
registry_password: ${{ secrets.DOCKER_USER_PASSWORD }}