From dd219e72bdc6ecab93a7a0e1b351db3ccfaaeaa1 Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 24 Feb 2022 15:19:51 +0100 Subject: [PATCH] use run-tests action in all workflows (#396) * use run-tests action in advanced workflow * use run-tests action in performance workflow * use run-tests action in docker-compose workflow * use run-tests action in quali advanced workflow * use run-tests action in quali basic manual workflow Signed-off-by: Max Brenner --- .github/workflows/advanced.yml | 119 ++------------------ .github/workflows/ow_docker-compose.yml | 121 ++------------------- .github/workflows/performance.yml | 129 +++------------------- .github/workflows/quali-advanced.yml | 120 ++------------------ .github/workflows/quali-basic-manual.yml | 133 ++++------------------- .github/workflows/quali.yml | 1 - 6 files changed, 63 insertions(+), 560 deletions(-) diff --git a/.github/workflows/advanced.yml b/.github/workflows/advanced.yml index 7e27e83f2..c84e5622d 100644 --- a/.github/workflows/advanced.yml +++ b/.github/workflows/advanced.yml @@ -1,8 +1,5 @@ name: advanced testing -env: - ALLURE_CLI_VERSION: 2.14.0 - on: workflow_dispatch: @@ -42,11 +39,13 @@ jobs: - advanced-02 steps: + - uses: actions/checkout@v2 - 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" @@ -55,117 +54,21 @@ jobs: - name: get EKS access credentials run: aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} - - name: install Allure CLI tool - run: | - wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${{ env.ALLURE_CLI_VERSION }}/allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz - tar -xzf allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz - - - name: set job name - id: job - run: echo "::set-output name=name::advanced-ci-${{ github.run_number }}" - - name: prepare namespace id: namespace run: | NAMESPACE="testing-${{ github.run_number }}-${{ matrix.testbed }}" - 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 - kubectl create secret generic configuration --from-file=configuration=./configuration.py - - name: run tests - run: | - cat </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 - - until [[ ! -z "$EXIT_CODE" ]]; do EXIT_CODE=$(kubectl get pod $podname --output="jsonpath={.status.containerStatuses[].state.terminated.exitCode}"); sleep 1; done; - exit $EXIT_CODE - - - name: upload Allure results as artifact - if: ${{ always() }} - uses: actions/upload-artifact@v2 + uses: ./.github/actions/run-tests with: - name: allure-results-${{ matrix.testbed }} - path: allure-results - - - name: cleanup - if: ${{ always() }} - run: | - kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true - + namespace: ${{ steps.namespace.outputs.name }} + testbed: ${{ matrix.testbed }} + marker_expression: advance + configuration: "${{ secrets.LAB_CONFIGURATION }}" + testing_docker_image: tip-tip-wlan-cloud-docker-repo.jfrog.io/cloud-sdk-nightly:${{ github.run_id }} + allure_results_artifact_name: allure-results-${{ matrix.testbed }} report: needs: [ test ] @@ -178,9 +81,7 @@ jobs: - advanced-01 - advanced-02 steps: - - name: checkout testing repo - uses: actions/checkout@v2 - + - uses: actions/checkout@v2 - uses: actions/download-artifact@v2 with: name: allure-results-${{ matrix.testbed }} diff --git a/.github/workflows/ow_docker-compose.yml b/.github/workflows/ow_docker-compose.yml index ae680d63e..4267640d3 100644 --- a/.github/workflows/ow_docker-compose.yml +++ b/.github/workflows/ow_docker-compose.yml @@ -7,7 +7,6 @@ env: AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }} AWS_ACCESS_KEY_ID: ${{ secrets.AWS_CLIENT_ID }} AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_CLIENT_KEY }} - ALLURE_CLI_VERSION: 2.14.0 on: repository_dispatch: @@ -88,15 +87,6 @@ jobs: with: path: wlan-testing - # build and push docker-compose-deployment image -# - name: docker login -# run: docker login ${{ env.DOCKER_SERVER }} -u ${{ env.DOCKER_USER_NAME }} -p ${{ env.DOCKER_USER_PASSWORD }} -# - name: build docker image -# working-directory: wlan-testing/docker-compose/openwifi -# run: docker build -t ${{ env.DOCKER_SERVER }}/docker-compose-deployment:${{ github.run_id }} . -# - name: push docker image -# run: docker push ${{ env.DOCKER_SERVER }}/docker-compose-deployment:${{ github.run_id }} -# - name: Prepare certificates from secrets working-directory: wlan-testing/docker-compose/openwifi run: | @@ -358,24 +348,14 @@ jobs: runs-on: ubuntu-latest needs: [ build, deploy-controller ] steps: + - uses: actions/checkout@v2 - name: get EKS access credentials run: aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} - - name: install Allure CLI tool - run: | - wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${{ env.ALLURE_CLI_VERSION }}/allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz - tar -xzf allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz - - - name: set job name - id: job - run: echo "::set-output name=name::testing-${{ github.run_number }}" - - name: prepare namespace id: namespace run: | NAMESPACE="testing-${{ github.run_id }}" - kubectl create ns $NAMESPACE - kubectl config set-context --current --namespace=$NAMESPACE echo "::set-output name=name::${NAMESPACE}" - name: create configuration.py secret @@ -385,98 +365,16 @@ jobs: EOF sed -i -r "s/'url': ('|\").*('|\")/'url': 'https:\/\/${{ needs.deploy-controller.outputs.sec_url }}:16001'/" configuration.py 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 tests - run: | - cat </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 - - until [[ ! -z "$EXIT_CODE" ]]; do EXIT_CODE=$(kubectl get pod $podname --output="jsonpath={.status.containerStatuses[].state.terminated.exitCode}"); sleep 1; done; - exit $EXIT_CODE - - - 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 + uses: ./.github/actions/run-tests with: - name: allure-results-docker-compose-${{ github.event.inputs.marker_expression || 'sdk_restapi' }} - path: allure-results - - - name: cleanup - if: always() - run: | - kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true + namespace: ${{ steps.namespace.outputs.name }} + testbed: "${{ github.event.inputs.testbeds || 'basic-05' }}" + marker_expression: "${{ github.event.inputs.marker_expression || 'sdk_restapi' }}" + configuration_file: "./configuration.py" + testing_docker_image: tip-tip-wlan-cloud-docker-repo.jfrog.io/cloud-sdk-nightly:${{ github.run_id }} + allure_results_artifact_name: allure-results-docker-compose-${{ github.event.inputs.marker_expression || 'sdk_restapi' }} report: runs-on: ubuntu-latest @@ -536,9 +434,6 @@ jobs: registry_user: wlan-testing-cicd registry_password: ${{ secrets.DOCKER_USER_PASSWORD }} -# - name: cleanup docker-compose-deployment image -# run: curl -u${{ env.DOCKER_USER_NAME }}:${{ env.DOCKER_USER_PASSWORD }} -X DELETE "https://tip.jfrog.io/artifactory/tip-wlan-cloud-docker-repo/docker-compose-deployment/${{ github.run_id }}" - destroy-controller: needs: [ test ] runs-on: ubuntu-latest diff --git a/.github/workflows/performance.yml b/.github/workflows/performance.yml index 8d4fd5401..b8c1dbffc 100644 --- a/.github/workflows/performance.yml +++ b/.github/workflows/performance.yml @@ -1,16 +1,4 @@ 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: @@ -38,6 +26,13 @@ jobs: test: runs-on: [ self-hosted, small ] needs: [ build ] + env: + 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 }} strategy: max-parallel: 1 fail-fast: false @@ -65,10 +60,6 @@ jobs: - 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' }}" @@ -77,108 +68,18 @@ jobs: 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 </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 - - until [[ ! -z "$EXIT_CODE" ]]; do EXIT_CODE=$(kubectl get pod $podname --output="jsonpath={.status.containerStatuses[].state.terminated.exitCode}"); sleep 1; done; - exit $EXIT_CODE - - - 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 + - name: run tests + uses: ./.github/actions/run-tests with: - name: allure-results-${{ matrix.marker }} - path: allure-results + namespace: ${{ steps.namespace.outputs.name }} + testbed: ${{ steps.testbed.outputs.name }} + marker_expression: "performance and ${{ matrix.marker }}" + configuration: "${{ secrets.LAB_CONFIGURATION }}" + testing_docker_image: tip-tip-wlan-cloud-docker-repo.jfrog.io/cloud-sdk-nightly:${{ github.run_id }} + allure_results_artifact_name: allure-results-${{ matrix.marker }} - - name: cleanup - if: always() - run: | - kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true report: runs-on: ubuntu-latest needs: [ test ] diff --git a/.github/workflows/quali-advanced.yml b/.github/workflows/quali-advanced.yml index 06fa9db4c..270e46f91 100644 --- a/.github/workflows/quali-advanced.yml +++ b/.github/workflows/quali-advanced.yml @@ -1,8 +1,5 @@ name: Quali advanced testing -env: - ALLURE_CLI_VERSION: 2.14.0 - on: workflow_dispatch: inputs: @@ -128,21 +125,10 @@ jobs: - name: get EKS access credentials run: aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} - - name: install Allure CLI tool - run: | - wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${{ env.ALLURE_CLI_VERSION }}/allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz - tar -xzf allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz - - - name: set job name - id: job - run: echo "::set-output name=name::advanced-ci-${{ github.run_number }}" - - name: prepare namespace id: namespace run: | NAMESPACE="testing-${{ github.run_id }}-$(echo ${{ matrix.ap_model }} | tr '[:upper:]' '[:lower:]' | tr '_' '-')" - kubectl create ns $NAMESPACE - kubectl config set-context --current --namespace=$NAMESPACE echo "::set-output name=name::${NAMESPACE}" - name: prepare configuration @@ -282,91 +268,17 @@ jobs: } EOF - kubectl create secret generic configuration --from-file=configuration=./configuration.py - - name: run tests - run: | - cat <> /etc/hosts - echo "DNS record for \$HOST resolved successfully!" - done - - cat /etc/hosts - - cd tests - pytest -m "${{ needs.vars.outputs.marker_expression }}" -s -vvv --testbed="advanced" --alluredir=/tmp/allure-results -o firmware="${{ needs.vars.outputs.ap_version }}" - 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 - kubectl logs -f $podname & - - until [ -s test_everything.xml ] - do - sleep 10 - 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 - - until [[ ! -z "$EXIT_CODE" ]]; do EXIT_CODE=$(kubectl get pod $podname --output="jsonpath={.status.containerStatuses[].state.terminated.exitCode}"); sleep 1; done; - exit $EXIT_CODE + uses: ./.github/actions/run-tests + with: + namespace: ${{ steps.namespace.outputs.name }} + testbed: advanced + marker_expression: "${{ needs.vars.outputs.marker_expression }}" + configuration_file: "./configuration.py" + testing_docker_image: tip-tip-wlan-cloud-docker-repo.jfrog.io/cloud-sdk-nightly:${{ github.run_id }} + additional_args: '-o firmware="${{ needs.vars.outputs.ap_version }}"' + allure_results_artifact_name: allure-results-${{ matrix.ap_model }} + dns_records_to_resolve: "sec-${{ steps.reservation.outputs.namespace }}.cicd.lab.wlan.tip.build gw-${{ steps.reservation.outputs.namespace }}.cicd.lab.wlan.tip.build fms-${{ steps.reservation.outputs.namespace }}.cicd.lab.wlan.tip.build" - name: show gw logs if: failure() @@ -384,18 +296,6 @@ jobs: if: failure() run: kubectl -n openwifi-${{ steps.reservation.outputs.namespace }} logs deployment/owsec - - name: upload Allure results as artifact - if: ${{ always() }} - uses: actions/upload-artifact@v2 - with: - name: allure-results-${{ matrix.ap_model }} - path: allure-results - - - name: cleanup - if: ${{ always() }} - run: | - kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true - - name: stop reservation if: always() run: python .quali/stop_reservation.py ${{ steps.reservation.outputs.identifier }} diff --git a/.github/workflows/quali-basic-manual.yml b/.github/workflows/quali-basic-manual.yml index 118c5dfda..2e39fc686 100644 --- a/.github/workflows/quali-basic-manual.yml +++ b/.github/workflows/quali-basic-manual.yml @@ -11,10 +11,6 @@ env: 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 }} - ALLURE_CLI_VERSION: 2.14.0 on: workflow_dispatch: @@ -116,21 +112,10 @@ jobs: 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: install Allure CLI tool - run: | - wget https://repo.maven.apache.org/maven2/io/qameta/allure/allure-commandline/${{ env.ALLURE_CLI_VERSION }}/allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz - tar -xzf allure-commandline-${{ env.ALLURE_CLI_VERSION }}.tgz - - - name: set job name - id: job - run: echo "::set-output name=name::manual-${{ github.run_id }}" - - name: prepare namespace id: namespace run: | NAMESPACE="testing-${{ github.run_id }}" - kubectl create ns $NAMESPACE - kubectl config set-context --current --namespace=$NAMESPACE echo "::set-output name=name::${NAMESPACE}" - name: prepare configuration @@ -241,106 +226,17 @@ jobs: } EOF - kubectl create secret generic configuration --from-file=configuration=./configuration.py - - name: run tests - run: | - cat <> /etc/hosts - echo "DNS record for \$HOST resolved successfully!" - done - - cd tests - pytest -m "${{ github.event.inputs.marker_expression }}" -s -vvv --testbed="basic" -o firmware="${{ github.event.inputs.firmware }}" --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 - kubectl logs -f $podname & - until [ -s test_everything.xml ] - do - sleep 10 - 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: upload Allure results as artifact - if: always() - uses: actions/upload-artifact@v2 + uses: ./.github/actions/run-tests with: - name: allure-results - path: allure-results - - - name: generate Allure report - run: allure-${{ env.ALLURE_CLI_VERSION }}/bin/allure generate allure-results - - - name: upload Allure report as artifact - uses: actions/upload-artifact@v2 - with: - name: allure-report - path: allure-report - - - name: cleanup - if: always() - run: | - kubectl delete ns "${{ steps.namespace.outputs.name }}" --wait=true + namespace: ${{ steps.namespace.outputs.name }} + testbed: basic + marker_expression: ${{ github.event.inputs.marker_expression }} + configuration_file: "./configuration.py" + testing_docker_image: tip-tip-wlan-cloud-docker-repo.jfrog.io/cloud-sdk-nightly:${{ github.run_id }} + additional_args: '-o firmware="${{ github.event.inputs.firmware }}"' + allure_results_artifact_name: allure-results + dns_records_to_resolve: "sec-${{ steps.reservation.outputs.namespace }}.cicd.lab.wlan.tip.build gw-${{ steps.reservation.outputs.namespace }}.cicd.lab.wlan.tip.build fms-${{ steps.reservation.outputs.namespace }}.cicd.lab.wlan.tip.build" - name: stop reservation if: always() @@ -350,6 +246,17 @@ jobs: CLOUDSHELL_USER: ${{ secrets.CLOUDSHELL_USER }} CLOUDSHELL_PASSWORD: ${{ secrets.CLOUDSHELL_PASSWORD }} + - name: generate Allure report + uses: ./.github/actions/generate-allure-report + with: + results_path: ./allure-results + + - name: upload Allure report as artifact + uses: actions/upload-artifact@v2 + with: + name: allure-report + path: allure-report + cleanup: needs: [ test ] runs-on: ubuntu-latest diff --git a/.github/workflows/quali.yml b/.github/workflows/quali.yml index 0673ed1fe..0dcf3b768 100644 --- a/.github/workflows/quali.yml +++ b/.github/workflows/quali.yml @@ -137,7 +137,6 @@ jobs: echo "::set-output name=name::${NAMESPACE}" - name: prepare configuration - id: configuration run: | cat << EOF > configuration.py Customer = ''