Skip to content

Commit

Permalink
Merge pull request #3653 from mulkieran/readd-startup
Browse files Browse the repository at this point in the history
Re-add startup tests but run in the TMT framework
  • Loading branch information
mulkieran authored Jul 29, 2024
2 parents 56c5b38 + ba23a31 commit d106ba6
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 47 deletions.
4 changes: 2 additions & 2 deletions tests-fmf/python.fmf
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ environment:

/legacy/loop:
summary: Run Python tests that use loopbacked device framework
test: make -f Makefile tang-tests dump-metadata-tests
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
test: make -f Makefile tang-tests dump-metadata-tests startup-tests
4 changes: 2 additions & 2 deletions tests/client-dbus/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ lint:
pylint src/stratisd_client_dbus --ignore=_introspect.py
pylint tests --disable=R0801

.PHONY: misc-tests
.PHONY: startup-tests
startup-tests:
python3 -m unittest ${UNITTEST_OPTS} tests.misc.test_startup
python3 -m unittest ${UNITTEST_OPTS} tests.udev.test_startup

.PHONY: fmt
fmt:
Expand Down
43 changes: 0 additions & 43 deletions tests/client-dbus/README.rst

This file was deleted.

1 change: 1 addition & 0 deletions tests/client-dbus/tests/udev/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
from ._loopback import LoopBackDevices

_STRATISD = os.environ["STRATISD"]
STRATISD = _STRATISD
_LEGACY_POOL = os.environ.get("LEGACY_POOL")

CRYPTO_LUKS_FS_TYPE = "crypto_LUKS"
Expand Down
58 changes: 58 additions & 0 deletions tests/client-dbus/tests/udev/test_startup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright 2021 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.

"""
Test starting additional stratisd processes.
"""

# isort: STDLIB
import os
import subprocess
import time

from ._utils import STRATISD, ServiceContextManager, UdevTest


class TestStarting(UdevTest):
"""
Test starting stratisd when an instance of stratisd is already running.
"""

def test_unique_instance(self):
"""
Verify that a second stratisd instance can not be started.
"""
with ServiceContextManager():
stratisd_lock_file = "/run/stratisd.pid"

for _ in range(5):
if os.path.exists(stratisd_lock_file):
break
time.sleep(1)
else:
raise RuntimeError(
f"Lock file {stratisd_lock_file} does not seem to exist."
)

env = dict(os.environ)
env["RUST_LOG"] = env.get("RUST_LOG", "") + ",nix::fcntl=debug"
with subprocess.Popen(
[STRATISD],
stderr=subprocess.STDOUT,
text=True,
close_fds=True,
env=env,
) as process:
(_, _) = process.communicate()
self.assertEqual(process.returncode, 1)

0 comments on commit d106ba6

Please sign in to comment.