From 44772911113e56a3dc859184b2fcc5b2cd26aa15 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Thu, 30 Aug 2018 16:05:06 -0700 Subject: [PATCH] Add testinfra tests for bridge Change-Id: I4df79669c9daa3eb998ee666be6c53c957467748 --- playbooks/zuul/run-base.yaml | 2 +- testinfra/test_base.py | 18 --------------- testinfra/test_bridge.py | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 46 insertions(+), 19 deletions(-) create mode 100644 testinfra/test_bridge.py diff --git a/playbooks/zuul/run-base.yaml b/playbooks/zuul/run-base.yaml index 319c848aef..39bb771eb0 100644 --- a/playbooks/zuul/run-base.yaml +++ b/playbooks/zuul/run-base.yaml @@ -47,7 +47,7 @@ - name: Display group membership command: ansible localhost -m debug -a 'var=groups' - name: Run base.yaml - command: ansible-playbook /home/zuul/src/git.openstack.org/openstack-infra/system-config/playbooks/base.yaml + command: ansible-playbook -v /home/zuul/src/git.openstack.org/openstack-infra/system-config/playbooks/base.yaml - name: Run testinfra to validate configuration include_role: name: tox diff --git a/testinfra/test_base.py b/testinfra/test_base.py index f0b7dc5783..9b961491e1 100644 --- a/testinfra/test_base.py +++ b/testinfra/test_base.py @@ -166,21 +166,3 @@ def test_logrotate(host): assert cfg_file.exists assert cfg_file.contains('/var/log/ansible/run_all_cron.log') - -def test_openstacksdk_config(host): - ansible_vars = host.ansible.get_variables() - if ansible_vars['inventory_hostname'] == 'bridge.openstack.org': - f = host.file('/etc/openstack') - assert f.exists - assert f.is_directory - assert f.user == 'root' - assert f.group == 'root' - assert f.mode == 0o750 - del f - - f = host.file('/etc/openstack/limestone_cacert.pem') - assert f.exists - assert f.is_file - assert f.user == 'root' - assert f.group == 'root' - assert f.mode == 0o640 diff --git a/testinfra/test_bridge.py b/testinfra/test_bridge.py new file mode 100644 index 0000000000..439cc6355f --- /dev/null +++ b/testinfra/test_bridge.py @@ -0,0 +1,45 @@ +# Copyright 2018 Red Hat, Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + + +testinfra_hosts = ['bridge.openstack.org'] + + +def test_clouds_yaml(host): + clouds_yaml = host.file('/etc/openstack/clouds.yaml') + assert clouds_yaml.exists + + assert b'password' in clouds_yaml.content + + all_clouds_yaml = host.file('/etc/openstack/all-clouds.yaml') + assert all_clouds_yaml.exists + + assert b'password' in all_clouds_yaml.content + + +def test_openstacksdk_config(host): + f = host.file('/etc/openstack') + assert f.exists + assert f.is_directory + assert f.user == 'root' + assert f.group == 'root' + assert f.mode == 0o750 + del f + + f = host.file('/etc/openstack/limestone_cacert.pem') + assert f.exists + assert f.is_file + assert f.user == 'root' + assert f.group == 'root' + assert f.mode == 0o640