From 005be05ec3a8938c687e7d119b6737819d56236a Mon Sep 17 00:00:00 2001 From: Eric Harney Date: Tue, 8 Oct 2024 16:32:20 +0000 Subject: [PATCH] Tests: Skip multiprocess test when using 1 cpu When only one cpu is present, the "backup_workers" option cannot be set to 2 because the maximum value of it is set to processutils.get_worker_count(). This is rare, so skip this test when only 1 cpu is present. Closes-Bug: #2083541 Change-Id: I83df179a032c1a60eee31eaac1bd4a0c9a4e307d --- cinder/tests/unit/test_cmd.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cinder/tests/unit/test_cmd.py b/cinder/tests/unit/test_cmd.py index 610d9d22e9c..4fee6ca00f1 100644 --- a/cinder/tests/unit/test_cmd.py +++ b/cinder/tests/unit/test_cmd.py @@ -22,6 +22,7 @@ from unittest import mock import ddt import fixtures import iso8601 +from oslo_concurrency import processutils from oslo_config import cfg from oslo_db import exception as oslo_exception from oslo_utils import timeutils @@ -128,6 +129,10 @@ class TestCinderBackupCmd(test.TestCase): @mock.patch('oslo_log.log.setup') def test_main_multiprocess(self, log_setup, monkey_patch, service_create, get_launcher, mock_semaphore): + if processutils.get_worker_count() < 2: + raise test.testtools.TestCase.skipException( + 'requires more than 1 cpu (to set backup_workers >1)') + CONF.set_override('backup_workers', 2) mock_semaphore.side_effect = [mock.sentinel.semaphore1, mock.sentinel.semaphore2]