1
0
mirror of https://github.com/oVirt/ovirt-ansible-engine-setup.git synced 2026-02-05 06:44:53 +01:00

Add linters & syntax check in tox and extra docker tests in travis CI

This commit is contained in:
Katerina Koukiou
2017-12-08 20:19:50 +01:00
committed by Ondra Machacek
parent 4c3f4c6f39
commit 200df2215b
16 changed files with 186 additions and 0 deletions

4
.gitignore vendored Normal file
View File

@@ -0,0 +1,4 @@
.tox
*.retry
roles/provision_docker

42
.travis.yml Normal file
View File

@@ -0,0 +1,42 @@
---
sudo: required
language: python
python:
- "2.7"
services:
- docker
env:
global:
- ANSIBLE_HOST_KEY_CHECKING="False"
matrix:
- TEST_NAME=4.1
- TEST_NAME=master
- TEST_NAME=upgrade-4.1-to-master
# Tests on previous versions cannot be enabled on Centos
# because of https://github.com/rhevm-qe-automation/ovirt-ansible/issues/155
# Install python-pip
addons:
apt:
packages:
- python-pip
install:
- pip install tox ansible docker-py
# Check ansible version
- ansible --version
# Install ansible role tests requirements
- ansible-galaxy install -r tests/requirements.yml -p tests/roles/
script:
# Run sytax checks and linters
- tox
# Execute oVirt engine deployment playbook
- travis_wait 20 ansible-playbook tests/test-${TEST_NAME}.yml -i tests/inventory --skip-tags skip-travis -vvv
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/

6
.yamllint Normal file
View File

@@ -0,0 +1,6 @@
---
extends: default
rules:
line-length: disable

1
requirements.txt Normal file
View File

@@ -0,0 +1 @@
ansible

3
test-requirements.txt Normal file
View File

@@ -0,0 +1,3 @@
ansible-lint
yamllint
flake8

View File

@@ -0,0 +1,15 @@
---
- name: Bring up docker containers
hosts: localhost
gather_facts: false
roles:
- role: provision_docker
provision_docker_inventory_group: "{{ groups['engine'] }}"
- name: "Update python because of ovirt-imageio-proxy"
hosts: engine
tasks:
- name: Update python
yum:
name: python-libs
state: latest

17
tests/engine-deploy.yml Normal file
View File

@@ -0,0 +1,17 @@
---
- name: Run ovirt-ansible roles on containerized environments
hosts: engine
vars_files:
- passwords.yml
vars:
ovirt_engine_setup_type: "ovirt-engine"
ovirt_engine_setup_version: "{{ ovirt_engine_setup_version }}"
ovirt_engine_setup_hostname: "localhost"
ovirt_engine_setup_organization: "example.com"
ovirt_engine_setup_dwh_db_configure: true
ovirt_engine_setup_dwh_db_host: "localhost"
ovirt_engine_setup_firewall_manager: null
ovirt_repositories_ovirt_release_rpm: "{{ ovirt_release_rpm }}"
roles:
- role: oVirt.repositories
- role: oVirt.engine-setup

20
tests/engine-upgrade.yml Normal file
View File

@@ -0,0 +1,20 @@
---
- name: Run ovirt-ansible roles on containerized environments
hosts: engine
vars_files:
- passwords.yml
vars:
ovirt_engine_setup_type: "ovirt-engine"
ovirt_engine_setup_version: "{{ ovirt_engine_setup_version }}"
ovirt_engine_setup_hostname: "localhost"
ovirt_engine_setup_organization: "example.com"
ovirt_engine_setup_firewall_manager: null
ovirt_engine_setup_dwh_db_configure: false
ovirt_repositories_ovirt_release_rpm: "{{ ovirt_release_rpm }}"
roles:
- role: oVirt.repositories
- role: oVirt.engine-setup
# --accept-defaults needed because of: https://bugzilla.redhat.com/show_bug.cgi?id=1518697
# Can be solved also with https://bugzilla.redhat.com/show_bug.cgi?id=1396925
ovirt_engine_setup_accept_defaults: true
ovirt_engine_setup_answer_file_path: "answerfile_{{ ovirt_engine_setup_version }}_upgrade.txt.j2"

4
tests/inventory Normal file
View File

@@ -0,0 +1,4 @@
localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python"
[engine]
engine_centos7 image="katerinak/c7-systemd-utf8"

12
tests/passwords.yml Normal file
View File

@@ -0,0 +1,12 @@
---
# As an example this file is keep in plaintext, if you want to
# encrypt this file, please execute following command:
#
# $ ansible-vault encrypt passwords.yml
#
# It will ask you for a password, which you must then pass to
# ansible interactively when executing the playbook.
#
# $ ansible-playbook myplaybook.yml --ask-vault-pass
#
ovirt_engine_setup_admin_password: 123456

4
tests/requirements.yml Normal file
View File

@@ -0,0 +1,4 @@
---
- src: chrismeyersfsu.provision_docker
name: provision_docker
- src: oVirt.repositories

View File

@@ -0,0 +1 @@
../../

6
tests/test-4.1.yml Normal file
View File

@@ -0,0 +1,6 @@
---
- import_playbook: containers-deploy.yml
- import_playbook: engine-deploy.yml
vars:
ovirt_engine_setup_version: "4.1"
ovirt_release_rpm: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release41.rpm"

6
tests/test-master.yml Normal file
View File

@@ -0,0 +1,6 @@
---
- import_playbook: containers-deploy.yml
- import_playbook: engine-deploy.yml
vars:
ovirt_engine_setup_version: "4.2"
ovirt_release_rpm: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release-master.rpm"

View File

@@ -0,0 +1,10 @@
---
- import_playbook: containers-deploy.yml
- import_playbook: engine-deploy.yml
vars:
ovirt_engine_setup_version: "4.1"
ovirt_release_rpm: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release41.rpm"
- import_playbook: engine-upgrade.yml
vars:
ovirt_engine_setup_version: "4.2"
ovirt_release_rpm: "http://plain.resources.ovirt.org/pub/yum-repo/ovirt-release-master.rpm"

35
tox.ini Normal file
View File

@@ -0,0 +1,35 @@
[tox]
skipsdist = True
envlist = linters
[testenv]
deps =
-r{toxinidir}/requirements.txt
-r{toxinidir}/test-requirements.txt
whitelist_externals = bash
[testenv:ansible-lint]
commands = bash -c "\
ansible-lint "{toxinidir}"/tests/test*.yml"
[testenv:yamllint]
commands = bash -c "\
yamllint \
-c {toxinidir}/.yamllint \
{toxinidir}/tasks \
{toxinidir}/tests/*.yml"
[testenv:ansible-syntax]
commands = bash -c "\
ansible-galaxy install -r tests/requirements.yml -p tests/roles/; \
ansible-playbook \
--syntax-check \
--list-tasks \
{toxinidir}/tests/test*.yml"
[testenv:linters]
commands =
{[testenv:yamllint]commands}
{[testenv:ansible-syntax]commands}
{[testenv:ansible-lint]commands}