mirror of
https://github.com/ceph/ceph
synced 2025-03-22 18:27:10 +00:00
qa/dashboard: fix test_list_enabled_module failure
Check the ports availability and go for a new port if the current one is
not available
Fixes: https://tracker.ceph.com/issues/62972
Signed-off-by: Nizamudeen A <nia@redhat.com>
(cherry picked from commit a2a4a3415c
)
This commit is contained in:
parent
c0955dc2ad
commit
5cc7fc6806
@ -4,6 +4,7 @@ from __future__ import absolute_import
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
from urllib3.exceptions import MaxRetryError
|
||||||
|
|
||||||
from .helper import (DashboardTestCase, JLeaf, JList, JObj,
|
from .helper import (DashboardTestCase, JLeaf, JList, JObj,
|
||||||
module_options_object_schema, module_options_schema,
|
module_options_object_schema, module_options_schema,
|
||||||
@ -24,10 +25,11 @@ class MgrModuleTestCase(DashboardTestCase):
|
|||||||
def _check_connection():
|
def _check_connection():
|
||||||
try:
|
try:
|
||||||
# Try reaching an API endpoint successfully.
|
# Try reaching an API endpoint successfully.
|
||||||
|
logger.info('Trying to reach the REST API endpoint')
|
||||||
self._get('/api/mgr/module')
|
self._get('/api/mgr/module')
|
||||||
if self._resp.status_code == 200:
|
if self._resp.status_code == 200:
|
||||||
return True
|
return True
|
||||||
except requests.ConnectionError:
|
except (MaxRetryError, requests.ConnectionError):
|
||||||
pass
|
pass
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
|
import socket
|
||||||
|
|
||||||
from unittest import SkipTest
|
from unittest import SkipTest
|
||||||
|
|
||||||
@ -209,15 +210,22 @@ class MgrTestCase(CephTestCase):
|
|||||||
"""
|
"""
|
||||||
# Start handing out ports well above Ceph's range.
|
# Start handing out ports well above Ceph's range.
|
||||||
assign_port = min_port
|
assign_port = min_port
|
||||||
|
ip_addr = cls.mgr_cluster.get_mgr_map()['active_addr'].split(':')[0]
|
||||||
|
|
||||||
for mgr_id in cls.mgr_cluster.mgr_ids:
|
for mgr_id in cls.mgr_cluster.mgr_ids:
|
||||||
cls.mgr_cluster.mgr_stop(mgr_id)
|
cls.mgr_cluster.mgr_stop(mgr_id)
|
||||||
cls.mgr_cluster.mgr_fail(mgr_id)
|
cls.mgr_cluster.mgr_fail(mgr_id)
|
||||||
|
|
||||||
|
|
||||||
for mgr_id in cls.mgr_cluster.mgr_ids:
|
for mgr_id in cls.mgr_cluster.mgr_ids:
|
||||||
log.debug("Using port {0} for {1} on mgr.{2}".format(
|
# Find a port that isn't in use
|
||||||
assign_port, module_name, mgr_id
|
while True:
|
||||||
))
|
if not cls.is_port_in_use(ip_addr, assign_port):
|
||||||
|
break
|
||||||
|
log.debug(f"Port {assign_port} in use, trying next")
|
||||||
|
assign_port += 1
|
||||||
|
|
||||||
|
log.debug(f"Using port {assign_port} for {module_name} on mgr.{mgr_id}")
|
||||||
cls.mgr_cluster.set_module_localized_conf(module_name, mgr_id,
|
cls.mgr_cluster.set_module_localized_conf(module_name, mgr_id,
|
||||||
config_name,
|
config_name,
|
||||||
str(assign_port),
|
str(assign_port),
|
||||||
@ -235,3 +243,8 @@ class MgrTestCase(CephTestCase):
|
|||||||
mgr_map['active_name'], mgr_map['active_gid']))
|
mgr_map['active_name'], mgr_map['active_gid']))
|
||||||
return done
|
return done
|
||||||
cls.wait_until_true(is_available, timeout=30)
|
cls.wait_until_true(is_available, timeout=30)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def is_port_in_use(cls, ip_addr: str, port: int) -> bool:
|
||||||
|
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
|
||||||
|
return s.connect_ex((ip_addr, port)) == 0
|
||||||
|
@ -134,7 +134,7 @@ run_teuthology_tests() {
|
|||||||
export CEPH_OUT_CLIENT_DIR=${LOCAL_BUILD_DIR}/out/client
|
export CEPH_OUT_CLIENT_DIR=${LOCAL_BUILD_DIR}/out/client
|
||||||
find . -iname "*${COVERAGE_FILE}*" -type f -delete
|
find . -iname "*${COVERAGE_FILE}*" -type f -delete
|
||||||
|
|
||||||
python ../qa/tasks/vstart_runner.py --ignore-missing-binaries --no-verbose $OPTIONS $(echo $TEST_CASES) ||
|
python ../qa/tasks/vstart_runner.py --ignore-missing-binaries --no-verbose --debug $OPTIONS $(echo $TEST_CASES) ||
|
||||||
on_tests_error
|
on_tests_error
|
||||||
|
|
||||||
deactivate
|
deactivate
|
||||||
|
Loading…
Reference in New Issue
Block a user