Skip to content

Commit 724ebfa

Browse files
Update Travis test environments to Netbox 2.6, 2.7 (#145)
1 parent 8640ac2 commit 724ebfa

File tree

6 files changed

+51
-14
lines changed

6 files changed

+51
-14
lines changed

.travis.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ language: python
33
services:
44
- docker
55

6-
sudo: false
6+
os: linux
7+
dist: bionic
78

89
env:
910
global:
@@ -12,11 +13,12 @@ env:
1213
- COLLECTION_VERSION: 0.1.10
1314
- secure: "tE6GtwrRU+Kjobx/94xqR2MqM20pHCnrLcHgPzIHA3npdwuA+GjCBiBLTkEEQM4fUWIfzUTyjSr9bZErm1PTI1GcIRdniTgJ3ZzSSkE7tgeYALB/7xsusB57SlmbBQm2SGwU558uWZ3NHEsi0WTgD8GKZo77OpGX72FZKsVXOz6k2wve51sOtoSVjgCsvWTmZHx4ynGdiA5wFkZfaEcjXECahKtunW+MlB5kpJzkVeLRUEXFMhWlsIYiA5nj8OI/X3Nk9ugh1ribENX9LrjpgrqQ9YariZ8G6py1ONuKZIn2g7xs5kNQ3qL6HL6N7SoUxiwH16CfSyugFaYiMfaxQ4NUVGGRHS4vSGbNIf+gLHcYvP40miI1f/+pntCzqygZMhW73FX2o+KH2OGv09khOl8k1nDg2/XvW0kCc/FU6l+Jp5wCC8H9X2uiULtQpRqts5TzIonlPEzGIpfGFgJ5m54Emhv9gjG1Z5OOyL/qae1Wr+L/uhiFafcglZYh8NHEMWCUCkeqFqR2kDmUMtdgYLD7Q7NdwlL/PSVVs1l7UPiQHlnecQKEHN7CvR3eKByTEmkCKafRYh/JQ9rBt9sZc7aAPVu+w3wWUwbHS4o4vVnmyXvJb1PeJSiuynF7CBo4Qd6qj4YwX8gLK6PylGyaMOp169u6xw1mo5/CX0pJ3x4="
1415

15-
matrix:
16+
jobs:
1617
include:
17-
- name: "Python 3.6 - Netbox 2.5 - Latest PyPi Ansible"
18+
# Previous release of Netbox, latest release of Ansible
19+
- name: "Python 3.6 - Netbox 2.6 - Latest PyPi Ansible"
1820
python: 3.6
19-
env: PYTHON_VER=3.6 VERSION=v2.5
21+
env: PYTHON_VER=3.6 VERSION=v2.6
2022
install:
2123
- cd ..
2224
# Setup netbox container for integration testing
@@ -29,13 +31,32 @@ matrix:
2931
- pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0
3032
- pip install pynetbox cryptography codecov jmespath ansible
3133

32-
- name: "Python 3.6 - Netbox 2.6 - Ansible Devel"
34+
# Latest release of Netbox and Ansible
35+
- name: "Python 3.6 - Netbox 2.7 - Latest PyPi Ansible"
3336
python: 3.6
34-
env: PYTHON_VER=3.6 VERSION=v2.6
37+
env: PYTHON_VER=3.6 VERSION=v2.7
3538
install:
3639
- cd ..
3740
# Setup netbox container for integration testing
38-
- git clone https://github.com/FragmentedPacket/netbox-docker.git
41+
- git clone https://github.com/netbox-community/netbox-docker.git
42+
- cd netbox-docker
43+
- docker-compose pull
44+
- docker-compose up -d
45+
- cd ..
46+
- pip install -U pip
47+
- pip install pytest==4.6.5 pytest-mock pytest-xdist jinja2 PyYAML black==19.10b0
48+
- pip install pynetbox cryptography codecov jmespath ansible
49+
50+
# Latest development versions of Netbox and Ansible, newest Python
51+
# This may be broken sometimes by changes in the netbox & ansible projects
52+
# Failures will be allowed in this build
53+
- name: "Python 3.8 - Netbox develop-2.8 - Ansible Devel"
54+
python: 3.8
55+
env: PYTHON_VER=3.8 VERSION=develop-2.8
56+
install:
57+
- cd ..
58+
# Setup netbox container for integration testing
59+
- git clone https://github.com/netbox-community/netbox-docker.git
3960
- cd netbox-docker
4061
- docker-compose pull
4162
- docker-compose up -d
@@ -47,6 +68,9 @@ matrix:
4768
- cd ansible
4869
- source hacking/env-setup
4970
- cd ..
71+
allow_failures:
72+
# When testing against dev netbox and dev ansible, allow failures
73+
- env: PYTHON_VER=3.8 VERSION=develop-2.8
5074

5175
before_script:
5276
- mkdir -p ~/ansible_collections/$COLLECTION_NAMESPACE
@@ -56,10 +80,20 @@ before_script:
5680
- ansible-galaxy collection install $COLLECTION_NAMESPACE-$COLLECTION_NAME-$COLLECTION_VERSION.tar.gz -p /home/travis/.ansible/collections
5781

5882
script:
59-
- ansible-test units --python $PYTHON_VER -v
60-
- black . --check
83+
# Perform unit tests on collection from within the installed directory, not the source directory
84+
# Required for imports of other collections (ie. ansible.netcommon) to work correctly
85+
- (cd /home/travis/.ansible/collections/ansible_collections/$COLLECTION_NAMESPACE/$COLLECTION_NAME && ansible-test units --python $PYTHON_VER -v)
86+
87+
# Check python syntax
88+
- black . --check --diff
89+
90+
# Wait for Netbox containers to be running
6191
- timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:32768)" != "200" ]]; do echo "waiting for Netbox"; sleep 5; done' || false
92+
93+
# Prepare data in Netbox
6294
- python tests/integration/netbox-deploy.py
95+
96+
# Run regression and integration tests
6397
- ansible-playbook tests/integration/regression-tests.yml -vvvv
6498
- ansible-playbook tests/integration/integration-tests.yml -vvvv
6599
- ansible-inventory -i tests/integration/test-inventory.yml --list

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ To keep the code simple, we only officially support the two latest releases of N
1010

