Merge "Adds molecule tests to image-serve and correct validation"

This commit is contained in:
Zuul 2019-08-19 12:49:52 +00:00 committed by Gerrit Code Review
commit 355fae7cf9
6 changed files with 215 additions and 11 deletions

View File

@ -0,0 +1,37 @@
# Molecule managed
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
{% if item.registry is defined %}
FROM {{ item.registry.url }}/{{ item.image }}
{% else %}
FROM {{ item.image }}
{% endif %}
RUN if [ $(command -v apt-get) ]; then apt-get update && apt-get install -y python sudo bash ca-certificates && apt-get clean; \
elif [ $(command -v dnf) ]; then dnf makecache && dnf --assumeyes install python sudo python-devel python*-dnf bash {{ item.pkg_extras | default('') }} && dnf clean all; \
elif [ $(command -v yum) ]; then yum makecache fast && yum install -y python sudo yum-plugin-ovl python-setuptools bash {{ item.pkg_extras | default('') }} && sed -i 's/plugins=0/plugins=1/g' /etc/yum.conf && yum clean all; \
elif [ $(command -v zypper) ]; then zypper refresh && zypper install -y python sudo bash python-xml {{ item.pkg_extras | default('') }} && zypper clean -a; \
elif [ $(command -v apk) ]; then apk update && apk add --no-cache python sudo bash ca-certificates {{ item.pkg_extras | default('') }}; \
elif [ $(command -v xbps-install) ]; then xbps-install -Syu && xbps-install -y python sudo bash ca-certificates {{ item.pkg_extras | default('') }} && xbps-remove -O; fi
{% for pkg in item.easy_install | default([]) %}
# install pip for centos where there is no python-pip rpm in default repos
RUN easy_install {{ pkg }}
{% endfor %}
CMD ["sh", "-c", "while true; do sleep 10000; done"]

View File

@ -0,0 +1,51 @@
---
driver:
name: docker
log: true
platforms:
- name: centos7
hostname: centos7
image: centos:7
override_command: True
command: python -m SimpleHTTPServer 8787
pkg_extras: python-setuptools python-enum34 python-netaddr epel-release ruby
easy_install:
- pip
environment: &env
http_proxy: "{{ lookup('env', 'http_proxy') }}"
https_proxy: "{{ lookup('env', 'https_proxy') }}"
- name: fedora28
hostname: fedora28
image: fedora:28
override_command: True
command: python3 -m http.server 8787
pkg_extras: python*-setuptools python*-enum python*-netaddr ruby
environment:
<<: *env
provisioner:
name: ansible
log: true
env:
ANSIBLE_STDOUT_CALLBACK: yaml
ANSIBLE_LIBRARY: "../../../../library"
scenario:
test_sequence:
- destroy
- create
- prepare
- converge
- verify
- destroy
lint:
enabled: false
verifier:
name: testinfra
lint:
name: flake8

View File

@ -0,0 +1,58 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
- name: Converge
hosts: all
gather_facts: no
tasks:
- name: detect wrong port
block:
- name: run validation for wrong port
include_role:
name: image-serve
vars:
container_registry_port: 9999
rescue:
- name: Clear host errors
meta: clear_host_errors
- name: Status message
debug:
msg: "Detected faulty port!"
- name: Ensure we detect faulty tree
block:
- name: run validation for 404
include_role:
name: image-serve
rescue:
- name: Clear host errors
meta: clear_host_errors
- name: Status message
debug:
msg: "Detected faulty image serve tree!"
- name: End play
meta: end_play
- name: Fail the test
fail:
msg: |
The image-serve role should have detected httpd wasn't running or
index.json is absent.

View File

@ -0,0 +1,54 @@
---
# Copyright 2019 Red Hat, Inc.
# All Rights Reserved.
#
# 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.
- name: Prepare
hosts: all
gather_facts: no
tasks:
- name: install hiera
package:
name: hiera
- name: create hiera tree
file:
path: /etc/puppet
state: directory
- name: populate hiera.yaml
copy:
dest: /etc/puppet/hiera.yaml
content: |
:backends:
- yaml
:yaml:
:datadir: "/etc/puppet/"
:hierarchy:
- "common"
- name: populate hiera content
copy:
dest: /etc/puppet/common.yaml
content: |
tripleo_undercloud_conf_file: /undercloud.conf
- name: populate undercloud.conf
copy:
dest: /undercloud.conf
content: |
[DEFAULT]
local_ip = 127.0.0.1

View File

@ -18,21 +18,16 @@
container_registry_host: >-
{{ local_ip.value|default('0.0.0.0', true)|ipaddr('address') }}
- name: Get httpd status
systemd:
name: httpd
register: httpd_state
- name: Ensure httpd is running
assert:
that: httpd_state.status['SubState'] == 'running'
fail_msg: httpd service is not running
success_msg: httpd service is running as expected
- name: Ensure port is open
wait_for:
port: "{{ container_registry_port }}"
host: "{{ container_registry_host }}"
timeout: 10
- name: Ensure registry does answer
uri:
method: HEAD
url: "http://{{ container_registry_host }}:{{ container_registry_port }}/v2/"
url: "http://{{ container_registry_host }}:{{ container_registry_port }}/v2/index.json"
status_code:
- 200
- 204

View File

@ -16,6 +16,7 @@
- tripleo-validations-centos-7-molecule-xfs-check-ftype
- tripleo-validations-centos-7-molecule-no-op-firewall-nova-driver
- tripleo-validations-centos-7-molecule-nova-status
- tripleo-validations-centos-7-molecule-image-serve
gate:
queue: integrated
jobs:
@ -32,6 +33,7 @@
- tripleo-validations-centos-7-molecule-xfs-check-ftype
- tripleo-validations-centos-7-molecule-no-op-firewall-nova-driver
- tripleo-validations-centos-7-molecule-nova-status
- tripleo-validations-centos-7-molecule-image-serve
name: tripleo-validations-molecule-jobs
- job:
files:
@ -125,3 +127,10 @@
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: nova-status
- job:
files:
- ^roles/image-serve/.*
name: tripleo-validations-centos-7-molecule-image-serve
parent: tripleo-validations-centos-7-base
vars:
tripleo_validations_role_name: image-serve