Skip to content
This repository has been archived by the owner on Feb 9, 2022. It is now read-only.

Commit

Permalink
Add linters & syntax check in tox and extra docker tests in travis CI
Browse files Browse the repository at this point in the history
  • Loading branch information
KKoukiou committed Jan 5, 2018
1 parent 093eadf commit 4130b19
Show file tree
Hide file tree
Showing 16 changed files with 186 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.tox
*.retry
roles/provision_docker

42 changes: 42 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions .yamllint
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
extends: default

rules:
line-length: disable

1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ansible
3 changes: 3 additions & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ansible-lint
yamllint
flake8
15 changes: 15 additions & 0 deletions tests/containers-deploy.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 17 additions & 0 deletions tests/engine-deploy.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 20 additions & 0 deletions tests/engine-upgrade.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions tests/inventory
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
localhost ansible_connection=local ansible_python_interpreter="/usr/bin/env python"

[engine]
engine_centos7 image="katerinak/c7-systemd-utf8"
12 changes: 12 additions & 0 deletions tests/passwords.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 4 additions & 0 deletions tests/requirements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
- src: chrismeyersfsu.provision_docker
name: provision_docker
- src: oVirt.repositories
1 change: 1 addition & 0 deletions tests/roles/oVirt.engine-setup
6 changes: 6 additions & 0 deletions tests/test-4.1.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 6 additions & 0 deletions tests/test-master.yml
Original file line number Diff line number Diff line change
@@ -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"
10 changes: 10 additions & 0 deletions tests/test-upgrade-4.1-to-master.yml
Original file line number Diff line number Diff line change
@@ -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 changes: 35 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -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}

0 comments on commit 4130b19

Please sign in to comment.