tests: convert extra-vars to use json

This will prevent ansible from misreading any of these values. There
were failures with xenial deployments because the value set for
``ceph_rhcs`` was being treated as a boolean True even though I'd set
the value to false. This is because boolean values passed in with
--extra-vars must use the json format.

The formatting of the json is very important as you need a '\' to escape
the starting and ending json to make tox happy. Also, each line needs to
end with '\' if it's a multi-line command.

Another thing to note is that if you want to use extra vars at the
command line to respond to a vars_prompt it must be in key/value format.
This is why we have a -e and a --extra-vars on the purge and update
tests.

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
pull/1368/head
Andrew Schoen 2017-03-16 06:16:09 -05:00
parent d76b1d9609
commit 000110d2a2
1 changed files with 45 additions and 42 deletions

87
tox.ini
View File

@ -9,28 +9,29 @@ skipsdist = True
[purge]
commands=
cp {toxinidir}/infrastructure-playbooks/purge-cluster.yml {toxinidir}/purge-cluster.yml
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/purge-cluster.yml --extra-vars="\
ireallymeanit=yes \
fetch_directory={changedir}/fetch \
ceph_rhcs={env:CEPH_RHCS:false} \
ceph_origin={env:CEPH_ORIGIN:upstream} \
ceph_dev={env:CEPH_DEV:false} \
ceph_dev_branch={env:CEPH_DEV_BRANCH:master} \
ceph_dev_sha1={env:CEPH_DEV_SHA1:latest} \
ceph_stable_release={env:CEPH_STABLE_RELEASE:jewel} \
ceph_stable={env:CEPH_STABLE:true} \
"
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/purge-cluster.yml -e ireallymeanit=yes --extra-vars '\
\{\
"fetch_directory":"{changedir}/fetch",\
"ceph_rhcs":{env:CEPH_RHCS:false},\
"ceph_origin":"{env:CEPH_ORIGIN:upstream}",\
"ceph_dev":{env:CEPH_DEV:false},\
"ceph_dev_branch":"{env:CEPH_DEV_BRANCH:master}",\
"ceph_dev_sha1":"{env:CEPH_DEV_SHA1:latest}",\
"ceph_stable_release":"{env:CEPH_STABLE_RELEASE:jewel}",\
"ceph_stable":{env:CEPH_STABLE:true}\
\}'
# set up the cluster again
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/site.yml.sample --extra-vars="\
fetch_directory={changedir}/fetch \
ceph_rhcs={env:CEPH_RHCS:false} \
ceph_origin={env:CEPH_ORIGIN:upstream} \
ceph_dev={env:CEPH_DEV:false} \
ceph_dev_branch={env:CEPH_DEV_BRANCH:master} \
ceph_dev_sha1={env:CEPH_DEV_SHA1:latest} \
ceph_stable_release={env:CEPH_STABLE_RELEASE:jewel} \
ceph_stable={env:CEPH_STABLE:true} \
"
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/site.yml.sample --extra-vars '\
\{\
"fetch_directory":"{changedir}/fetch",\
"ceph_rhcs":{env:CEPH_RHCS:false},\
"ceph_origin":"{env:CEPH_ORIGIN:upstream}",\
"ceph_dev":{env:CEPH_DEV:false},\
"ceph_dev_branch":"{env:CEPH_DEV_BRANCH:master}",\
"ceph_dev_sha1":"{env:CEPH_DEV_SHA1:latest}",\
"ceph_stable_release":"{env:CEPH_STABLE_RELEASE:jewel}",\
"ceph_stable":{env:CEPH_STABLE:true}\
\}'
# test that the cluster can be redeployed in a healthy state
testinfra -n 4 --sudo -v --connection=ansible --ansible-inventory={changedir}/hosts {toxinidir}/tests/functional/tests
@ -40,17 +41,17 @@ commands=
[update]
commands=
cp {toxinidir}/infrastructure-playbooks/rolling_update.yml {toxinidir}/rolling_update.yml
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/rolling_update.yml --extra-vars="\
ceph_stable_release={env:UPDATE_CEPH_STABLE_RELEASE:kraken} \
ireallymeanit=yes \
fetch_directory={changedir}/fetch \
ceph_rhcs={env:CEPH_RHCS:false} \
ceph_origin={env:CEPH_ORIGIN:upstream} \
ceph_dev={env:CEPH_DEV:false} \
ceph_dev_branch={env:UPDATE_CEPH_DEV_BRANCH:master} \
ceph_dev_sha1={env:UPDATE_CEPH_DEV_SHA1:latest} \
ceph_stable={env:CEPH_STABLE:true} \
"
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/rolling_update.yml -e ireallymeanit=yes --extra-vars '\
\{\
"fetch_directory":"{changedir}/fetch",\
"ceph_rhcs":{env:CEPH_RHCS:false},\
"ceph_origin":"{env:CEPH_ORIGIN:upstream}",\
"ceph_dev":{env:CEPH_DEV:false},\
"ceph_dev_branch":"{env:UPDATE_CEPH_DEV_BRANCH:master}",\
"ceph_dev_sha1":"{env:UPDATE_CEPH_DEV_SHA1:latest}",\
"ceph_stable_release":"{env:UPDATE_CEPH_STABLE_RELEASE:kraken}",\
"ceph_stable":{env:CEPH_STABLE:true}\
\}'
testinfra -n 4 --sudo -v --connection=ansible --ansible-inventory={changedir}/hosts {toxinidir}/tests/functional/tests
@ -97,16 +98,18 @@ commands=
vagrant up --no-provision {posargs:--provider=virtualbox}
bash {toxinidir}/tests/scripts/generate_ssh_config.sh {changedir}
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/{env:PLAYBOOK:site.yml.sample} --extra-vars="\
fetch_directory={changedir}/fetch \
ceph_rhcs={env:CEPH_RHCS:false} \
ceph_origin={env:CEPH_ORIGIN:upstream} \
ceph_dev={env:CEPH_DEV:false} \
ceph_dev_branch={env:CEPH_DEV_BRANCH:master} \
ceph_dev_sha1={env:CEPH_DEV_SHA1:latest} \
ceph_stable_release={env:CEPH_STABLE_RELEASE:jewel} \
ceph_stable={env:CEPH_STABLE:true} \
"
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/{env:PLAYBOOK:site.yml.sample} --extra-vars '\
\{\
"fetch_directory":"{changedir}/fetch",\
"ceph_rhcs":{env:CEPH_RHCS:false},\
"ceph_origin":"{env:CEPH_ORIGIN:upstream}",\
"ceph_dev":{env:CEPH_DEV:false},\
"ceph_dev_branch":"{env:CEPH_DEV_BRANCH:master}",\
"ceph_dev_sha1":"{env:CEPH_DEV_SHA1:latest}",\
"ceph_stable_release":"{env:CEPH_STABLE_RELEASE:jewel}",\
"ceph_stable":{env:CEPH_STABLE:true}\
\}'
ansible-playbook -vv -i {changedir}/hosts {toxinidir}/tests/functional/setup.yml
testinfra -n 4 --sudo -v --connection=ansible --ansible-inventory={changedir}/hosts {toxinidir}/tests/functional/tests