1111
## Requirements
1212

13-
- NetBox 2.5+ or the two latest NetBox releases
13+
- NetBox 2.6+ or the two latest NetBox releases
1414
- **pynetbox 4.2.5+**
1515
- Python 3.6+
1616
- Ansible 2.9+

galaxy.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ tags:
4545
# collection label 'namespace.name'. The value is a version range
4646
# L(specifiers,https://python-semanticversion.readthedocs.io/en/latest/#requirement-specification). Multiple version
4747
# range specifiers can be set and are separated by ','
48-
dependencies: {}
48+
dependencies:
49+
ansible.netcommon: "*"
4950

5051
# The URL of the originating SCM repository
5152
repository: https://github.com/netbox-community/ansible_modules

plugins/inventory/nb_inventory.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,9 @@
133133
from ansible.module_utils._text import to_text
134134
from ansible.module_utils.urls import open_url
135135
from ansible.module_utils.six.moves.urllib.parse import urlencode
136-
from ansible.module_utils.compat.ipaddress import ip_interface
136+
from ansible_collections.ansible.netcommon.plugins.module_utils.compat.ipaddress import (
137+
ip_interface,
138+
)
137139

138140
ALLOWED_DEVICE_QUERY_PARAMETERS = (
139141
"asset_tag",

plugins/module_utils/netbox_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import traceback
1010
import re
1111
from itertools import chain
12-
from ansible.module_utils.compat import ipaddress
12+
from ansible_collections.ansible.netcommon.plugins.module_utils.compat import ipaddress
1313
from ansible.module_utils._text import to_text
1414

1515
# from ._text import to_native

plugins/modules/netbox_interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@
222222
INTF_FORM_FACTOR,
223223
INTF_MODE,
224224
)
225-
from ansible.module_utils.compat import ipaddress
225+
from ansible_collections.ansible.netcommon.plugins.module_utils.compat import ipaddress
226226
from ansible.module_utils._text import to_text
227227

228228

0 commit comments

Comments
 (0)