Add testinfra tests for bridge

Change-Id: I4df79669c9daa3eb998ee666be6c53c957467748
This commit is contained in:
James E. Blair 2018-08-30 16:05:06 -07:00 committed by Ian Wienand
parent e54afccc77
commit 4477291111
3 changed files with 46 additions and 19 deletions

View File

@ -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

View File

@ -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

45
testinfra/test_bridge.py Normal file
View File

@ -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