Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial test that does nothing #3686

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/support.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ jobs:
pylint
python3-dbus-client-gen
python3-dbus-python-client-gen
python3-hypothesis
python3-justbytes
python3-psutil
python3-pyudev
Expand Down
21 changes: 3 additions & 18 deletions tests-fmf/python.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require:
- python3-dbus
- python3-dbus-client-gen
- python3-dbus-python-client-gen
- python3-hypothesis
- python3-psutil
- python3-pyudev
- python3-tenacity
Expand All @@ -19,22 +20,6 @@ environment:
STRATIS_DUMPMETADATA: /usr/bin/stratis-dumpmetadata
PYTHONPATH: ./src

/legacy:
environment+:
LEGACY_POOL: /usr/local/bin/stratis-legacy-pool

/legacy/udev:
summary: Run Python udev tests
test: make -f Makefile udev-tests

/legacy/loop:
summary: Run Python tests that use loopbacked device framework
test: make -f Makefile tang-tests dump-metadata-tests startup-tests

/v2/udev:
summary: Run Python udev tests
test: make -f Makefile udev-tests

/v2/loop:
summary: Run Python tests that use loopbacked device framework
test: make -f Makefile tang-tests dump-metadata-tests startup-tests
summary: Run Python model tests
test: make -f Makefile model-tests
4 changes: 4 additions & 0 deletions tests/client-dbus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,7 @@ filesystem-predict-tests:
.PHONY: dump-metadata-tests
dump-metadata-tests:
python3 -m unittest ${UNITTEST_OPTS} tests.udev.test_dump

.PHONY: model-tests
model-tests:
python3 -m unittest ${UNITTEST_OPTS} tests.udev.test_hypothesis_stateful
74 changes: 74 additions & 0 deletions tests/client-dbus/tests/udev/test_hypothesis_stateful.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Copyright 2024 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Use hypothesis stateful testing to test stratisd.
"""

# isort: STDLIB
from time import sleep

# isort: THIRDPARTY
from hypothesis import HealthCheck, settings
from hypothesis.stateful import RuleBasedStateMachine, precondition, rule

from ._utils import _Service, processes


class StratisOrders(RuleBasedStateMachine):
"""
Rule based machine for doing testing.
"""

def __init__(self): # pylint: disable=super-init-not-called
"""
Initialize.
"""
super().__init__()
self.service = _Service()

@precondition(lambda self: next(processes("stratisd"), None) is not None)
@rule()
def start_stratisd(self):
"""
Start stratisd.
"""
sleep(5)
self.service.start_service()

@precondition(lambda self: True)
@rule()
def stop_stratisd(self):
"""
Stop stratisd.
"""
sleep(5)
self.service.stop_service()

@precondition(lambda self: True)
@rule()
def create_pool(self):
"""
Create a pool.
"""

@precondition(lambda self: True)
@rule()
def destroy_pool(self):
"""
Destroy a pool.
"""


StratisOrders.TestCase.settings = settings(suppress_health_check=[HealthCheck.too_slow])
TestStratis = StratisOrders.TestCase