system-config/testinfra/test_nodepool.py
Monty Taylor 8d7075b02f Run zookeeper cluster in nodepool jobs
Rather than running a local zookeeper, just run a real zookeeper.
Also, get rid of nb01-test and just use nb04 - what could possibly
go wrong?

Dynamically write zookeeper host information to nodepool.yaml

So that we can run an actual zk using the new zk role on hosts in
ansible inventory, we need to write out the ip addresses of the
hosts that we build in zuul. This means having the info baked in
to the file in project-config isn't going to work.

We can do this in prod too, it shouldn't hurt anything.

Increase timeout for run-service-nodepool

We need to fix the playbook, but we'll do that after we get the
puppet gone.

Change-Id: Ib01d461ae2c5cec3c31ec5105a41b1a99ff9d84a
2020-04-29 16:18:25 -05:00

58 lines
1.9 KiB
Python

# 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.
import pytest
testinfra_hosts = ['nl01.openstack.org', 'nb01.openstack.org',
'nb04.opendev.org']
def test_clouds_yaml(host):
if host.backend.get_hostname().endswith('openstack.org'):
cfg_file = '/home/nodepool/.config/openstack/clouds.yaml'
else:
cfg_file = '/etc/openstack/clouds.yaml'
clouds_yaml = host.file(cfg_file)
assert clouds_yaml.exists
assert b'password' in clouds_yaml.content
def test_kube_config(host):
if not host.backend.get_hostname().endswith('openstack.org'):
pytest.skip()
kubeconfig = host.file('/home/nodepool/.kube/config')
assert kubeconfig.exists
assert b'nodepool_k8s_key' in kubeconfig.content
def test_builder_container_running(host):
if host.backend.get_hostname() != 'nb04.opendev.org':
pytest.skip()
cmd = host.run("docker ps -a --format '{{ .Names }}'")
assert 'nodepool-builder-compose_nodepool-builder_1' in cmd.stdout
def test_builder_webserver_running(host):
if host.backend.get_hostname() != 'nb04.opendev.org':
pytest.skip()
apache = host.service('apache2')
assert apache.is_running
cmd = host.run('curl --insecure '
'--resolve nb04.opendev.org:443:127.0.0.1 '
'https://nb04.opendev.org/')
assert 'Index of /' in cmd.stdout