From 89c4b8089851396d8a8da2abc6e39b314cc550db Mon Sep 17 00:00:00 2001 From: Johann Hoffmann Date: Mon, 14 Mar 2022 15:53:39 +0100 Subject: [PATCH] [WIFI-7229] Integrate virtual AP in Docker Compose testing workflow (#426) * Integrate virtual AP in Docker Compose testing workflow and switch to CLI testing Signed-off-by: Johann Hoffmann * Fix syntax error Signed-off-by: Johann Hoffmann * Fix another syntax error Signed-off-by: Johann Hoffmann * Execute command over SSH and fix CLI permissions Signed-off-by: Johann Hoffmann * Add shared AWS variables and try to escape secret Signed-off-by: Johann Hoffmann * Auto-accept new SSH host keys Signed-off-by: Johann Hoffmann * Fix SSH key permissions Signed-off-by: Johann Hoffmann * Use curl and switch to raw repository files Signed-off-by: Johann Hoffmann * Add serial to CLI calls Signed-off-by: Johann Hoffmann * Get mac address of virtual AP dynamically Signed-off-by: Johann Hoffmann * Fix step condition syntax Signed-off-by: Johann Hoffmann * Add silent option to curl Signed-off-by: Johann Hoffmann * Re-apply AP config after starting firstcontact service Signed-off-by: Johann Hoffmann * Remove duplicate quotes Signed-off-by: Johann Hoffmann * Use local AP config file and add choice to test all microservices Signed-off-by: Johann Hoffmann * Wait before re-applying config modifications to avoid overwrite Signed-off-by: Johann Hoffmann --- .github/workflows/ow_docker-compose.yml | 711 +++++++++++------------- 1 file changed, 340 insertions(+), 371 deletions(-) diff --git a/.github/workflows/ow_docker-compose.yml b/.github/workflows/ow_docker-compose.yml index 6f063618f..b0c0acc37 100644 --- a/.github/workflows/ow_docker-compose.yml +++ b/.github/workflows/ow_docker-compose.yml @@ -1,26 +1,14 @@ name: 2.x testing with Docker Compose deployment + 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 }} on: - repository_dispatch: - types: [openwifi-sdk-pr] workflow_dispatch: inputs: - testbeds: - default: 'basic-05' - description: 'Testbed(s) to test' - required: false - marker_expression: - default: 'sdk_restapi' - description: 'Markers expression that will be passed to the pytest command.' - required: false owgw_version: default: 'master' description: 'OpenWIFI Gateway version to be deployed.' @@ -48,6 +36,15 @@ on: id: description: 'run identifier' required: false + microservice: + description: 'OpenWIFI microservice to be tested' + required: true + type: choice + options: + - owgw + - owsec + - owfms + - all defaults: run: @@ -58,23 +55,14 @@ jobs: name: Workflow ID Provider runs-on: ubuntu-latest steps: - - name: ${{github.event.inputs.id}} + - name: ${{ github.event.inputs.id }} run: echo run identifier ${{ inputs.id }} - build: - runs-on: ubuntu-latest - needs: id - 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 }} - deploy-controller: name: Deploy OpenWIFI Cloud SDK + env: + AWS_DEFAULT_OUTPUT: json + AWS_DEFAULT_REGION: us-east-2 runs-on: ubuntu-latest needs: id outputs: @@ -82,371 +70,352 @@ jobs: sec_url: ${{ steps.sec_url.outputs.value }} namespace: ${{ steps.namespace.outputs.value }} steps: - - name: Checkout wlan-testing repo - uses: actions/checkout@v2 - with: - path: wlan-testing + - name: Checkout wlan-testing repo + uses: actions/checkout@v2 + with: + path: wlan-testing - - name: Prepare certificates from secrets - working-directory: wlan-testing/docker-compose/openwifi - run: | - echo "${{ secrets.DIGICERT_CERT }}" | base64 -d > websocket-cert.pem - echo "${{ secrets.DIGICERT_KEY }}" | base64 -d > websocket-key.pem + - name: Prepare certificates from secrets + working-directory: wlan-testing/docker-compose/openwifi + run: | + echo "${{ secrets.DIGICERT_CERT }}" | base64 -d > websocket-cert.pem + echo "${{ secrets.DIGICERT_KEY }}" | base64 -d > websocket-key.pem - - name: Fetch kubeconfig - run: | - aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} + - name: Fetch kubeconfig + run: | + aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} - - name: Set namespace output - id: namespace - run: echo "::set-output name=value::ow-docker-compose-${{ github.run_id }}" + - name: Set namespace output + id: namespace + run: echo "::set-output name=value::ow-docker-compose-${{ github.run_id }}" - - name: Set gateway URL output - id: gateway_url - run: echo "::set-output name=value::ow-docker-compose-${{ github.run_id }}.cicd.lab.wlan.tip.build" + - name: Set gateway URL output + id: gateway_url + run: echo "::set-output name=value::ow-docker-compose-${{ github.run_id }}.cicd.lab.wlan.tip.build" - - name: Set sec service URL output - id: sec_url - run: echo "::set-output name=value::ow-docker-compose-${{ github.run_id }}.cicd.lab.wlan.tip.build" + - name: Set sec service URL output + id: sec_url + run: echo "::set-output name=value::ow-docker-compose-${{ github.run_id }}.cicd.lab.wlan.tip.build" - - name: Create Kubernetes namespace and secret - working-directory: wlan-testing/docker-compose/openwifi - run: | - kubectl create ns ow-docker-compose-${{ github.run_id }} - kubectl create secret generic tip-cicd-wildcard-certs --from-file=websocket-cert.pem=websocket-cert.pem --from-file=websocket-key.pem=websocket-key.pem -n ow-docker-compose-${{ github.run_id }} + - name: Create Kubernetes namespace and secret + working-directory: wlan-testing/docker-compose/openwifi + run: | + kubectl create ns ow-docker-compose-${{ github.run_id }} + kubectl create secret generic tip-cicd-wildcard-certs --from-file=websocket-cert.pem=websocket-cert.pem --from-file=websocket-key.pem=websocket-key.pem -n ow-docker-compose-${{ github.run_id }} - - name: Deploy OpenWIFI Cloud SDK - working-directory: wlan-testing/docker-compose/openwifi - env: - RTTY_TOKEN: ${{ secrets.RTTY_TOKEN }} - OWSEC_AUTHENTICATION_DEFAULT_USERNAME: ${{ secrets.UCENTRALGW_AUTH_USERNAME }} - OWSEC_AUTHENTICATION_DEFAULT_PASSWORD: ${{ secrets.UCENTRALGW_AUTH_PASSWORD }} - OWFMS_S3_SECRET: ${{ secrets.UCENTRALFMS_S3_SECRET }} - OWFMS_S3_KEY: ${{ secrets.UCENTRALFMS_S3_KEY }} - run: | - cat < openwifi-virtual-ap.pem + chmod 600 openwifi-virtual-ap.pem + ssh -o StrictHostKeyChecking=accept-new -i openwifi-virtual-ap.pem root@${{ steps.get_virtual_ap_public_ip.outputs.ip }} '/etc/init.d/firstcontact start; sleep 10; /usr/share/ucentral/ucentral.uc /root/config.json' test: - 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: Test specified microservice + needs: [deploy-controller, set-redirector-url] + runs-on: ubuntu-latest + env: + OWSEC: "${{ needs.deploy-controller.outputs.sec_url }}:16001" + OWSEC_USERNAME: ${{ secrets.OWSEC_DEFAULT_USERNAME }} + OWSEC_PASSWORD: ${{ secrets.OWSEC_NEW_PASSWORD }} + steps: + - name: Checkout wlan-cloud-ucentralgw repo and test OWGW + if: github.event.inputs.microservice == 'owgw' || github.event.inputs.microservice == 'all' + run: | + curl -s https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentralgw/master/test_scripts/curl/cli -o cli + chmod +x cli + ./cli test_service ${{ needs.set-redirector-url.outputs.mac_address }} - - name: prepare namespace - id: namespace - run: | - NAMESPACE="testing-${{ github.run_id }}" - echo "::set-output name=name::${NAMESPACE}" + - name: Checkout wlan-cloud-ucentralsec repo and test OWSec + if: github.event.inputs.microservice == 'owsec' || github.event.inputs.microservice == 'all' + run: | + curl -s https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentralsec/main/test_scripts/curl/cli -o cli + chmod +x cli + ./cli test_service - - name: create configuration secret - run: | - cat << EOF > lab_info.json - ${{ secrets.LAB_CONFIGURATION_JSON }} - EOF - jq '.CONFIGURATION["${{ github.event.inputs.testbeds || 'basic-05' }}"].controller.url="https://${{ needs.deploy-controller.outputs.sec_url }}:16001"' lab_info.json > lab_info.json.tmp && mv lab_info.json.tmp lab_info.json - jq '.CONFIGURATION["${{ github.event.inputs.testbeds || 'basic-05' }}"].controller.password="${{ secrets.OWSEC_NEW_PASSWORD }}"' lab_info.json > lab_info.json.tmp && mv lab_info.json.tmp lab_info.json - - - name: run tests - uses: ./.github/actions/run-tests - with: - namespace: ${{ steps.namespace.outputs.name }} - testbed: "${{ github.event.inputs.testbeds || 'basic-05' }}" - marker_expression: "${{ github.event.inputs.marker_expression || 'sdk_restapi' }}" - configuration_file: "./lab_info.json" - 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 - needs: [ test ] - if: always() - steps: - - name: checkout testing repo - uses: actions/checkout@v2 - - - uses: actions/download-artifact@v2 - with: - name: allure-results-docker-compose-${{ github.event.inputs.marker_expression || 'sdk_restapi' }} - path: 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 docker-compose-${{ github.event.inputs.marker_expression || 'sdk_restapi' }}/latest/index.html | jq -r .Metadata.latest) - aws s3 cp --recursive s3://openwifi-allure-reports/docker-compose-${{ github.event.inputs.marker_expression || 'sdk_restapi' }}/$LAST_RUN_ID/history history - - - name: generate Allure report - uses: ./.github/actions/generate-allure-report - with: - results_path: ./allure-results - history_path: ./history - - - name: upload Allure report as artifact - uses: actions/upload-artifact@v2 - with: - name: allure-report-docker-compose-${{ github.event.inputs.marker_expression || 'sdk_restapi' }} - 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: docker-compose-${{ github.event.inputs.marker_expression || 'sdk_restapi' }} - testbed: ${{ github.event.inputs.testbeds || 'basic-05' }} - report_path: allure-report - s3_access_key_id: ${{ secrets.ALLURE_S3_ACCESS_KEY_ID }} - s3_access_key_secret: ${{ secrets.ALLURE_S3_ACCESS_KEY_SECRET }} - - delete-docker-image: - 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 }} + - name: Checkout wlan-cloud-ucentralfms repo and test OWFms + if: github.event.inputs.microservice == 'owfms' || github.event.inputs.microservice == 'all' + run: | + curl -s https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentralfms/main/test_scripts/curl/cli -o cli + chmod +x cli + ./cli test_service ${{ needs.set-redirector-url.outputs.mac_address }} destroy-controller: - needs: [ test ] + name: Destroy controller namespace + needs: [deploy-controller, test] runs-on: ubuntu-latest + env: + AWS_DEFAULT_REGION: us-east-2 if: always() steps: - - name: Checkout wlan-testing repo - uses: actions/checkout@v2 - with: - path: wlan-testing + - name: Checkout wlan-testing repo + uses: actions/checkout@v2 + with: + path: wlan-testing - - name: Fetch kubeconfig - run: | - aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} + - name: Fetch kubeconfig + run: | + aws eks update-kubeconfig --name ${{ env.AWS_EKS_NAME }} - - name: Delete namespace - run: kubectl delete ns --ignore-not-found=true "ow-docker-compose-${{ github.run_id }}" + - name: Delete namespace + run: kubectl delete ns --ignore-not-found=true ${{ needs.deploy-controller.outputs.namespace }}