|
| 1 | +name: 'Run server and configure tests' |
| 2 | +description: 'Run server in a Docker container. Also configure python client dev tests' |
| 3 | +# NOTE: do not share this server container with others |
| 4 | +# since it's using the default admin / admin credentials |
| 5 | +outputs: |
| 6 | + container-network: |
| 7 | + description: Forwards the container's network name from setup-as-server |
| 8 | + value: ${{ steps.setup-as-server.outputs.network-name }} |
| 9 | + container-name: |
| 10 | + description: Forwards the container name from setup-as-server |
| 11 | + value: ${{ steps.setup-as-server.outputs.container-names }} |
| 12 | +inputs: |
| 13 | + # All inputs in composite actions are strings |
| 14 | + oidc-provider-name: |
| 15 | + description: For pulling server images from JFrog |
| 16 | + required: true |
| 17 | + oidc-audience: |
| 18 | + description: For pulling server images from JFrog |
| 19 | + required: true |
| 20 | + server-edition: |
| 21 | + required: true |
| 22 | + description: 'community or enterprise' |
| 23 | + features-content: |
| 24 | + description: Only used if server edition is enterprise. For enabling strong consistency |
| 25 | + required: true |
| 26 | + server-tag: |
| 27 | + required: true |
| 28 | + description: Specify Docker tag |
| 29 | + where-is-client-connecting-from: |
| 30 | + required: false |
| 31 | + description: 'docker-host, separate-docker-container, "remote-connection" via DOCKER_HOST' |
| 32 | + default: 'docker-host' |
| 33 | + |
| 34 | +runs: |
| 35 | + using: "composite" |
| 36 | + steps: |
| 37 | + # Start up server |
| 38 | + - uses: aerospike/shared-workflows/.github/actions/setup-aerospike-server@CLIENT-4793-setup-aerospike-server-use-named-volumes-instead-of-bind-mounts-to-support-windows-and-macos-runners |
| 39 | + id: setup-as-server |
| 40 | + with: |
| 41 | + server-container-repo: database-docker-virtual/aerospike-server${{ inputs.server-edition == 'enterprise' && '-enterprise' || '' }} |
| 42 | + enable-security: ${{ inputs.server-edition == 'enterprise' }} |
| 43 | + enable-tls: ${{ inputs.server-edition == 'enterprise' }} |
| 44 | + enable-strong-consistency: ${{ inputs.server-edition == 'enterprise' }} |
| 45 | + features-content: ${{ inputs.features-content }} |
| 46 | + num-nodes: 1 |
| 47 | + oidc-provider: ${{ inputs.oidc-provider-name }} |
| 48 | + oidc-audience: ${{ inputs.oidc-audience }} |
| 49 | + server-tag: ${{ inputs.server-tag }} |
| 50 | + # This way doesn't work, so pass a custom server config for now with this setting enabled |
| 51 | + # Problem is the shared action is overriding the entrypoint script that parses this env var |
| 52 | + # env-vars: DEFAULT_TTL=2592000; |
| 53 | + config-file: ./.github/workflows/aerospike${{ inputs.server-edition == 'community' && '-ce' || '' }}.conf |
| 54 | + |
| 55 | + - name: Get config.conf |
| 56 | + run: | |
| 57 | + CONFIG_CONF=config.conf |
| 58 | + echo "CONFIG_CONF=$CONFIG_CONF" >> "$GITHUB_ENV" |
| 59 | + cp config.conf.template "$CONFIG_CONF" |
| 60 | + working-directory: test |
| 61 | + shell: bash -ex {0} |
| 62 | + |
| 63 | + - if: ${{ inputs.server-edition == 'enterprise' }} |
| 64 | + run: | |
| 65 | + call_from_tools_container() { |
| 66 | + # See comment in run-ee-server.bash's call_from_tools_container() for why we surround $@ with double quotes |
| 67 | + docker run --rm --network host aerospike/aerospike-tools "$@" |
| 68 | + } |
| 69 | +
|
| 70 | + SUPERUSER_NAME_AND_PASSWORD="superuser" |
| 71 | + call_from_tools_container asadm -U admin -P admin --enable --execute "manage acl \ |
| 72 | + create user "$SUPERUSER_NAME_AND_PASSWORD" password "$SUPERUSER_NAME_AND_PASSWORD" \ |
| 73 | + roles read-write-udf, sys-admin, user-admin, data-admin" |
| 74 | +
|
| 75 | + # Install crudini to manipulate config.conf |
| 76 | + pipx install crudini --pip-args "-c ${{ github.workspace }}/.github/workflows/requirements.txt" |
| 77 | +
|
| 78 | + # Disable community edition connection |
| 79 | + crudini --existing=param --set "$CONFIG_CONF" community-edition hosts '' |
| 80 | + crudini --existing=param --set "$CONFIG_CONF" enterprise-edition user "$SUPERUSER_NAME_AND_PASSWORD" |
| 81 | + crudini --existing=param --set "$CONFIG_CONF" enterprise-edition password "$SUPERUSER_NAME_AND_PASSWORD" |
| 82 | + crudini --set "$CONFIG_CONF" tls enable true |
| 83 | +
|
| 84 | + tls_cert_dir=${{ steps.setup-as-server.outputs.tls-cert-dir }} |
| 85 | + if [[ "$WHERE_IS_CLIENT_CONNECTING_FROM" == "separate-docker-container" ]]; then |
| 86 | + tls_cert_dir="/host${tls_cert_dir}" |
| 87 | + fi |
| 88 | +
|
| 89 | + crudini --set "$CONFIG_CONF" tls cafile $tls_cert_dir/ca.crt |
| 90 | + crudini --set "$CONFIG_CONF" tls keyfile $tls_cert_dir/client.key |
| 91 | + crudini --set "$CONFIG_CONF" tls certfile $tls_cert_dir/client.crt |
| 92 | +
|
| 93 | + if [[ "$WHERE_IS_CLIENT_CONNECTING_FROM" == "docker-host" ]]; then |
| 94 | + SERVER_IP=127.0.0.1 |
| 95 | + elif [[ "$WHERE_IS_CLIENT_CONNECTING_FROM" == "remote-connection" ]]; then |
| 96 | + # Set IP address to remote machine running the Docker daemon |
| 97 | + SERVER_IP=${DOCKER_HOST/tcp:\/\//} |
| 98 | + SERVER_IP=${SERVER_IP/:2375/} |
| 99 | + elif [[ "$WHERE_IS_CLIENT_CONNECTING_FROM" == "separate-docker-container" ]]; then |
| 100 | + SERVER_IP="$SERVER_CONTAINER_NAME" |
| 101 | + else |
| 102 | + # Invalid input |
| 103 | + exit 1 |
| 104 | + fi |
| 105 | +
|
| 106 | + # Set EE server's IP address and TLS name for test config |
| 107 | + cluster_name=$(call_from_tools_container asinfo -U admin -P admin -v "get-config:context=service" -l | grep -i cluster-name | cut -d = -f 2) |
| 108 | + crudini --existing=param --set "$CONFIG_CONF" enterprise-edition hosts "${SERVER_IP}:${TLS_PORT}|${cluster_name}" |
| 109 | + working-directory: test |
| 110 | + shell: bash -ex {0} |
| 111 | + env: |
| 112 | + WHERE_IS_CLIENT_CONNECTING_FROM: "${{ inputs.where-is-client-connecting-from }}" |
| 113 | + TLS_PORT: ${{ steps.setup-as-server.outputs.tls-service-ports }} |
| 114 | + SERVER_CONTAINER_NAME: ${{ steps.setup-as-server.outputs.container-names }} |
0 commit comments