Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CLIENT-3027] CI/CD: Refactor composite action that deploys an EE server for testing #682

Merged
merged 10 commits into from
Nov 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions .github/actions/run-ee-server-for-ext-container/action.yml

This file was deleted.

92 changes: 63 additions & 29 deletions .github/actions/run-ee-server/action.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: 'Run EE Server'
name: 'Run EE Server in a Docker container'
description: 'Run EE server. Returns once server is ready. Only tested on Linux and macOS'
# NOTE: do not share this server container with others
# since it's using the default admin / admin credentials
Expand All @@ -20,37 +20,15 @@ inputs:
docker-hub-password:
description: Required for using release candidates
required: false
where-is-client-connecting-from:
required: false
description: 'docker-host, separate-docker-container, "remote-connection" via DOCKER_HOST'
default: 'docker-host'

runs:
using: "composite"
steps:
- name: Install crudini to manipulate config.conf
# This will only work on the Github hosted runners.
run: pipx install crudini --pip-args "-c ${{ github.workspace }}/.github/workflows/requirements.txt"
working-directory: .github/workflows
shell: bash

- name: Create config.conf
run: cp config.conf.template config.conf
working-directory: test
shell: bash

- name: Use enterprise edition instead of community edition in config.conf
run: |
crudini --existing=param --set config.conf enterprise-edition hosts ''
crudini --existing=param --set config.conf enterprise-edition hosts 127.0.0.1:3000
working-directory: test
shell: bash

- run: echo SUPERUSER_NAME_AND_PASSWORD="superuser" >> $GITHUB_ENV
shell: bash

- name: Set credentials in config file
run: |
crudini --existing=param --set config.conf enterprise-edition user ${{ env.SUPERUSER_NAME_AND_PASSWORD }}
crudini --existing=param --set config.conf enterprise-edition password ${{ env.SUPERUSER_NAME_AND_PASSWORD }}
working-directory: test
shell: bash
# Start up server

- name: Log into Docker Hub to get server RC
if: ${{ inputs.use-server-rc == 'true' }}
Expand All @@ -60,7 +38,7 @@ runs:
- run: echo IMAGE_NAME=aerospike/aerospike-server-enterprise${{ inputs.use-server-rc == 'true' && '-rc' || '' }}:${{ inputs.server-tag }} >> $GITHUB_ENV
shell: bash

- run: echo NEW_IMAGE_NAME=${{ env.IMAGE_NAME }}-security-and-sc >> $GITHUB_ENV
- run: echo NEW_IMAGE_NAME=${{ env.IMAGE_NAME }}-python-client-testing >> $GITHUB_ENV
shell: bash

# macOS Github runners and Windows self-hosted runners don't have buildx installed by default
Expand Down Expand Up @@ -92,6 +70,9 @@ runs:
is-security-enabled: true
is-strong-consistency-enabled: true

- run: echo SUPERUSER_NAME_AND_PASSWORD="superuser" >> $GITHUB_ENV
shell: bash

- run: echo ASADM_AUTH_FLAGS="--user=${{ env.SUPERUSER_NAME_AND_PASSWORD }} --password=${{ env.SUPERUSER_NAME_AND_PASSWORD }}" >> $GITHUB_ENV
shell: bash

Expand All @@ -106,3 +87,56 @@ runs:
# For debugging
- run: docker logs aerospike
shell: bash

# Configure tests

- name: Install crudini to manipulate config.conf
run: pipx install crudini --pip-args "-c ${{ github.workspace }}/.github/workflows/requirements.txt"
working-directory: .github/workflows
shell: bash

- name: Create config.conf
run: cp config.conf.template config.conf
working-directory: test
shell: bash

- name: Disable community edition connection
run: crudini --existing=param --set config.conf community-edition hosts ''
working-directory: test
shell: bash

- name: Set credentials in config file
run: |
crudini --existing=param --set config.conf enterprise-edition user ${{ env.SUPERUSER_NAME_AND_PASSWORD }}
crudini --existing=param --set config.conf enterprise-edition password ${{ env.SUPERUSER_NAME_AND_PASSWORD }}
working-directory: test
shell: bash

- name: Set IP address to localhost
if: ${{ inputs.where-is-client-connecting-from == 'docker-host' }}
run: echo SERVER_IP=127.0.0.1 >> $GITHUB_ENV
working-directory: test
shell: bash

