From e00580462e8e77fecbae3852ec3601079945d853 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Fri, 16 Sep 2016 21:15:42 -0500 Subject: [PATCH] Update testing bits for consistency Change-Id: I6263e91f7b83ace3a747569844a6218ec107c799 Signed-off-by: Kevin Carter --- .gitignore | 8 ++++++++ manual-test.rc | 33 +++++++++++++++++++++++++++++++++ run_tests.sh | 10 +++++----- tests/test.yml | 1 - tox.ini | 31 +++++++++++++++++++++++++------ 5 files changed, 71 insertions(+), 12 deletions(-) create mode 100644 manual-test.rc diff --git a/.gitignore b/.gitignore index 036f683..21adf3c 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,7 @@ doc/build/ *.log *.sql *.sqlite +logs/* # OS generated files # ###################### @@ -61,3 +62,10 @@ releasenotes/build # Test temp files tests/plugins +tests/playbooks +tests/test.retry + +# Vagrant artifacts +.vagrant + + diff --git a/manual-test.rc b/manual-test.rc new file mode 100644 index 0000000..f7e7771 --- /dev/null +++ b/manual-test.rc @@ -0,0 +1,33 @@ +export VIRTUAL_ENV=$(pwd) +export ANSIBLE_HOST_KEY_CHECKING=False +export ANSIBLE_SSH_CONTROL_PATH=/tmp/%%h-%%r + +# TODO (odyssey4me) These are only here as they are non-standard folder +# names for Ansible 1.9.x. We are using the standard folder names for +# Ansible v2.x. We can remove this when we move to Ansible 2.x. +export ANSIBLE_ACTION_PLUGINS=${HOME}/.ansible/plugins/action +export ANSIBLE_CALLBACK_PLUGINS=${HOME}/.ansible/plugins/callback +export ANSIBLE_FILTER_PLUGINS=${HOME}/.ansible/plugins/filter +export ANSIBLE_LOOKUP_PLUGINS=${HOME}/.ansible/plugins/lookup + +# This is required as the default is the current path or a path specified +# in ansible.cfg +export ANSIBLE_LIBRARY=${HOME}/.ansible/plugins/library + +# This is required as the default is '/etc/ansible/roles' or a path +# specified in ansible.cfg +export ANSIBLE_ROLES_PATH=${HOME}/.ansible/roles:$(pwd)/.. + +export ANSIBLE_SSH_ARGS="-o ControlMaster=no \ + -o UserKnownHostsFile=/dev/null \ + -o StrictHostKeyChecking=no \ + -o ServerAliveInterval=64 \ + -o ServerAliveCountMax=1024 \ + -o Compression=no \ + -o TCPKeepAlive=yes \ + -o VerifyHostKeyDNS=no \ + -o ForwardX11=no \ + -o ForwardAgent=yes" + +echo "Run manual functional tests by executing the following:" +echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml -e \"rolename=$(pwd)\"" diff --git a/run_tests.sh b/run_tests.sh index 0a49aa3..482a389 100755 --- a/run_tests.sh +++ b/run_tests.sh @@ -24,23 +24,23 @@ if [ ! "$(which pip)" ]; then fi # Install bindep and tox -pip install bindep tox +sudo pip install bindep tox # CentOS 7 requires two additional packages: # redhat-lsb-core - for bindep profile support # epel-release - required to install python-ndg_httpsclient/python2-pyasn1 if [ "$(which yum)" ]; then - yum -y install redhat-lsb-core epel-release + sudo yum -y install redhat-lsb-core epel-release fi # Install OS packages using bindep if apt-get -v >/dev/null 2>&1 ; then - apt-get update + sudo apt-get update DEBIAN_FRONTEND=noninteractive \ - apt-get -q --option "Dpkg::Options::=--force-confold" \ + sudo apt-get -q --option "Dpkg::Options::=--force-confold" \ --assume-yes install `bindep -b -f bindep.txt test` else - yum install -y `bindep -b -f bindep.txt test` + sudo yum install -y `bindep -b -f bindep.txt test` fi # run through each tox env and execute the test diff --git a/tests/test.yml b/tests/test.yml index 24bd624..a662f26 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -28,7 +28,6 @@ - name: Check os_aggregate_storage exists stat: path: /etc/logrotate.d/os_aggregate_storage - delegate_to: 10.100.100.102 register: os_aggregate_storage - name: Check role functions assert: diff --git a/tox.ini b/tox.ini index 55a5f11..6e6acff 100644 --- a/tox.ini +++ b/tox.ini @@ -94,7 +94,7 @@ commands = [testenv:ansible] deps = {[testenv]deps} - ansible==1.9.4 + ansible==2.1.1 ansible-lint>=2.7.0,<3.0.0 setenv = {[testenv]setenv} @@ -113,6 +113,7 @@ setenv = # This is required as the default is '/etc/ansible/roles' or a path # specified in ansible.cfg ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/.. + ANSIBLE_TRANSPORT = "ssh" commands = rm -rf {homedir}/.ansible/plugins git clone https://git.openstack.org/openstack/openstack-ansible-plugins \ @@ -121,6 +122,11 @@ commands = ansible-galaxy install \ --role-file={toxinidir}/tests/ansible-role-requirements.yml \ --force + rm -rf {homedir}/.ansible/roles/rsyslog_server + bash -c "ln -s {toxinidir} {homedir}/.ansible/roles/rsyslog_server" + rm -rf {toxinidir}/tests/playbooks + git clone https://git.openstack.org/openstack/openstack-ansible-tests \ + {toxinidir}/tests/playbooks [testenv:ansible-syntax] @@ -145,6 +151,22 @@ commands = ansible-lint {toxinidir} +[testenv:func_base] +# NOTE(odyssey4me): this target does not use constraints because +# it doesn't work in OpenStack-CI yet. Once that's fixed, we can +# drop the install_command. +install_command = + pip install -U --force-reinstall {opts} {packages} + + +[testenv:func_logs] +commands = + bash -c 'mkdir -p {toxinidir}/logs' + bash -c 'rsync --archive --verbose --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true' + bash -c 'find "{toxinidir}/logs/" -type f | sed "p;s|$|.txt|" | xargs -n2 mv' + bash -c 'command gzip --best --recursive "{toxinidir}/logs/"' + + [testenv:functional] # Ignore_errors is set to true so that the logs are collected at the # end of the run. This will not produce a false positive. Any @@ -155,7 +177,7 @@ ignore_errors = True # it doesn't work in OpenStack-CI yet. Once that's fixed, we can # drop the install_command. install_command = - pip install -U --force-reinstall {opts} {packages} + {[testenv:func_base]install_command} deps = {[testenv:ansible]deps} setenv = @@ -166,10 +188,7 @@ commands = -e "rolename={toxinidir}" \ -e "install_test_packages=True" \ {toxinidir}/tests/test.yml -vvvv - bash -c 'mkdir -p {toxinidir}/logs' - bash -c 'rsync --archive --verbose --ignore-errors /var/log/ /openstack/log/ {toxinidir}/logs/ || true' - bash -c 'find "{toxinidir}/logs/" -type f | sed "p;s|$|.txt|" | xargs -n2 mv' - bash -c 'command gzip --best --recursive "{toxinidir}/logs/"' + {[testenv:func_logs]commands} [testenv:linters]