Skip to content

Commit 26246c7

Browse files
authored
Merge pull request #128 from stackhpc/remove-symlinks
Remove symlinks for molecule tests
2 parents 433b7ca + 5540f7f commit 26246c7

File tree

5 files changed

+93
-3
lines changed

5 files changed

+93
-3
lines changed

molecule/kvm/tests

Lines changed: 0 additions & 1 deletion
This file was deleted.

molecule/kvm/tests/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""PyTest Fixtures."""
2+
from __future__ import absolute_import
3+
import os
4+
import pytest
5+
6+
7+
def pytest_runtest_setup(item):
8+
"""Run tests only when under molecule with testinfra installed."""
9+
try:
10+
import testinfra
11+
except ImportError:
12+
pytest.skip("Test requires testinfra", allow_module_level=True)
13+
if "MOLECULE_INVENTORY_FILE" in os.environ:
14+
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
15+
os.environ["MOLECULE_INVENTORY_FILE"]
16+
).get_hosts("all")
17+
else:
18+
pytest.skip(
19+
"Test should run only from inside molecule.", allow_module_level=True
20+
)

molecule/kvm/tests/test_default.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
"""Role testing files using testinfra."""
2+
3+
4+
def test_lvm_package_shall_be_installed(host):
5+
assert host.package("lvm2").is_installed
6+
7+
8+
def test_non_persistent_volume_group_is_created(host):
9+
command = """sudo vgdisplay | grep -c 'my_vg'"""
10+
cmd = host.run(command)
11+
assert "1" in cmd.stdout
12+
13+
14+
def test_mylv_logical_volume_is_created(host):
15+
command = """sudo lvs -o lv_name my_vg --separator='|' --noheadings \
16+
| grep -c 'my_lv'"""
17+
cmd = host.run(command)
18+
assert int(cmd.stdout.rstrip()) >= 1
19+
20+
21+
def test_mylv_logical_volume2_is_created(host):
22+
command = """sudo lvs -o lv_name my_vg --separator='|' --noheadings \
23+
| grep -c 'my_lw'"""
24+
cmd = host.run(command)
25+
assert int(cmd.stdout.rstrip()) >= 1
26+
27+
28+
def test_volume_is_mounted(host):
29+
host.file("/var/lib/mountpoint").mode == 0o731
30+
31+
32+
def test_volume2_is_mounted(host):
33+
host.file("/var/lib/mountpoint2").mode == 0o731

molecule/kvmonlyvg/tests/conftest.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

molecule/kvmonlyvg/tests/conftest.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""PyTest Fixtures."""
2+
from __future__ import absolute_import
3+
import os
4+
import pytest
5+
6+
7+
def pytest_runtest_setup(item):
8+
"""Run tests only when under molecule with testinfra installed."""
9+
try:
10+
import testinfra
11+
except ImportError:
12+
pytest.skip("Test requires testinfra", allow_module_level=True)
13+
if "MOLECULE_INVENTORY_FILE" in os.environ:
14+
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
15+
os.environ["MOLECULE_INVENTORY_FILE"]
16+
).get_hosts("all")
17+
else:
18+
pytest.skip(
19+
"Test should run only from inside molecule.", allow_module_level=True
20+
)

molecule/kvmsinglelv/tests/conftest.py

Lines changed: 0 additions & 1 deletion
This file was deleted.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""PyTest Fixtures."""
2+
from __future__ import absolute_import
3+
import os
4+
import pytest
5+
6+
7+
def pytest_runtest_setup(item):
8+
"""Run tests only when under molecule with testinfra installed."""
9+
try:
10+
import testinfra
11+
except ImportError:
12+
pytest.skip("Test requires testinfra", allow_module_level=True)
13+
if "MOLECULE_INVENTORY_FILE" in os.environ:
14+
pytest.testinfra_hosts = testinfra.utils.ansible_runner.AnsibleRunner(
15+
os.environ["MOLECULE_INVENTORY_FILE"]
16+
).get_hosts("all")
17+
else:
18+
pytest.skip(
19+
"Test should run only from inside molecule.", allow_module_level=True
20+
)

0 commit comments

Comments
 (0)