File tree Expand file tree Collapse file tree 5 files changed +93
-3
lines changed Expand file tree Collapse file tree 5 files changed +93
-3
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
+ )
Original file line number Diff line number Diff line change
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
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
+ )
Load Diff This file was deleted.
Original file line number Diff line number Diff line change
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
+ )
You can’t perform that action at this time.
0 commit comments