Skip to content

feat: add per-pr smoke tests #935

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
38 changes: 38 additions & 0 deletions .github/workflows/smoke-deploy-lab.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Running hyperconverged smoke tests

on:
pull_request:
paths:
- ansible/**
- base-kustomize/**
- base-helm-configs/**
- bin/**
- scripts/**

env:
HYPERCONVERGED_DEV: "true"
GATEWAY_DOMAIN: cloud.local
ACME_EMAIL: [email protected]
OS_IMAGE: "Ubuntu 24.04"
SSH_USERNAME: "ubuntu"

jobs:
smoke-deploy:
runs-on: self-hosted
container:
image: localhost:5000/genestack-ci:latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Dynamically set MY_DATE environment variable
run: echo "LAB_NAME_PREFIX=smoke-$(date +%s)" >> $GITHUB_ENV

- name: Run deployment script
run: |
eval "$(ssh-agent -s)"
scripts/hyperconverged-lab.sh

- name: Cleanup the lab
if: always()
run: scripts/hyperconverged-lab-uninstall.sh
23 changes: 15 additions & 8 deletions scripts/hyperconverged-lab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,11 @@ if ! COMPUTE_2_PORT=$(openstack port show ${LAB_NAME_PREFIX}-2-compute-port -f v
)
fi

if [ ! -d "~/.ssh" ]; then
echo "Creating the SSH directory"
mkdir -p ~/.ssh
chmod 700 ~/.ssh
fi
if ! openstack keypair show ${LAB_NAME_PREFIX}-key 2> /dev/null; then
if [ ! -f ~/.ssh/${LAB_NAME_PREFIX}-key.pem ]; then
openstack keypair create ${LAB_NAME_PREFIX}-key > ~/.ssh/${LAB_NAME_PREFIX}-key.pem
Expand Down Expand Up @@ -290,11 +295,11 @@ fi

echo "Waiting for the jump host to be ready"
COUNT=0
while ! ssh -o StrictHostKeyChecking=no -o ConnectTimeout=2 -o ConnectionAttempts=3 -o UserKnownHostsFile=/dev/null -q ${SSH_USERNAME}@${JUMP_HOST_VIP} exit; do
while ! ssh -o ConnectTimeout=2 -o ConnectionAttempts=3 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -q ${SSH_USERNAME}@${JUMP_HOST_VIP} exit; do
sleep 2
echo "SSH is not ready, Trying again..."
COUNT=$((COUNT+1))
if [ $COUNT -gt 30 ]; then
if [ $COUNT -gt 60 ]; then
echo "Failed to ssh into the jump host"
exit 1
fi
Expand All @@ -307,16 +312,16 @@ if [ "${HYPERCONVERGED_DEV:-false}" = "true" ]; then
echo "HYPERCONVERGED_DEV is true, but we've failed to determine the base genestack directory"
exit 1
fi
ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -t ${SSH_USERNAME}@${JUMP_HOST_VIP} \
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} \
"timeout 1m bash -c 'while ! sudo apt update; do sleep 2; done' && sudo apt install -y rsync git"
echo "Copying the development source code to the jump host"
rsync -az \
-e "ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null" \
-e "ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no" \
--rsync-path="sudo rsync" \
$(readlink -fn ${SCRIPT_DIR}/../) ${SSH_USERNAME}@${JUMP_HOST_VIP}:/opt/
fi

ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
set -e
if ! command -v git &> /dev/null; then
echo "git could not be found, installing..."
Expand Down Expand Up @@ -472,6 +477,8 @@ if [ ! -f "/etc/genestack/helm-configs/glance/glance-helm-overrides.yaml" ]; the
cat > /etc/genestack/helm-configs/glance/glance-helm-overrides.yaml <<EOF
conf:
glance:
DEFAULT:
workers: 2
oslo_messaging_notifications:
driver: noop
glance_api_uwsgi:
Expand Down Expand Up @@ -620,7 +627,7 @@ fi
EOC

# Run host and K8S setup
ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
set -e
if [ ! -f "/usr/local/bin/queue_max.sh" ]; then
python3 -m venv ~/.venvs/genestack
Expand Down Expand Up @@ -652,7 +659,7 @@ popd
EOC

# Run Genestack Infrastucture/OpenStack Setup
ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
set -e
echo "Installing OpenStack Infrastructure"
sudo LONGHORN_STORAGE_REPLICAS=1 \
Expand All @@ -665,7 +672,7 @@ sudo /opt/genestack/bin/setup-openstack.sh
EOC

# Run Genestack post setup
ssh -o StrictHostKeyChecking=no -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
ssh -o ForwardAgent=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -t ${SSH_USERNAME}@${JUMP_HOST_VIP} <<EOC
set -e
sudo bash <<HERE
sudo /opt/genestack/bin/setup-openstack-rc.sh
Expand Down