Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sf network zuul #2

Merged
merged 5 commits into from Jul 10, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
73 changes: 73 additions & 0 deletions .zuul.d/jobs.yaml
@@ -0,0 +1,73 @@
#####################################################################
# Projects
#

- project:
#third-party-check:
check:
jobs:
- noop
#- ansible-test-network-integration-vyos-devel-py2
#- ansible-test-network-integration-vyos-devel-py3
gate:
jobs:
- noop


#####################################################################
# ansible-test-network-integration
#
# Integration tests for Networking
#

- job:
name: ansible-test-network-integration
description: |
Parent job for ``ansible-test network-integration`` tests.

Responds to these variables:

.. zuul:jobvar:: python_version

Instruct ansible-test to test against this version of Python.

Example ``2.6``, ``2.7``, ``3.5``, ``3.6``

.. zuul:jobvar:: platform

Network platform to test against, such as ``eos``, ``ios``, ``vyos``
run: test/utils/zuul/playbooks/ansible-test-network-integration/run.yaml
timeout: 3000

- job:
name: ansible-test-network-integration-vyos-devel-py2
description: ansible-test network-integration on Python 2
parent: ansible-test-network-integration
files:
- ^zuul.d/.*$
- ^lib/ansible/modules/network/vyos/.*$
- ^lib/ansible/module_utils/network/vyos/.*$
vars:
platform: vyos
python_version: 2.7
nodeset:
nodes:
- name: test-node
label: ansible-network-vyos-1.1.8

- job:
name: ansible-test-network-integration-vyos-devel-py3
description: ansible-test network-integration on Python 3
parent: ansible-test-network-integration
files:
- ^zuul.d/.*$
- ^lib/ansible/modules/network/vyos/.*$
- ^lib/ansible/module_utils/network/vyos/.*$
vars:
platform: vyos
python_version: 3.6
nodeset:
nodes:
- name: test-node
label: ansible-network-vyos-1.1.8

66 changes: 66 additions & 0 deletions roles/ansible-test-network-integration/tasks/main.yaml
@@ -0,0 +1,66 @@
---

# Ensure we have clean results structure to store results files
# This could be used in the future to enable ansibullbot
- name: Ensure previous results files have been removed
file:
path: "{{ ansible_path }}/test/results/bot"
state: absent

- name: Create results directory
file:
path: "{{ ansible_path }}/test/results/bot"
state: directory

- name: Create sub results file
copy:
content: '{"verified": false, "results": []}'
dest: "{{ ansible_path }}/test/results/bot/ansible-test-failure.json"


- name: Install dependencies not listed in runner/requirements/network-integration.txt
pip:
name: tox
executable: "{{ item }}"
become: yes
with_items:
- pip2
- pip3

- name: Wait for VM SSH
wait_for:
port: 8022
search_regex: SSH

###
# Run ansible-test
#

- name: Build test options
set_fact:
standard_options: '--color no --tox --continue-on-error --changes'
test_targets: "{{ platform}}_.*"

- name: Run ansible-test network-integration
command: "{{ ansible_path }}/test/runner/ansible-test network-integration --inventory /var/lib/network-image-builder/output/{{ platform }}/inventory {{ standard_options }} --python {{ python_version }} {{ test_targets }}"

##
# Check for failures
#

- name: Remove temporary results file
file:
path: "{{ ansible_path }}/test/results/bot/ansible-test-failure.json"
state: absent

- name: Examine results files
find:
path: "{{ ansible_path }}/test/results/bot"
patterns: "ansible-test-*.json"
register: results_files

- name: Check for failing tests
fail:
msg: One or more tests have failed
when:
results_files.matched
3 changes: 3 additions & 0 deletions roles/ansible-test-network-integration/vars/main.yaml
@@ -0,0 +1,3 @@
---
ansible_path_query: "[?name=='ansible/ansible'].src_dir"
ansible_path: "{{ (zuul.projects.values() | list | json_query(ansible_path_query))[0] }}"
40 changes: 40 additions & 0 deletions test/utils/zuul/README.rst
@@ -0,0 +1,40 @@
Zuul configuration
==================

This directory contains the configuration for testing Ansible Network via Software Factory's Zuul instance.


Configuration
=============

The configuration is split across the following locations

Webhook
^^^^^^^

FIXME

Software Factory tenant configuration
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

FIXME, will be into https://softwarefactory-project.io/cgit/config/tree/zuul/ansible_networking.yaml

Defines the repos that ``softwarefactory-project-zuul`` should read configuration from.

ansible/zuul-config
^^^^^^^^^^^^^^^^^^^

Trusted configuration project

Minimal, non-branched configuration. Shouldn't change often.


ansible/ansible
^^^^^^^^^^^^^^^

To allow what and how we test to be updated over time, while still allowing tests to run against older we are storing as much of the Zuul configuration in the Ansible repo as possible.

* ``.zuul.d/jobs.yaml`` - Lists the ``jobs`` that should be run
* ``test/utils/zuul/playbooks/``- Maps hosts (``nodeset``) to roles
* ``roles/`` - Details how to run the tests (FIXME will move to ``test/utils/zuul/`` in the future

@@ -0,0 +1,4 @@
---
- hosts: all
roles:
- ansible-test-network-integration