Skip to content
Permalink
Browse files

[ci] Add support for test scripts in jane

  • Loading branch information...
drybjed committed Aug 11, 2019
1 parent a9fefda commit 9c3e7aa9812ca210fcfdd054f82e865e11191d87
Showing with 21 additions and 0 deletions.
  1. +1 −0 .gitlab-ci.yml
  2. +1 −0 Vagrantfile
  3. +19 −0 lib/tests/jane
@@ -24,6 +24,7 @@

variables:
TEST_PLAYBOOKS: '/vagrant/lib/tests/playbooks'
TEST_SCRIPTS: '/vagrant/lib/tests/scripts'
DEBOPS_PLAYBOOKS: '/vagrant/ansible/playbooks'
VAGRANT_DOTFILE_PATH: '/var/tmp/vagrant-dotfile-${CI_JOB_ID}'
GIT_STRATEGY: 'clone'
@@ -285,6 +285,7 @@ export CI_JOB_NAME="#{ENV['CI_JOB_NAME']}"
export CI_JOB_STAGE="#{ENV['CI_JOB_STAGE']}"
export JANE_TEST_PLAY="#{ENV['JANE_TEST_PLAY']}"
export JANE_TEST_FACT="#{ENV['JANE_TEST_FACT']}"
export JANE_TEST_SCRIPT="#{ENV['JANE_TEST_SCRIPT']}"
export JANE_FORCE_TESTS="#{ENV['JANE_FORCE_TESTS']}"
export JANE_INVENTORY_DIRS="#{ENV['JANE_INVENTORY_DIRS']}"
export JANE_INVENTORY_GROUPS="#{ENV['JANE_INVENTORY_GROUPS']}"
@@ -65,6 +65,7 @@ readonly JANE_LOG_PATTERN="${JANE_LOG_PATTERN:-}"
readonly JANE_FORCE_TESTS="${JANE_FORCE_TESTS:-}"
readonly JANE_TEST_PLAY="${JANE_TEST_PLAY:-}"
readonly JANE_TEST_FACT="${JANE_TEST_FACT:-}"
readonly JANE_TEST_SCRIPT="${JANE_TEST_SCRIPT:-}"
readonly JANE_ANSIBLE_CONFIG="${JANE_ANSIBLE_CONFIG:-/vagrant/lib/tests/ansible.cfg}"
readonly JANE_ANSIBLE_INVENTORY="${JANE_ANSIBLE_INVENTORY:-/vagrant/lib/tests/jane}"
readonly JANE_INVENTORY_DIRS="${JANE_INVENTORY_DIRS:-common}"
@@ -348,6 +349,7 @@ sub__ansible__playbook () {
local ANSIBLE_INVENTORY="${JANE_ANSIBLE_INVENTORY}"
local jane_test_play="${JANE_TEST_PLAY}"
local jane_test_fact="${JANE_TEST_FACT}"
local jane_test_script="${JANE_TEST_SCRIPT}"
local inventory_path
IFS=':' read -r -a inventory_path <<< "${INVENTORY_PATH}"
local jane_inventory_dirs
@@ -356,9 +358,11 @@ sub__ansible__playbook () {
local jane_inventory_hostvars=( "${JANE_INVENTORY_HOSTVARS}" )
local -a test_playbooks
local -a test_facts
local -a test_scripts

IFS=" " read -r -a test_playbooks <<< "${jane_test_play}"
IFS=" " read -r -a test_facts <<< "${jane_test_fact}"
IFS=" " read -r -a test_scripts <<< "${jane_test_script}"

export ANSIBLE_CONFIG
export ANSIBLE_INVENTORY
@@ -426,11 +430,26 @@ sub__ansible__playbook () {
status_msg info "Contents of the '${element%.fact}' local fact:"
cat "${fact_script}"
fi
status_msg ok "Ansible local fact script succeeded"
else
status_msg warning "The '${element%.fact}' Ansible local fact doesn't exist"
fi
done
fi

if [ -n "${test_scripts[*]}" ] ; then
for element in "${test_scripts[@]}" ; do
if [ -f "${element}" ] ; then
if [ -x "${element}" ] ; then
status_msg info "Executing the '$(basename "${element}")' test script..."
"${element}"
status_msg ok "The '$(basename "${element}")' test script completed successfully"
fi
else
status_msg warning "The '${element}' test script doesn't exist"
fi
done
fi
}


0 comments on commit 9c3e7aa

Please sign in to comment.
You can’t perform that action at this time.