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

move provisioning cluster to jenkins agent in bml #965

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
22 changes: 11 additions & 11 deletions jenkins/scripts/bare_metal_lab/tasks/deploy-tasks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,17 +47,6 @@
cmd: "brctl addif provisioning eno1"
become: true

- name: Deploy bmhosts
template:
src: "templates/bmhosts_crs.yaml.j2"
dest: "/opt/metal3-dev-env/bmhosts_crs.yaml"

- name: Apply bmhosts manifest
shell:
cmd: kubectl apply -f ./bmhosts_crs.yaml -n metal3
chdir: "/opt/metal3-dev-env/"
tags: kubectl_apply

- name: Set VLAN 3 interface to be up
shell:
cmd: "ip link set up dev bmext"
Expand All @@ -80,6 +69,17 @@
when: brctl_grep_bmext.rc != 0
tags: bmext

- name: Deploy bmhosts
template:
src: "templates/bmhosts_crs.yaml.j2"
dest: "/opt/metal3-dev-env/bmhosts_crs.yaml"

- name: Apply bmhosts manifest
shell:
cmd: kubectl apply -f ./bmhosts_crs.yaml -n metal3
chdir: "/opt/metal3-dev-env/"
tags: kubectl_apply

- name: Wait until all BMHs become available .
kubernetes.core.k8s_info:
api_version: metal3.io/v1alpha1
Expand Down
23 changes: 4 additions & 19 deletions jenkins/scripts/bml_cleanup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,9 @@ set -eu
# Usage:
# cleanup_bml.sh
#
echo "Cleaning up the lab"
# Execute remote script
# shellcheck disable=SC2029

TEST_EXECUTER_IP="192.168.1.3"
CI_DIR="$(dirname "$(readlink -f "${0}")")"

echo "Cleaning up the lab"

ssh \
-o StrictHostKeyChecking=no \
-o UserKnownHostsFile=/dev/null \
-o ServerAliveInterval=15 \
-o ServerAliveCountMax=10 \
-o SendEnv="BML_ILO_USERNAME" \
-o SendEnv="BML_ILO_PASSWORD" \
-o SendEnv="GITHUB_TOKEN" \
-o SendEnv="REPO_NAME" \
-o SendEnv="BML_METAL3_DEV_ENV_REPO" \
-o SendEnv="BML_METAL3_DEV_ENV_BRANCH" \
-o SendEnv="PR_ID" \
-i "${METAL3_CI_USER_KEY}" \
"${METAL3_CI_USER}"@"${TEST_EXECUTER_IP}" \
ANSIBLE_FORCE_COLOR=true ansible-playbook -v /tmp/bare_metal_lab/cleanup-lab.yaml --skip-tags "clone"
ANSIBLE_FORCE_COLOR=true ansible-playbook -v "${CI_DIR}"/bare_metal_lab/cleanup-lab.yaml --skip-tags "clone"
43 changes: 6 additions & 37 deletions jenkins/scripts/bml_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,7 @@ CAPM3RELEASEBRANCH="${CAPM3RELEASEBRANCH:-main}"
BMORELEASEBRANCH="${BMORELEASEBRANCH:-main}"
BARE_METAL_LAB=true

TEST_EXECUTER_IP="192.168.1.3"

cat <<-EOF >"${CI_DIR}/files/vars.sh"
cat <<-EOF >"/tmp/vars.sh"
REPO_ORG="${REPO_ORG}"
REPO_NAME="${REPO_NAME}"
REPO_BRANCH="${REPO_BRANCH}"
Expand All @@ -54,43 +52,14 @@ TARGET_NODE_MEMORY="${TARGET_NODE_MEMORY}"
BARE_METAL_LAB="${BARE_METAL_LAB}"
EOF

cat "${CI_DIR}/integration_test_env.sh" >>"${CI_DIR}/files/vars.sh"

declare -a SSH_OPTIONS=(
-o StrictHostKeyChecking=no
-o UserKnownHostsFile=/dev/null
-o ServerAliveInterval=15
-o ServerAliveCountMax=10
-i "${METAL3_CI_USER_KEY}"
)

# Send Remote script to Executer
scp -r \
"${CI_DIR}/files/run_integration_tests.sh" \
"${CI_DIR}/files/vars.sh" \
"${CI_DIR}/bare_metal_lab/" \
"${METAL3_CI_USER}@${TEST_EXECUTER_IP}:/tmp/" >/dev/null
cat "${CI_DIR}/integration_test_env.sh" >>"/tmp/vars.sh"

echo "Setting up the lab"
# Execute remote script
# shellcheck disable=SC2029
ssh \
-o SendEnv="BML_ILO_USERNAME" \
-o SendEnv="BML_ILO_PASSWORD" \
-o SendEnv="GITHUB_TOKEN" \
-o SendEnv="REPO_NAME" \
-o SendEnv="BML_METAL3_DEV_ENV_REPO" \
-o SendEnv="BML_METAL3_DEV_ENV_BRANCH" \
-o SendEnv="PR_ID" \
"${SSH_OPTIONS[@]}" \
"${METAL3_CI_USER}"@"${TEST_EXECUTER_IP}" \
ANSIBLE_FORCE_COLOR=true ansible-playbook -v /tmp/bare_metal_lab/deploy-lab.yaml

ANSIBLE_FORCE_COLOR=true ansible-playbook -v "${CI_DIR}"/bare_metal_lab/deploy-lab.yaml

echo "Running the tests"
# Execute remote script
# shellcheck disable=SC2029
ssh \
"${SSH_OPTIONS[@]}" \
"${METAL3_CI_USER}"@"${TEST_EXECUTER_IP}" \
PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/bin \
/tmp/run_integration_tests.sh /tmp/vars.sh "${GITHUB_TOKEN}"

"${CI_DIR}"/files/run_integration_tests.sh /tmp/vars.sh "${GITHUB_TOKEN}"
4 changes: 2 additions & 2 deletions jenkins/scripts/files/run_clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ else
export EPHEMERAL_CLUSTER="minikube"
fi
if [[ "${REPO_NAME}" == "metal3-dev-env" ]]; then
pushd tested_repo
pushd "${HOME}/tested_repo"
else
pushd metal3
pushd "${HOME}/metal3"
fi
make clean
10 changes: 3 additions & 7 deletions jenkins/scripts/files/run_integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

set -eux

VARS_FILE="${1:?}"
export GITHUB_TOKEN="${2:?}"

# shellcheck disable=SC1090
source "${VARS_FILE}"
export GITHUB_TOKEN="${1:?}"

export CAPI_VERSION
export CAPM3_VERSION
Expand Down Expand Up @@ -37,9 +33,9 @@ fi
# In the bare metal lab, we have already cloned metal3-dev-env and we run integration tests
# so no need to clone other repos.
if [[ "${REPO_NAME}" == "metal3-dev-env" ]]; then
cd tested_repo
cd "${HOME}/tested_repo"
else
cd metal3
cd "${HOME}/metal3"
fi

# See bare metal lab infrastructure documentation:
Expand Down