From 4b6f3a65d978d011693035122957927ff9b914c1 Mon Sep 17 00:00:00 2001 From: Vicente Cheng Date: Wed, 6 Dec 2023 16:35:13 +0800 Subject: [PATCH] ci: add test for the files should be created Signed-off-by: Vicente Cheng (cherry picked from commit 28fb14ac8aa851296b73fd2635d365349e182dc4) --- ci/run_vagrant_install_test.yml | 8 ++++++++ ci/terraform/check_files.sh | 23 +++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 ci/terraform/check_files.sh diff --git a/ci/run_vagrant_install_test.yml b/ci/run_vagrant_install_test.yml index 3e02e2b9a..39f977d29 100644 --- a/ci/run_vagrant_install_test.yml +++ b/ci/run_vagrant_install_test.yml @@ -139,6 +139,14 @@ args: chdir: "{{ WORKSPACE }}/harvester-installer/ci/terraform" + - name: Testing existing files + vars: + settings_file: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml" + shell: > + ./check_files.sh {{ settings_file}} + args: + chdir: "{{ WORKSPACE }}/harvester-installer/ci/terraform" + - name: Testing services status vars: settings_file: "{{ WORKSPACE }}/ipxe-examples/vagrant-pxe-harvester/settings.yml" diff --git a/ci/terraform/check_files.sh b/ci/terraform/check_files.sh new file mode 100755 index 000000000..aacc91d89 --- /dev/null +++ b/ci/terraform/check_files.sh @@ -0,0 +1,23 @@ +#!/bin/bash -ex + +if [[ $# != 1 ]] +then + echo "We need the settings.yaml from ipxe repo" + exit 1 +fi + +SETTINGS=$1 + +EXISTING_FILES="/oem/grubenv /oem/grubcustom" +NODE0_IP=$(yq e ".harvester_network_config.cluster[0].ip" ${SETTINGS}) + +echo "Check files that should exist." + +SSHKEY=./tmp-ssh-key +for filepath in ${EXISTING_FILES}; do + echo "Prepare to check file: ${filepath} ..." + if ! ssh -o "StrictHostKeyChecking no" -i tmp-ssh-key rancher@$NODE0_IP "sudo stat ${filepath}" | grep -q ${filepath}; then + echo "${filepath} should exist, exit!" + exit 1 + fi +done \ No newline at end of file