Skip to content

test: add ProxySQL --bootstrap mode test script #119

test: add ProxySQL --bootstrap mode test script

test: add ProxySQL --bootstrap mode test script #119

name: Integration Tests
on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
# Run nightly at 2am UTC
- cron: '0 2 * * *'
workflow_dispatch:
jobs:
sandbox-test:
name: Sandbox (${{ matrix.mysql-version }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
mysql-version:
- '8.0.42'
- '8.4.4'
- '9.1.0'
env:
GO111MODULE: on
SANDBOX_BINARY: ${{ github.workspace }}/opt/mysql
MYSQL_VERSION: ${{ matrix.mysql-version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install system libraries
run: |
sudo apt-get update
sudo apt-get install -y libaio1 libnuma1 libncurses5
- name: Build dbdeployer
run: go build -o dbdeployer .
- name: Cache MySQL tarball
uses: actions/cache@v4
with:
path: /tmp/mysql-tarball
key: mysql-${{ matrix.mysql-version }}-linux-x86_64-v1
- name: Download MySQL
run: |
SHORT_VER=$(echo "$MYSQL_VERSION" | grep -oP '^\d+\.\d+')
TARBALL="mysql-${MYSQL_VERSION}-linux-glibc2.17-x86_64.tar.xz"
mkdir -p /tmp/mysql-tarball
if [ ! -f "/tmp/mysql-tarball/$TARBALL" ]; then
echo "Downloading $TARBALL..."
curl -L -f -o "/tmp/mysql-tarball/$TARBALL" \
"https://dev.mysql.com/get/Downloads/MySQL-${SHORT_VER}/$TARBALL" \
|| curl -L -f -o "/tmp/mysql-tarball/$TARBALL" \
"https://downloads.mysql.com/archives/get/p/23/file/$TARBALL"
fi
ls -lh "/tmp/mysql-tarball/$TARBALL"
- name: Unpack MySQL
run: |
mkdir -p "$SANDBOX_BINARY"
TARBALL="mysql-${MYSQL_VERSION}-linux-glibc2.17-x86_64.tar.xz"
./dbdeployer unpack "/tmp/mysql-tarball/$TARBALL" \
--sandbox-binary="$SANDBOX_BINARY"
- name: Test single sandbox
run: |
./dbdeployer deploy single "$MYSQL_VERSION" \
--sandbox-binary="$SANDBOX_BINARY"
~/sandboxes/msb_*/use -e "SELECT VERSION()"
./dbdeployer delete all --skip-confirm
- name: Test replication sandbox
run: |
./dbdeployer deploy replication "$MYSQL_VERSION" \
--sandbox-binary="$SANDBOX_BINARY"
~/sandboxes/rsandbox_*/check_slaves
~/sandboxes/rsandbox_*/test_replication
./dbdeployer delete all --skip-confirm
- name: Cleanup
if: always()
run: |
./dbdeployer delete all --skip-confirm 2>/dev/null || true
pkill -9 -u "$USER" mysqld 2>/dev/null || true
# Test PostgreSQL provider: deb extraction, single sandbox, replication,
# cross-database validation.
postgresql-test:
name: PostgreSQL ${{ matrix.pg-version }}
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
pg-version: ['16']
env:
GO111MODULE: on
PG_VERSION: ${{ matrix.pg-version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Add PostgreSQL apt repo
run: |
sudo apt-get update
sudo apt-get install -y curl ca-certificates
sudo install -d /usr/share/postgresql-common/pgdg
sudo curl -o /usr/share/postgresql-common/pgdg/apt.postgresql.org.asc --fail https://www.postgresql.org/media/keys/ACCC4CF8.asc
echo "deb [signed-by=/usr/share/postgresql-common/pgdg/apt.postgresql.org.asc] https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
sudo apt-get update
- name: Build dbdeployer
run: go build -o dbdeployer .
- name: Install PostgreSQL and set up binaries
run: |
# Install PostgreSQL to get properly configured binaries
sudo apt-get install -y postgresql-${PG_VERSION} postgresql-client-${PG_VERSION}
# Stop the system service — we'll manage our own instances
sudo systemctl stop postgresql || true
# Get full version and copy binaries into dbdeployer's expected layout
PG_FULL=$(dpkg -s postgresql-${PG_VERSION} | grep '^Version:' | sed 's/Version: //' | cut -d'-' -f1)
echo "PostgreSQL version: ${PG_FULL}"
mkdir -p ~/opt/postgresql/${PG_FULL}/{bin,lib,share}
cp -a /usr/lib/postgresql/${PG_VERSION}/bin/. ~/opt/postgresql/${PG_FULL}/bin/
cp -a /usr/lib/postgresql/${PG_VERSION}/lib/. ~/opt/postgresql/${PG_FULL}/lib/
cp -a /usr/share/postgresql/${PG_VERSION}/. ~/opt/postgresql/${PG_FULL}/share/
ls ~/opt/postgresql/${PG_FULL}/bin/
- name: Test deploy postgresql (single)
run: |
PG_FULL=$(ls ~/opt/postgresql/ | head -1)
echo "=== Deploying PostgreSQL $PG_FULL single ==="
./dbdeployer deploy postgresql "$PG_FULL"
echo "=== Connecting ==="
~/sandboxes/pg_sandbox_*/use -c "SELECT version();"
echo "=== Status ==="
~/sandboxes/pg_sandbox_*/status
echo "=== Stop + Start ==="
~/sandboxes/pg_sandbox_*/stop
~/sandboxes/pg_sandbox_*/start
sleep 2
~/sandboxes/pg_sandbox_*/use -c "SELECT 1;"
echo "=== Cleanup ==="
~/sandboxes/pg_sandbox_*/stop
rm -rf ~/sandboxes/pg_sandbox_*
- name: Test deploy replication --provider=postgresql
run: |
PG_FULL=$(ls ~/opt/postgresql/ | head -1)
echo "=== Deploying PostgreSQL $PG_FULL replication ==="
./dbdeployer deploy replication "$PG_FULL" --provider=postgresql --nodes=3
echo "=== Checking topology dir ==="
ls ~/sandboxes/postgresql_repl_*/
echo "=== Check replication ==="
bash ~/sandboxes/postgresql_repl_*/check_replication || true
echo "=== Check recovery ==="
bash ~/sandboxes/postgresql_repl_*/check_recovery || true
echo "=== Primary: write test ==="
~/sandboxes/postgresql_repl_*/primary/use -c "CREATE TABLE test_repl(id serial, val text); INSERT INTO test_repl(val) VALUES ('hello');"
sleep 2
echo "=== Replica 1: read test ==="
~/sandboxes/postgresql_repl_*/replica1/use -c "SELECT * FROM test_repl;"
echo "=== Replica 2: read test ==="
~/sandboxes/postgresql_repl_*/replica2/use -c "SELECT * FROM test_repl;"
- name: Test cross-database validation
run: |
PG_FULL=$(ls ~/opt/postgresql/ | head -1)
echo "=== Test: --flavor with --provider=postgresql should fail ==="
if ./dbdeployer deploy single "$PG_FULL" --provider=postgresql --flavor=ndb 2>&1; then
echo "ERROR: should have failed"
exit 1
else
echo "OK: correctly rejected --flavor with --provider=postgresql"
fi
- name: Cleanup
if: always()
run: |
for dir in ~/sandboxes/pg_sandbox_* ~/sandboxes/postgresql_*; do
[ -d "$dir" ] && bash "$dir/stop" 2>/dev/null || true
rm -rf "$dir"
done 2>/dev/null || true
pkill -9 -u "$USER" postgres 2>/dev/null || true
# Test the "downloads get-by-version" + "unpack" flow that users follow
# from the quickstart guide. This catches registry gaps and download issues.
downloads-test:
name: Downloads get-by-version (${{ matrix.short-version }})
runs-on: ubuntu-22.04
strategy:
fail-fast: false
matrix:
short-version:
- '8.4'
- '9.5'
env:
GO111MODULE: on
SANDBOX_BINARY: ${{ github.workspace }}/opt/mysql
SHORT_VERSION: ${{ matrix.short-version }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
- name: Install system libraries
run: |
sudo apt-get update
sudo apt-get install -y libaio1 libnuma1 libncurses5
- name: Build dbdeployer
run: go build -o dbdeployer .
- name: Test downloads get-by-version
run: |
echo "=== Testing: dbdeployer downloads get-by-version $SHORT_VERSION ==="
./dbdeployer downloads get-by-version "$SHORT_VERSION" --newest --minimal
echo "=== Download complete ==="
ls -lh mysql-*.tar.*
- name: Test unpack
run: |
TARBALL=$(ls mysql-*.tar.* | head -1)
echo "=== Unpacking: $TARBALL ==="
mkdir -p "$SANDBOX_BINARY"
./dbdeployer unpack "$TARBALL" --sandbox-binary="$SANDBOX_BINARY"
echo "=== Available versions ==="
./dbdeployer versions --sandbox-binary="$SANDBOX_BINARY"
- name: Test deploy from downloaded binary
run: |
VERSION=$(./dbdeployer versions --sandbox-binary="$SANDBOX_BINARY" | grep -oP '\d+\.\d+\.\d+' | head -1)
echo "=== Deploying: $VERSION ==="
./dbdeployer deploy single "$VERSION" --sandbox-binary="$SANDBOX_BINARY"
~/sandboxes/msb_*/use -e "SELECT VERSION()"
./dbdeployer delete all --skip-confirm
- name: Cleanup
if: always()
run: |
./dbdeployer delete all --skip-confirm 2>/dev/null || true
pkill -9 -u "$USER" mysqld 2>/dev/null || true