Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
c558eaa
Add travis test file and requirements
dgarros May 18, 2016
e93db65
Initial travis build
dgarros May 18, 2016
80860af
Fix dir name
dgarros May 18, 2016
b0850c0
Add Vagrant installation
dgarros May 18, 2016
06b1dbc
Ignore vagrant files
dgarros May 18, 2016
ac75254
strip variables from \n\r
dgarros May 18, 2016
c4b05ee
Add Ansible config and playbook for Vagrant
dgarros May 18, 2016
878d4ab
Update ansible module installation in travis
dgarros May 18, 2016
c46e17a
Remove bundle
dgarros May 18, 2016
a589ad2
Change travis distro
dgarros May 18, 2016
c04c29a
Install kernel header
dgarros May 18, 2016
5178e54
Add confirmation for linux header install
dgarros May 18, 2016
04d264b
Change virtual box install
dgarros May 18, 2016
c15ca0f
Turn off VT-x and limit to 1 CPU
dgarros May 18, 2016
b542f84
Use Ravello to create Test topology
Nov 10, 2016
8059f7f
Move cd tests later in the test
Nov 10, 2016
c9367da
Move cd test again
Nov 10, 2016
5dca1f5
Clean up tests
Nov 10, 2016
f26284a
Merge branch 'master' of https://github.com/Juniper/ansible-junos-std…
Nov 15, 2016
77747f5
small changes
dgarros Nov 30, 2016
034bbcf
Merge branch 'master' of https://github.com/Juniper/ansible-junos-std…
Nov 30, 2016
1700ecb
Cleanup ping after conflict
Nov 30, 2016
ff0e17a
Merge branch 'unittest' of github.com:dgarros/ansible-junos-stdlib in…
Nov 30, 2016
dfac66a
Move tests for junos_get_facts
Nov 30, 2016
07eefaa
Cleanup vagrant tests
Nov 30, 2016
895d585
Add tests for junos_jsnapy
Nov 30, 2016
0c7d650
Add ARG for Ansible and Jsnapy version to change that at Build time
Dec 1, 2016
3d77ab2
Reorganize travis-ci file to use Docker container for tests
Dec 1, 2016
db40091
Fix issue with inventory name
Dec 1, 2016
af2147d
Change name of the application on Ravello to include more information
Dec 1, 2016
90588be
Add URL to see the Applications on Ravello
Dec 1, 2016
62c3ece
Delete travis_ansible_python file once ravello topology is up
Dec 1, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,5 @@ nosetests.xml
docs/build
docs/*.rst
docs/_build/

tests/.vagrant/*
33 changes: 33 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
language: python
python:
- 2.7

sudo: required
dist: trusty

env:
- ANSIBLE_VERSION=2.2.0.0
- ANSIBLE_VERSION=2.1.3.0

install:
## Create Docker with Ansible modules and all dependancies
- docker build --build-arg ver_ansible=$ANSIBLE_VERSION -t juniper/pyez-ansible:travis .
## Install Ansible locally for Ravello and install Roles
- pip install -q ansible==$ANSIBLE_VERSION
- cd tests
- mkdir library
- git clone https://github.com/Juniper/ravello-ansible.git library/ravello-ansible
- pip install -r library/ravello-ansible/requirements.txt
- cp .travis_ansible_python.yaml group_vars/all/travis_ansible_python.yaml

script:
## Start Virtual topology on Ravello with 2 VQFX and collect IP addresses
## Anyone can connect here to see the list of applications running and see the VMs
## https://cloud.ravellosystems.com/#/GtHFbCOuKgD1pcfkvCCIgenj6DOtn3VgRLjaYipdideCsiPC1NxJitt1UHfhF0Bf/apps
- ansible-playbook -i ravello.ini pb.rav.token.create-deploy.yaml
- ansible-playbook -i ravello.ini pb.rav.token.fqdn_get.yaml
- rm group_vars/all/travis_ansible_python.yaml

## Execute Tests with Docker
- docker run -t -i -v $(pwd):/project juniper/pyez-ansible:travis ansible-playbook -i ravello.ini pb.junos_ping.yaml
- docker run -t -i -v $(pwd):/project juniper/pyez-ansible:travis ansible-playbook -i ravello.ini pb.junos_jsnapy.yaml
7 changes: 5 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
FROM juniper/pyez:2.0.1
MAINTAINER ntwrkguru@gmail.com

ARG ver_ansible=2.2.0.0
ARG ver_jsnapy=1.0.0

WORKDIR /tmp
RUN mkdir /tmp/ansible-junos-stdlib &&\
mkdir /tmp/ansible-junos-stdlib/library &&\
Expand All @@ -15,8 +18,8 @@ RUN tar -czf Juniper.junos ansible-junos-stdlib &&\
apk add build-base gcc g++ make python-dev &&\
pip install junos-netconify &&\
pip install jxmlease &&\
pip install ansible &&\
pip install jsnapy &&\
pip install -q ansible==$ver_ansible &&\
pip install -q jsnapy==$ver_jsnapy &&\
ansible-galaxy install Juniper.junos &&\
apk del -r --purge gcc make g++ &&\
rm -rf /source/* &&\
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
junos-eznc
jxmlease
1 change: 1 addition & 0 deletions tests/.travis_ansible_python.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ansible_python_interpreter: "/home/travis/virtualenv/python2.7.10/bin/python"
4 changes: 4 additions & 0 deletions tests/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[defaults]
hash_behaviour=merge
roles_path = /etc/ansible/roles:library/ravello-ansible/roles
Empty file.
3 changes: 3 additions & 0 deletions tests/junos_jsnapy/add_loopback.set
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
set routing-instances LO10 interface lo0.10
set routing-instances LO10 instance-type virtual-router
set interfaces lo0 unit 10 family inet
2 changes: 2 additions & 0 deletions tests/junos_jsnapy/delete_loopback.set
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
delete routing-instances LO10
delete interfaces lo0 unit 10
11 changes: 11 additions & 0 deletions tests/junos_jsnapy/test_junos_storage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
tests_include:
- check_storage

check_storage:
- command: show system storage
- iterate:
xpath: //system-storage-information/filesystem[normalize-space(mounted-on)='/']
tests:
- is-lt: used-percent, 95
info: "File system {{post['mounted-on']}} use less than 95%"
err: "File system {{post['mounted-on']}} use {{post['used-percent']}} %"
16 changes: 16 additions & 0 deletions tests/junos_jsnapy/test_loopback.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
tests_include:
- test_command_version

test_command_version:
- command: show interfaces terse lo*
- iterate:
xpath: //logical-interface
id: './name'
tests:
- list-not-more: admin-status
err: "Test Failed!! name list changed, <{{pre['admin-status']}}> with name <{{id_0}}> is not found in post snapshot"
info: "Test successful!! name list is same, with name <{{id_0}}>"

- list-not-less: admin-status
err: "Test Failed!! name list changed, <{{pre['admin-status']}}> with name <{{id_0}}> was not present in PRE snapshot"
info: "Test successful!! name list is same, with name <{{id_0}}>"
12 changes: 12 additions & 0 deletions tests/junos_jsnapy/test_version.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
tests_include:
- test_version_check

test_version_check:
- command: show version
- iterate:
id: host-name
xpath: //software-information
tests:
- exists: //package-information/name
info: "Test Succeeded!! node //package-information/name exists with name <{{pre['//package-information/name']}}> and hostname: <{{id_0}} > "
err: "Test Failed!!! node //package-information/name does not exists in hostname: <{{id_0}}> !! "
26 changes: 26 additions & 0 deletions tests/pb.junos_get_facts.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Test junos_get_facts module
hosts: all
connection: local
gather_facts: no
roles:
- Juniper.junos
tasks:
- name: "TEST 1 - Gather Facts"
junos_get_facts:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
ignore_errors: True
register: test1

# - debug: var=test1

- name: Check TEST 1
assert:
that:
- test1.facts.hostname
- test1.facts.serialnumber
- test1.facts.model
- test1.facts.fqdn
217 changes: 217 additions & 0 deletions tests/pb.junos_jsnapy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
---
- name: Test junos_ping module
hosts: all
connection: local
gather_facts: no
roles:
- Juniper.junos
tasks:
##################################################
#### TEST 1 ##
##################################################
- name: "TEST 1 - Execute SNAPCHECK with 1 test file / no dir"
junos_jsnapy:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
test_files: junos_jsnapy/test_junos_storage.yml
action: snapcheck
register: test1
ignore_errors: True
tags: [ test1 ]
# - debug: var=test1

- name: Check TEST 1
assert:
that:
- test1|succeeded
- test1.passPercentage == 100
- test1.total_tests == 1
tags: [ test1 ]

##################################################
#### TEST 2 ##
##################################################
- name: "TEST 2 - Execute SNAPCHECK with 2 test file & dir"
junos_jsnapy:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
test_files:
- test_junos_storage.yml
- test_version.yml
dir: junos_jsnapy
action: snapcheck
register: test2
ignore_errors: True
tags: [ test2 ]
# - debug: var=test2

- name: Check TEST 2
assert:
that:
- test2|succeeded
- test2.passPercentage == 100
- test2.total_tests == 2
tags: [ test2 ]

##################################################
#### TEST 3 ##
##################################################
- name: "TEST 3 - Wrong test file"
junos_jsnapy:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
test_files: file_that_doesnt_exist.yml
action: snapcheck
register: test3
ignore_errors: True
tags: [ test3 ]
# - debug: var=test3

- name: Check TEST 3
assert:
that:
- test3|failed
tags: [ test3 ]

##################################################
#### TEST 4 ##
##################################################
- name: "TEST 4 - SNAP_PRE"
junos_jsnapy:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
test_files: junos_jsnapy/test_loopback.yml
action: snap_pre
register: test4
ignore_errors: True
tags: [ test4 ]

# - debug: var=test4

- name: Check TEST 4
assert:
that:
- test4|succeeded
tags: [ test4 ]

##################################################
#### TEST 5 ##
##################################################
- name: "TEST 5 - SNAP_POST"
junos_jsnapy:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
test_files: junos_jsnapy/test_loopback.yml
action: snap_post
register: test5
ignore_errors: True
tags: [ test5 ]

# - debug: var=test5

- name: Check TEST 5
assert:
that:
- test5|succeeded
tags: [ test5 ]

##################################################
#### TEST 6 ##
##################################################
- name: "TEST 6 - CHECK"
junos_jsnapy:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
test_files: junos_jsnapy/test_loopback.yml
action: check
register: test6
ignore_errors: True
tags: [ test6 ]

- debug: var=test6

- name: Check TEST 6
assert:
that:
- test6|succeeded
- test6.passPercentage == 100
tags: [ test6 ]

##################################################
#### TEST 7 ##
##################################################
- name: "PRE-TEST 7 - Add loopback address"
junos_install_config:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
file: junos_jsnapy/add_loopback.set
overwrite: no
register: test7_1
ignore_errors: True
tags: [ test7 ]

- name: Wait for loopback to come up
pause: seconds=15

- name: "TEST 7 - SNAP_POST with additional loopback"
junos_jsnapy:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
test_files: junos_jsnapy/test_loopback.yml
action: snap_post
register: test7_2
ignore_errors: True
tags: [ test7 ]
# - debug: var=pretest7

- name: "TEST 7 - CHECK"
junos_jsnapy:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
test_files: junos_jsnapy/test_loopback.yml
action: check
register: test7
ignore_errors: True
tags: [ test7 ]
- debug: var=test7

- name: "TEST 7 - Cleanup"
junos_install_config:
host: "{{ ansible_ssh_host }}"
port: "{{ ansible_ssh_port }}"
user: "{{ ansible_ssh_user }}"
passwd: "{{ ansible_ssh_pass }}"
file: junos_jsnapy/delete_loopback.set
overwrite: no
register: test7_3
ignore_errors: True
tags: [ test7 ]

- name: Check TEST 7
assert:
that:
- test7_1|succeeded
- test7_2|succeeded
- test7_3|succeeded
- test7|succeeded
- test7.passPercentage == 50
- test7.total_tests == 2
tags: [ test7 ]
Loading