Run inventory test during Jenkins lint check
Change-Id: I51ac381b516f7a71051c67270310591e4c09fdbe
This commit is contained in:
parent
c7f141dbab
commit
e7060e421a
@ -8,12 +8,11 @@ import subprocess
|
|||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
|
|
||||||
INV_DIR = '../playbooks/inventory'
|
INV_DIR = 'playbooks/inventory'
|
||||||
SCRIPT_FILENAME = 'dynamic_inventory.py'
|
SCRIPT_FILENAME = 'dynamic_inventory.py'
|
||||||
INV_SCRIPT = path.join(INV_DIR, SCRIPT_FILENAME)
|
INV_SCRIPT = path.join(os.getcwd(), INV_DIR, SCRIPT_FILENAME)
|
||||||
|
|
||||||
# We'll use the test directory, and have tox do the cd command for us.
|
TARGET_DIR = path.join(os.getcwd(), 'tests', 'inventory')
|
||||||
TARGET_DIR = path.join(os.getcwd(), 'inventory')
|
|
||||||
|
|
||||||
# These files will be placed in TARGET_DIR by INV_SCRIPT.
|
# These files will be placed in TARGET_DIR by INV_SCRIPT.
|
||||||
# They should be cleaned up between each test.
|
# They should be cleaned up between each test.
|
||||||
@ -34,7 +33,7 @@ def cleanup():
|
|||||||
def get_inventory():
|
def get_inventory():
|
||||||
"Return the inventory mapping in a dict."
|
"Return the inventory mapping in a dict."
|
||||||
try:
|
try:
|
||||||
cmd = [INV_SCRIPT, '--file', TARGET_DIR]
|
cmd = [INV_SCRIPT, '--config', TARGET_DIR]
|
||||||
inventory_string = subprocess.check_output(cmd)
|
inventory_string = subprocess.check_output(cmd)
|
||||||
inventory = json.loads(inventory_string)
|
inventory = json.loads(inventory_string)
|
||||||
return inventory
|
return inventory
|
||||||
|
12
tox.ini
12
tox.ini
@ -1,7 +1,7 @@
|
|||||||
[tox]
|
[tox]
|
||||||
minversion = 1.6
|
minversion = 1.6
|
||||||
skipsdist = True
|
skipsdist = True
|
||||||
envlist = docs,linters,releasenotes,inventory
|
envlist = docs,linters,releasenotes
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
usedevelop = True
|
usedevelop = True
|
||||||
@ -100,6 +100,10 @@ commands =
|
|||||||
--list-tasks \
|
--list-tasks \
|
||||||
{toxinidir}/playbooks/*.yml"
|
{toxinidir}/playbooks/*.yml"
|
||||||
|
|
||||||
|
[testenv:inventory]
|
||||||
|
commands =
|
||||||
|
python {toxinidir}/tests/test_inventory.py
|
||||||
|
|
||||||
[testenv:linters]
|
[testenv:linters]
|
||||||
deps =
|
deps =
|
||||||
{[testenv:pep8]deps}
|
{[testenv:pep8]deps}
|
||||||
@ -113,8 +117,4 @@ commands =
|
|||||||
{[testenv:bashate]commands}
|
{[testenv:bashate]commands}
|
||||||
{[testenv:ansible-lint]commands}
|
{[testenv:ansible-lint]commands}
|
||||||
{[testenv:ansible-syntax]commands}
|
{[testenv:ansible-syntax]commands}
|
||||||
|
{[testenv:inventory]commands}
|
||||||
[testenv:inventory]
|
|
||||||
changedir = {toxinidir}/tests
|
|
||||||
commands =
|
|
||||||
python test_inventory.py
|
|
Loading…
x
Reference in New Issue
Block a user