Skip to content

Commit

Permalink
Add testing scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
torcolvin committed Oct 10, 2024
1 parent 953adec commit 328d024
Show file tree
Hide file tree
Showing 3 changed files with 128 additions and 0 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/service.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Copyright 2022-Present Couchbase, Inc.
#
# Use of this software is governed by the Business Source License included in
# the file licenses/BSL-Couchbase.txt. As of the Change Date specified in that
# file, in accordance with the Business Source License, use of this software
# will be governed by the Apache License, Version 2.0, included in the file
# licenses/APL2.txt.

name: openapi

on:
push:
# Only run when we modify service files
paths:
- 'service/**'
- 'integration-test/**'
branches:
- 'main'
- 'release/*'
- 'feature/*'
- 'beryllium'
- 'CBG*'
- 'ci-*'
- 'api-ci-*'
pull_request:
# Only run when we modify service files
paths:
- 'service/**'
- 'integration-test/**'
branches:
- 'main'
- 'release/*'

jobs:
scripts:
runs-on: ubuntu-latest
name: Verify service script installation.
steps:
- uses: actions/checkout@v4
- name: "Run test scripts"
run: ./integration-test/service-install-tests.sh
33 changes: 33 additions & 0 deletions integration-test/service-install-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/bin/bash

set -eux -o pipefail

IMAGES=(
#"almalinux:9"
"amazonlinux:2"
"amazonlinux:2023"
"debian:10"
"debian:11"
"debian:12"
"redhat/ubi8"
"redhat/ubi9"
#"rockylinux:9"
"ubuntu:20.04"
"ubuntu:22.04"
"ubuntu:24.04"

# not technically supported
"oraclelinux:9"
)

SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")
SYNC_GATEWAY_DIR=$(realpath ${SCRIPT_DIR}/..)

if [ "$(uname)" == "Darwin" ]; then
sudo ${SYNC_GATEWAY_DIR}/integration-test/service-test.sh
fi

for IMAGE in "${IMAGES[@]}"; do
echo "Running tests for ${IMAGE}"
docker run --mount src=${SYNC_GATEWAY_DIR},target=/sync_gateway,type=bind ${IMAGE} /bin/bash -c "/sync_gateway/integration-test/service-test.sh"
done
54 changes: 54 additions & 0 deletions integration-test/service-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#/bin/sh

set -eux -o pipefail

SCRIPT_DIR=$(dirname "${BASH_SOURCE[0]}")

cd ${SCRIPT_DIR}/../service

./sync_gateway_service_install.sh --servicecmd

# /etc/os-release doesn't exist on Darwin
if [ -f /etc/os-release ]; then
. /etc/os-release
case ${ID} in
amzn)
yum install -y shadow-utils systemd
;;
esac

groupadd -r sync_gateway
useradd -g sync_gateway sync_gateway

# bash would support export -f for a systemctl wrapper, but dash does not support exporting aliases or functions

mkdir -p /tmp/systemctl_wrapper

cat << 'EOF' > /tmp/systemctl_wrapper/systemctl
#!/bin/bash
set -eu -o pipefail
case ${1:-} in
start)
echo "No-op systemctl start in docker, since we're not running systemd"
;;
stop)
echo "No-op systemctl stop in docker, since we're not running systemd"
;;
*)
echo "Running systemctl $@"
command /usr/bin/systemctl "$@"
;;
esac
EOF

chmod +x /tmp/systemctl_wrapper/systemctl

export PATH=/tmp/systemctl_wrapper:$PATH
fi
./sync_gateway_service_install.sh
./sync_gateway_service_upgrade.sh
./sync_gateway_service_uninstall.sh

echo "Successful service test"

0 comments on commit 328d024

Please sign in to comment.