From e4e4747b500eb056fbdb33f7ab9a601f619419b5 Mon Sep 17 00:00:00 2001 From: Sean Sullivan Date: Sun, 12 Mar 2023 17:58:19 -0400 Subject: [PATCH] update testing (#534) --- .github/tests/configs/instances.yml | 6 +- .github/tests/configs/projects.yml | 2 +- .github/tests/configure_controller.yml | 36 +++++--- .../configure_controller_export_model.yml | 26 ++++-- .github/workflows/ci_standalone.yml | 27 ++++++ .github/workflows/ci_standalone_versioned.yml | 77 +++++++++++++++++ .github/workflows/ci_testing.yaml | 18 ---- .github/workflows/ci_workflow.yaml | 85 ------------------- 8 files changed, 151 insertions(+), 126 deletions(-) create mode 100644 .github/workflows/ci_standalone.yml create mode 100644 .github/workflows/ci_standalone_versioned.yml delete mode 100644 .github/workflows/ci_testing.yaml delete mode 100644 .github/workflows/ci_workflow.yaml diff --git a/.github/tests/configs/instances.yml b/.github/tests/configs/instances.yml index dc0f39617..ac562fff6 100644 --- a/.github/tests/configs/instances.yml +++ b/.github/tests/configs/instances.yml @@ -1,5 +1,5 @@ --- -controller_instances: - - hostname: my-instance.prod.example.com - capacity_adjustment: 0.4 +# controller_instances: +# - hostname: my-instance.prod.example.com +# capacity_adjustment: 0.4 ... diff --git a/.github/tests/configs/projects.yml b/.github/tests/configs/projects.yml index c4d0a730c..7a6e6418c 100644 --- a/.github/tests/configs/projects.yml +++ b/.github/tests/configs/projects.yml @@ -1,6 +1,6 @@ --- controller_configuration_projects_async_retries: 60 -controller_configuration_projects_async_delay: 2 +controller_configuration_projects_async_delay: 3 controller_projects: - name: Test Project scm_type: git diff --git a/.github/tests/configure_controller.yml b/.github/tests/configure_controller.yml index b7c990f5c..f56146e51 100644 --- a/.github/tests/configure_controller.yml +++ b/.github/tests/configure_controller.yml @@ -38,6 +38,14 @@ ansible.builtin.debug: msg: "Using the 'controller_api' plugin from: {{ controller_api_plugin }}" + - name: Include vars from configs directory + ansible.builtin.include_vars: + dir: ./configs + ignore_files: [controller_config.yml.template] + extensions: ["yml"] + tags: + - always + - name: Wait for Controller to come up ansible.builtin.uri: url: "https://{{ controller_hostname }}/api/v2/ping" @@ -49,23 +57,31 @@ delay: 30 ignore_errors: true - - name: "Show result of ping" + - name: Wait for the controller node to be up + uri: + url: "https://{{ controller_hostname }}/api/v2/mesh_visualizer/" + user: "{{ controller_username }}" + password: "{{ controller_password }}" + method: GET + validate_certs: false + force_basic_auth: true + status_code: 200 + body_format: json + register: mesh_data + until: mesh_data.json is defined + retries: 80 + delay: 5 + ignore_errors: true + + - name: "Show result of mesh_visualizer" ansible.builtin.debug: - var: result + var: mesh_data - name: Sleep for 60 seconds and allow awx to come up. ansible.builtin.wait_for: timeout: 60 delegate_to: localhost - - name: Include vars from configs directory - ansible.builtin.include_vars: - dir: ./configs - ignore_files: [controller_config.yml.template] - extensions: ["yml"] - tags: - - always - roles: - dispatch # The dispatch role calls all of the other roles. diff --git a/.github/tests/configure_controller_export_model.yml b/.github/tests/configure_controller_export_model.yml index eb1d003f6..eeb288071 100644 --- a/.github/tests/configure_controller_export_model.yml +++ b/.github/tests/configure_controller_export_model.yml @@ -37,21 +37,29 @@ ansible.builtin.debug: msg: "Using the 'controller_api' plugin from: {{ controller_api_plugin }}" - - name: Wait for Controller to come up - ansible.builtin.uri: - url: "{{ controller_hostname }}/api/v2/ping" - status_code: 200 - register: result - until: result.status == 200 - retries: 20 - delay: 30 - - name: Include vars from controller_configs directory ansible.builtin.include_vars: dir: ./configs_export_model ignore_files: [README.md] extensions: ["yml"] + - name: Wait for the controller to be up + uri: + url: "https://{{ controller_hostname }}/api/v2/mesh_visualizer/" + user: "{{ controller_username }}" + password: "{{ controller_password }}" + method: GET + validate_certs: false + force_basic_auth: true + status_code: 200 + body_format: json + register: mesh_data + until: mesh_data.json.nodes[0].enabled + retries: 120 + delay: 5 + + + roles: - {role: organizations, when: controller_organizations is defined, tags: organizations} - {role: users, when: controller_user_accounts is defined, tags: users} diff --git a/.github/workflows/ci_standalone.yml b/.github/workflows/ci_standalone.yml new file mode 100644 index 000000000..46e054e66 --- /dev/null +++ b/.github/workflows/ci_standalone.yml @@ -0,0 +1,27 @@ +--- +name: Test collection with AWX matrix +on: + push: + branches: + - '*_' + - devel + tags: + - '*_' # ending underscore for trying things + - 'v[0-9]+.[0-9]+.[0-9]+' # final version + - 'v[0-9]+.[0-9]+.[0-9]+[abrc]+[0-9]+' # alpha, beta, release candidate (rc) + - 'v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+' # development versions + pull_request: + +jobs: + ci_standalone: + strategy: + fail-fast: false + matrix: + awx_version: + - 21.11.0 + - 21.12.0 + - 21.13.0 + # - devel Disabled for now + uses: "./.github/workflows/ci_standalone_versioned.yml" + with: + awx_version: ${{ matrix.awx_version }} diff --git a/.github/workflows/ci_standalone_versioned.yml b/.github/workflows/ci_standalone_versioned.yml new file mode 100644 index 000000000..c29c3a167 --- /dev/null +++ b/.github/workflows/ci_standalone_versioned.yml @@ -0,0 +1,77 @@ +--- +name: Test collection with AWX + +on: + workflow_call: + inputs: + awx_version: + description: The version to pull of awx + required: true + type: string +env: + # Run docker-compose up in the background + COMPOSE_UP_OPTS: -d + +jobs: + integration: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + + - name: "Checkout galaxy_ng" + uses: actions/checkout@v2 + with: + repository: ansible/awx + path: awx + ref: ${{ inputs.awx_version }} + + - uses: actions/setup-python@v2 + with: + python-version: "3.8" + + - name: Update apt + run: sudo apt -y update + + - name: Install requirements + run: sudo apt-get install -y libsasl2-dev python3-dev libldap2-dev libssl-dev build-essential + + - name: Install docker-compose + run: pip3 install --upgrade docker-compose + + - name: collect system info + run: whoami; id; pwd; ls -al; uname -a ; df -h .; mount ; cat /etc/issue; docker --version ; ps aux | fgrep -i docker; ls -al /var/run/containerd/containerd.sock + + - name: set the awx password in the inventory + run: echo "admin_password='password'" >> awx/tools/docker-compose/inventory + + - name: build images + working-directory: awx + run: make docker-compose-build + + - name: build stack + working-directory: awx + run: make docker-compose up + continue-on-error: true + + - name: give some time to spin up + run: sleep 200 + + - name: Preload data + working-directory: awx + run: docker exec tools_awx_1 awx-manage create_preload_data + + - name: set the awx password in the inventory + run: ls awx/tools/docker-compose/_sources/secrets + + - name: Display Versions + run: which python && pip --version && ansible --version + + - name: "Install Galaxy dependencies" + run: ansible-galaxy collection install -r .github/collections/requirements.yml + + - name: "Perform playbook tests" + run: ansible-playbook .github/tests/configure_controller.yml -e controller_hostname=localhost:8043 -v + + - name: "Perform export model playbook tests" + run: ansible-playbook .github/tests/configure_controller_export_model.yml -e controller_hostname=localhost:8043 -v +... diff --git a/.github/workflows/ci_testing.yaml b/.github/workflows/ci_testing.yaml deleted file mode 100644 index c186ce76a..000000000 --- a/.github/workflows/ci_testing.yaml +++ /dev/null @@ -1,18 +0,0 @@ ---- -name: Run Test Playbooks on AWX workflow -on: - push: - branches: - - '*_' - - devel - tags: - - '*_' # ending underscore for trying things - - 'v[0-9]+.[0-9]+.[0-9]+' # final version - - 'v[0-9]+.[0-9]+.[0-9]+[abrc]+[0-9]+' # alpha, beta, release candidate (rc) - - 'v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+' # development versions - pull_request: - -jobs: - Integration-test: - uses: "./.github/workflows/ci_workflow.yaml" -... diff --git a/.github/workflows/ci_workflow.yaml b/.github/workflows/ci_workflow.yaml deleted file mode 100644 index eaed1a930..000000000 --- a/.github/workflows/ci_workflow.yaml +++ /dev/null @@ -1,85 +0,0 @@ ---- -name: Run Test Playbooks on AWX - -on: - workflow_call - -jobs: - Integration-test: - name: Deploy AWX to Minikube and run tests - runs-on: ubuntu-latest - steps: - - - name: Checkout - uses: actions/checkout@v2 - - - name: "Install dependencies" - run: pip install -r .github/requirements.txt - - - name: Setup Minikube - uses: manusa/actions-setup-minikube@v2.7.2 - with: - minikube version: 'v1.28.0' - kubernetes version: 'v1.25.4' - github token: ${{ secrets.GITHUB_TOKEN }} - start args: '--addons=ingress' - - - name: Wait / Sleep - uses: jakejarvis/wait-action@v0.1.0 - with: - time: '20s' - - - name: Setup awx operator - run: | - minikube kubectl create secret generic awx-admin-password -- --from-literal=password=password - minikube addons enable ingress - alias kubectl="minikube kubectl --" - - - name: kustomize awx operator - working-directory: .github/workflow-config - run: kustomize build . | kubectl apply -f - - - - name: Wait / Sleep - uses: jakejarvis/wait-action@v0.1.0 - with: - time: '30s' - - - name: kustomize awx - working-directory: .github/workflow-config/kube - run: kustomize build . | kubectl apply -f - - - - name: Wait / Sleep - uses: jakejarvis/wait-action@v0.1.0 - with: - time: '30s' - - - name: Check service URL - uses: nick-invision/retry@v2 - with: - timeout_minutes: 10 - max_attempts: 25 - retry_wait_seconds: 30 - command: minikube service awx-service --url - - - name: minikube kubectl get pods - run: minikube kubectl get pods - - - name: Set service url - run: echo '::set-output name=SERVICEURL::$(minikube service awx-service --url)' - id: service-url - - - name: Display service url - run: echo "Service URL is ${{ steps.service-url.outputs.SERVICEURL }}" - - - name: Display Versions - run: which python && pip --version && ansible --version - - - name: "Install Galaxy dependencies" - run: ansible-galaxy collection install -r .github/collections/requirements.yml - - - name: "Perform playbook tests" - run: ansible-playbook .github/tests/configure_controller.yml -e controller_hostname=${{ steps.service-url.outputs.SERVICEURL }} - - - name: "Perform export model playbook tests" - run: ansible-playbook .github/tests/configure_controller_export_model.yml -e controller_hostname=${{ steps.service-url.outputs.SERVICEURL }} -...