From 9143810a4db0b7ba40b94d1184f404628003591c Mon Sep 17 00:00:00 2001
From: Calin Cristian Andrei <cristian.calin@outlook.com>
Date: Tue, 19 Apr 2022 10:49:39 +0300
Subject: [PATCH] [CI] add remove node job

---
 .gitlab-ci.yml                                       | 1 +
 .gitlab-ci/packet.yml                                | 8 ++++++++
 tests/files/packet_almalinux8-calico-remove-node.yml | 7 +++++++
 tests/scripts/testcases_run.sh                       | 5 +++++
 4 files changed, 21 insertions(+)
 create mode 100644 tests/files/packet_almalinux8-calico-remove-node.yml

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8a145aa40..9b92261c9 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -27,6 +27,7 @@ variables:
   ANSIBLE_INVENTORY: ./inventory/sample/${CI_JOB_NAME}-${BUILD_NUMBER}.ini
   IDEMPOT_CHECK: "false"
   RESET_CHECK: "false"
+  REMOVE_NODE_CHECK: "false"
   UPGRADE_TEST: "false"
   MITOGEN_ENABLE: "false"
   ANSIBLE_LOG_LEVEL: "-vv"
diff --git a/.gitlab-ci/packet.yml b/.gitlab-ci/packet.yml
index 237e2b501..a0d514c5c 100644
--- a/.gitlab-ci/packet.yml
+++ b/.gitlab-ci/packet.yml
@@ -283,6 +283,14 @@ packet_debian10-calico-upgrade:
   variables:
     UPGRADE_TEST: graceful
 
+packet_almalinux8-calico-remove-node:
+  stage: deploy-part3
+  extends: .packet_pr
+  when: on_success
+  variables:
+    REMOVE_NODE_CHECK: "true"
+    REMOVE_NODE_NAME: "instance-3"
+
 packet_debian10-calico-upgrade-once:
   stage: deploy-part3
   extends: .packet_periodic
diff --git a/tests/files/packet_almalinux8-calico-remove-node.yml b/tests/files/packet_almalinux8-calico-remove-node.yml
new file mode 100644
index 000000000..4cb5dfc04
--- /dev/null
+++ b/tests/files/packet_almalinux8-calico-remove-node.yml
@@ -0,0 +1,7 @@
+---
+# Instance settings
+cloud_image: almalinux-8
+mode: ha
+
+# Kubespray settings
+auto_renew_certificates: true
diff --git a/tests/scripts/testcases_run.sh b/tests/scripts/testcases_run.sh
index ed16b24d0..5947309df 100755
--- a/tests/scripts/testcases_run.sh
+++ b/tests/scripts/testcases_run.sh
@@ -109,6 +109,11 @@ if [ "${IDEMPOT_CHECK}" = "true" ]; then
   fi
 fi
 
+# Test node removal procedure
+if [ "${REMOVE_NODE_CHECK}" = "true" ]; then
+  ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_SETTING} -e @${CI_TEST_REGISTRY_MIRROR}  -e @${CI_TEST_VARS} ${CI_TEST_ADDITIONAL_VARS} -e skip_confirmation=yes -e node=${REMOVE_NODE_NAME} --limit "all:!fake_hosts" remove-node.yml
+fi
+
 # Clean up at the end, this is to allow stage1 tests to include cleanup test
 if [ "${RESET_CHECK}" = "true" ]; then
   ansible-playbook ${ANSIBLE_LOG_LEVEL} -e @${CI_TEST_SETTING} -e @${CI_TEST_REGISTRY_MIRROR}  -e @${CI_TEST_VARS} ${CI_TEST_ADDITIONAL_VARS} -e reset_confirmation=yes --limit "all:!fake_hosts" reset.yml
-- 
GitLab