- name: Set IP address to remote machine running the Docker daemon
if: ${{ inputs.where-is-client-connecting-from == 'remote-connection' }}
run: |
SERVER_IP=${DOCKER_HOST/tcp:\/\//}
echo SERVER_IP=${SERVER_IP/:2375/} >> $GITHUB_ENV
working-directory: test
shell: bash

- name: Set IP address to Docker container for the server
if: ${{ inputs.where-is-client-connecting-from == 'separate-docker-container' }}
run: echo SERVER_IP=$(docker container inspect -f '{{ .NetworkSettings.IPAddress }}' aerospike) >> $GITHUB_ENV
shell: bash

- name: Invalid input
if: ${{ env.SERVER_IP == '' }}
run: exit 1
shell: bash

- name: Set EE server's IP address
run: crudini --existing=param --set config.conf enterprise-edition hosts ${{ env.SERVER_IP }}:3000
working-directory: test
shell: bash
24 changes: 4 additions & 20 deletions .github/workflows/build-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -205,24 +205,15 @@ jobs:
if: ${{ env.RUN_INTEGRATION_TESTS_IN_CIBW == 'true' && inputs.platform-tag == 'macosx_x86_64' }}
uses: ./.github/actions/setup-docker-on-macos

- name: 'macOS x86: run Aerospike server in Docker container and connect via localhost'
if: ${{ env.RUN_INTEGRATION_TESTS_IN_CIBW == 'true' && inputs.platform-tag == 'macosx_x86_64' }}
- name: 'Run Aerospike server in Docker container and configure tests accordingly'
if: ${{ env.RUN_INTEGRATION_TESTS_IN_CIBW == 'true' }}
uses: ./.github/actions/run-ee-server
with:
use-server-rc: ${{ inputs.use-server-rc }}
server-tag: ${{ inputs.server-tag }}
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}

# TODO: combine this composite action and the above into one
- name: "Linux: run Aerospike server in Docker container and configure config.conf to connect to the server container's Docker IP address"
if: ${{ env.RUN_INTEGRATION_TESTS_IN_CIBW == 'true' && startsWith(inputs.platform-tag, 'manylinux') }}
uses: ./.github/actions/run-ee-server-for-ext-container
with:
use-server-rc: ${{ inputs.use-server-rc }}
server-tag: ${{ inputs.server-tag }}
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}
where-is-client-connecting-from: ${{ inputs.platform-tag == 'macosx_x86_64' && 'docker-host' || 'separate-docker-container' }}

- name: If not running tests against server, only run basic import test
if: ${{ env.RUN_INTEGRATION_TESTS_IN_CIBW == 'false' }}
Expand Down Expand Up @@ -314,6 +305,7 @@ jobs:
server-tag: ${{ inputs.server-tag }}
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}
where-is-client-connecting-from: ${{ inputs.platform-tag == 'win_amd64' && 'remote-connection' || 'docker-host' }}

- name: Download wheel
uses: actions/download-artifact@v4
Expand All @@ -337,14 +329,6 @@ jobs:
run: python3 -m pip install aerospike --force-reinstall --no-index --find-links=./
shell: bash

- name: Connect to Docker container on remote machine with Docker daemon
if: ${{ inputs.platform-tag == 'win_amd64' }}
# DOCKER_HOST contains the IP address of the remote machine
run: |
$env:DOCKER_HOST_IP = $env:DOCKER_HOST | foreach {$_.replace("tcp://","")} | foreach {$_.replace(":2375", "")}
crudini --set config.conf enterprise-edition hosts ${env:DOCKER_HOST_IP}:3000
working-directory: test

- run: python3 -m pip install pytest -c requirements.txt
working-directory: test
shell: bash
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/stage-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ jobs:
server-tag: ${{ inputs.server-tag }}
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}
where-is-client-connecting-from: 'separate-docker-container'

- name: Run distro container
# Run distro container on host network to access the Aerospike server using localhost (without having to change config.conf)
Expand Down Expand Up @@ -194,6 +195,7 @@ jobs:
server-tag: ${{ inputs.server-tag }}
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}
where-is-client-connecting-from: 'docker-host'

- name: Install wheel
run: python3 -m pip install *.whl
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/test-server-rc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ jobs:

- run: docker run -d --name manylinux quay.io/pypa/manylinux2014_${{ matrix.platform[0] }} tail -f /dev/null

- uses: ./.github/actions/run-ee-server-for-ext-container
- uses: ./.github/actions/run-ee-server
with:
use-server-rc: true
server-tag: latest
docker-hub-username: ${{ secrets.DOCKER_HUB_BOT_USERNAME }}
docker-hub-password: ${{ secrets.DOCKER_HUB_BOT_PW }}
where-is-client-connecting-from: 'docker-container'

- uses: actions/download-artifact@v4
with:
Expand Down
Loading