Skip to content

Commit 39c4631

Browse files
committed
Initial test that just starts and stops stratisd
Signed-off-by: mulhern <amulhern@redhat.com>
1 parent 9f81e22 commit 39c4631

4 files changed

Lines changed: 82 additions & 18 deletions

File tree

.github/workflows/support.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
pylint
4343
python3-dbus-client-gen
4444
python3-dbus-python-client-gen
45+
python3-hypothesis
4546
python3-justbytes
4647
python3-psutil
4748
python3-pyudev

tests-fmf/python.fmf

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require:
88
- python3-dbus
99
- python3-dbus-client-gen
1010
- python3-dbus-python-client-gen
11+
- python3-hypothesis
1112
- python3-psutil
1213
- python3-pyudev
1314
- python3-tenacity
@@ -19,22 +20,6 @@ environment:
1920
STRATIS_DUMPMETADATA: /usr/bin/stratis-dumpmetadata
2021
PYTHONPATH: ./src
2122

22-
/legacy:
23-
environment+:
24-
LEGACY_POOL: /usr/local/bin/stratis-legacy-pool
25-
26-
/legacy/udev:
27-
summary: Run Python udev tests
28-
test: make -f Makefile udev-tests
29-
30-
/legacy/loop:
31-
summary: Run Python tests that use loopbacked device framework
32-
test: make -f Makefile tang-tests dump-metadata-tests startup-tests
33-
3423
/v2/udev:
35-
summary: Run Python udev tests
36-
test: make -f Makefile udev-tests
37-
38-
/v2/loop:
39-
summary: Run Python tests that use loopbacked device framework
40-
test: make -f Makefile tang-tests dump-metadata-tests startup-tests
24+
summary: Run Python model tests
25+
test: make -f Makefile model-tests

tests/client-dbus/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,7 @@ filesystem-predict-tests:
3838
.PHONY: dump-metadata-tests
3939
dump-metadata-tests:
4040
python3 -m unittest ${UNITTEST_OPTS} tests.udev.test_dump
41+
42+
.PHONY: model-tests
43+
model-tests:
44+
python3 -m unittest ${UNITTEST_OPTS} tests.udev.test_hypothesis_stateful
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Copyright 2024 Red Hat, Inc.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
"""
15+
Use hypothesis stateful testing to test stratisd.
16+
"""
17+
18+
# isort: STDLIB
19+
from time import sleep
20+
21+
# isort: THIRDPARTY
22+
from hypothesis import HealthCheck, settings
23+
from hypothesis.stateful import RuleBasedStateMachine, precondition, rule
24+
25+
from ._utils import _Service, processes
26+
27+
28+
class StratisOrders(RuleBasedStateMachine):
29+
"""
30+
Rule based machine for doing testing.
31+
"""
32+
33+
def __init__(self): # pylint: disable=super-init-not-called
34+
"""
35+
Initialize.
36+
"""
37+
super().__init__()
38+
self.service = _Service()
39+
40+
@precondition(lambda self: next(processes("stratisd"), None) is not None)
41+
@rule()
42+
def start_stratisd(self):
43+
"""
44+
Start stratisd.
45+
"""
46+
sleep(5)
47+
self.service.start_service()
48+
49+
@precondition(lambda self: True)
50+
@rule()
51+
def stop_stratisd(self):
52+
"""
53+
Stop stratisd.
54+
"""
55+
sleep(5)
56+
self.service.stop_service()
57+
58+
@precondition(lambda self: True)
59+
@rule()
60+
def create_pool(self):
61+
"""
62+
Create a pool.
63+
"""
64+
65+
@precondition(lambda self: True)
66+
@rule()
67+
def destroy_pool(self):
68+
"""
69+
Destroy a pool.
70+
"""
71+
72+
73+
StratisOrders.TestCase.settings = settings(suppress_health_check=[HealthCheck.too_slow])
74+
TestStratis = StratisOrders.TestCase

0 commit comments

Comments
 (0)