system-config/testinfra/test_mirror.py
Clark Boylan c0ac38c2c9 Listen on Quay Registry Mirror Ports
We need to tell apache to listen on the ports used by the Quay Registry
Mirror. Without this we aren't actually able to provide connections to
this vhost.

Add testing to ensure this is working in a simple manner.

Change-Id: I28bdb7aeb9c3252c6319658acaa530a7d7c25a72
2020-05-19 16:47:51 -07:00

113 lines
4.4 KiB
Python

# Copyright 2019 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 = ['mirror01.openafs.provider.opendev.org',
'mirror02.openafs.provider.opendev.org']
def test_apache(host):
apache = host.service('apache2')
assert apache.is_running
def test_base_mirror(host):
# BaseMirror
for addr in host.addr(host.backend.host).ip_addresses:
cmd = host.run("wget --no-check-certificate -qO- https://%s/" % addr)
assert '<a href="debian/">' in cmd.stdout
cmd = host.run("wget -qO- http://%s/" % addr)
assert '<a href="debian/">' in cmd.stdout
def test_proxy_mirror(host):
# ProxyMirror
for addr in host.addr(host.backend.host).ipv4_addresses:
cmd = host.run("wget --no-check-certificate -qO- "
"https://%s:4443/pypi/simple/setuptools" % addr)
assert 'setuptools' in cmd.stdout
cmd = host.run("wget -qO- "
"http://%s:8080/pypi/simple/setuptools" % addr)
assert 'setuptools' in cmd.stdout
# split the test cases so that we can escape the ipv6 addrs properly
for addr in host.addr(host.backend.host).ipv6_addresses:
cmd = host.run("wget --no-check-certificate -qO- "
"https://[%s]:4443/pypi/simple/setuptools" % addr)
assert 'setuptools' in cmd.stdout
cmd = host.run("wget -qO- "
"http://[%s]:8080/pypi/simple/setuptools" % addr)
assert 'setuptools' in cmd.stdout
def test_dockerv1_mirror(host):
# Dockerv1Mirror
for addr in host.addr(host.backend.host).ipv4_addresses:
cmd = host.run("wget --no-check-certificate -O- "
"https://%s:4444/registry-1.docker" % addr)
# TODO assert that this proxy cache is working more properly
assert '403 Forbidden' in cmd.stderr
cmd = host.run("wget -O- http://%s:8081/registry-1.docker" % addr)
# TODO assert that this proxy cache is working more properly
assert '403 Forbidden' in cmd.stderr
for addr in host.addr(host.backend.host).ipv6_addresses:
cmd = host.run("wget --no-check-certificate -O- "
"https://[%s]:4444/registry-1.docker" % addr)
# TODO assert that this proxy cache is working more properly
assert '403 Forbidden' in cmd.stderr
cmd = host.run("wget -O- http://[%s]:8081/registry-1.docker" % addr)
# TODO assert that this proxy cache is working more properly
assert '403 Forbidden' in cmd.stderr
def test_dockerv2_mirror(host):
# Dockerv2Mirror
for addr in host.addr(host.backend.host).ipv4_addresses:
cmd = host.run("wget --no-check-certificate -O- "
"https://%s:4445/v2/" % addr)
assert '401 Unauthorized' in cmd.stderr
cmd = host.run("wget -O- http://%s:8082/v2/" %addr)
assert '401 Unauthorized' in cmd.stderr
for addr in host.addr(host.backend.host).ipv6_addresses:
cmd = host.run("wget --no-check-certificate -O- "
"https://[%s]:4445/v2/" % addr)
assert '401 Unauthorized' in cmd.stderr
cmd = host.run("wget -O- http://[%s]:8082/v2/" %addr)
assert '401 Unauthorized' in cmd.stderr
def test_quay_mirror(host):
# QuayRegistryMirror
for addr in host.addr(host.backend.host).ipv4_addresses:
cmd = host.run("wget --no-check-certificate -qO- "
"https://%s:4447/" % addr)
assert 'quay' in cmd.stdout
cmd = host.run("wget -qO- http://%s:8084/" % addr)
assert 'quay' in cmd.stdout
for addr in host.addr(host.backend.host).ipv6_addresses:
cmd = host.run("wget --no-check-certificate -qO- "
"https://[%s]:4447/" % addr)
assert 'quay' in cmd.stdout
cmd = host.run("wget -qO- http://[%s]:8084/" % addr)
assert 'quay' in cmd.stdout
# TODO test RHRegistryMirror