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
This commit is contained in:
Eric Harney 2024-10-08 16:32:20 +00:00
parent 774d784aca
commit 005be05ec3

View File

@ -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]