diff --git a/manual-test.rc b/manual-test.rc index f7e77710..7016c453 100644 --- a/manual-test.rc +++ b/manual-test.rc @@ -30,4 +30,4 @@ export ANSIBLE_SSH_ARGS="-o ControlMaster=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)\"" +echo "# ./.tox/functional/bin/ansible-playbook -i tests/inventory tests/test.yml" diff --git a/tests/test-upgrade.yml b/tests/test-upgrade.yml index c55857b1..5a2cb19b 100644 --- a/tests/test-upgrade.yml +++ b/tests/test-upgrade.yml @@ -14,8 +14,8 @@ # limitations under the License. # Setup the host -- include: playbooks/test-install-openstack-hosts.yml -- include: playbooks/test-setup-host.yml +- include: common/test-install-openstack-hosts.yml +- include: common/test-setup-host.yml # Install previous version of RabbitMQ server - include: test-install-rabbitmq-server.yml diff --git a/tests/test.yml b/tests/test.yml index ac7395ad..9b98a272 100644 --- a/tests/test.yml +++ b/tests/test.yml @@ -14,7 +14,7 @@ # limitations under the License. # Setup the host -- include: playbooks/test-setup-host.yml +- include: common/test-setup-host.yml # Install RabbitMQ server - include: test-install-rabbitmq-server.yml diff --git a/tox.ini b/tox.ini index 22058c69..21c8972e 100644 --- a/tox.ini +++ b/tox.ini @@ -11,7 +11,7 @@ install_command = deps = -r{toxinidir}/test-requirements.txt commands = - /usr/bin/find . -type f -name "*.py[c|o]" -delete + /usr/bin/find . -type f -name "*.pyc" -delete passenv = HOME http_proxy @@ -22,12 +22,11 @@ passenv = NO_PROXY whitelist_externals = bash - git - rm - wget setenv = - VIRTUAL_ENV={envdir} PYTHONUNBUFFERED=1 + ROLE_NAME=rabbitmq_server + VIRTUAL_ENV={envdir} + WORKING_DIR={toxinidir} [testenv:docs] @@ -53,17 +52,17 @@ commands = {posargs} +[testenv:tests_clone] +commands = + bash -c "if [ ! -d "{toxinidir}/tests/common" ]; then \ + git clone https://git.openstack.org/openstack/openstack-ansible-tests {toxinidir}/tests/common; \ + fi" + + [testenv:pep8] commands = - # Run hacking/flake8 check for all python files - bash -c "grep --recursive --binary-files=without-match \ - --files-with-match '^.!.*python$' \ - --exclude-dir .eggs \ - --exclude-dir .git \ - --exclude-dir .tox \ - --exclude-dir *.egg-info \ - --exclude-dir doc \ - {toxinidir} | xargs flake8 --verbose" + {[testenv:tests_clone]commands} + bash -c "{toxinidir}/tests/common/test-pep8.sh" [flake8] @@ -76,64 +75,22 @@ ignore=F403,H303 [testenv:bashate] commands = - # Run bashate check for all bash scripts - # Ignores the following rules: - # E003: Indent not multiple of 4 (we prefer to use multiples of 2) - # E006: Line longer than 79 columns (as many scripts use jinja - # templating, this is very difficult) - # E040: Syntax error determined using `bash -n` (as many scripts - # use jinja templating, this will often fail and the syntax - # error will be discovered in execution anyway) - bash -c "grep --recursive --binary-files=without-match \ - --files-with-match '^.!.*\(ba\)\?sh$' \ - --exclude-dir .tox \ - --exclude-dir .git \ - {toxinidir} | xargs bashate --error . --verbose --ignore=E003,E006,E040" + {[testenv:tests_clone]commands} + bash -c "{toxinidir}/tests/common/test-bashate.sh" [testenv:ansible] deps = {[testenv]deps} - ansible==2.1.1 - ansible-lint>=2.7.0,<3.0.0 -setenv = - {[testenv]setenv} - ANSIBLE_HOST_KEY_CHECKING = False - 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. - ANSIBLE_ACTION_PLUGINS = {homedir}/.ansible/plugins/action - ANSIBLE_CALLBACK_PLUGINS = {homedir}/.ansible/plugins/callback - ANSIBLE_FILTER_PLUGINS = {homedir}/.ansible/plugins/filter - ANSIBLE_LOOKUP_PLUGINS = {homedir}/.ansible/plugins/lookup - # This is required as the default is the current path or a path specified - # in ansible.cfg - ANSIBLE_LIBRARY = {homedir}/.ansible/plugins/library - # 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" + -rhttp://git.openstack.org/cgit/openstack/openstack-ansible-tests/plain/test-ansible-deps.txt commands = - rm -rf {homedir}/.ansible/plugins - git clone https://git.openstack.org/openstack/openstack-ansible-plugins \ - {homedir}/.ansible/plugins - rm -rf {homedir}/.ansible/roles - ansible-galaxy install \ - --role-file={toxinidir}/tests/ansible-role-requirements.yml \ - --force - rm -rf {homedir}/.ansible/roles/rabbitmq_server - bash -c "ln -s {toxinidir} {homedir}/.ansible/roles/rabbitmq_server" - rm -rf {toxinidir}/tests/playbooks - git clone https://git.openstack.org/openstack/openstack-ansible-tests \ - {toxinidir}/tests/playbooks + {[testenv:tests_clone]commands} + bash -c "{toxinidir}/tests/common/test-ansible-env-prep.sh" [testenv:ansible-syntax] deps = {[testenv:ansible]deps} -setenv = - {[testenv:ansible]setenv} commands = {[testenv:ansible]commands} ansible-playbook -i {toxinidir}/tests/inventory \ @@ -149,6 +106,7 @@ commands = {[testenv:ansible]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 @@ -159,10 +117,7 @@ install_command = [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/"' + bash -c "{toxinidir}/tests/common/test-log-collect.sh" [testenv:functional] @@ -178,8 +133,6 @@ install_command = {[testenv:func_base]install_command} deps = {[testenv:ansible]deps} -setenv = - {[testenv:ansible]setenv} commands = {[testenv:ansible]commands} ansible-playbook -i {toxinidir}/tests/inventory \ @@ -187,33 +140,10 @@ commands = {toxinidir}/tests/test.yml -vvvv {[testenv:func_logs]commands} -[testenv:func_upgrade] -# 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 -# exception will be mark the run as failed and exit 1 after all of -# the commands have been iterated through. -ignore_errors = True -# 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 = - {[testenv:func_base]install_command} -deps = - {[testenv:ansible]deps} -setenv = - {[testenv:ansible]setenv} -commands = - {[testenv:ansible]commands} - ansible-playbook -i {toxinidir}/tests/inventory \ - -e "install_test_packages=True" \ - {toxinidir}/tests/test-upgrade.yml -vvvv - {[testenv:func_logs]commands} [testenv:linters] deps = {[testenv:ansible]deps} -setenv = - {[testenv:ansible]setenv} commands = {[testenv:pep8]commands} {[testenv:bashate]commands}