Skip to content

Commit 9d79a06

Browse files
authored
Merge pull request ceph#60511 from rhcs-dashboard/health-test-fix
qa/dashboard: fix tasks.mgr.dashboard.test_health.HealthTest Reviewed-by: Ernesto Puerta <[email protected]>
2 parents 47e9c85 + a2a4a34 commit 9d79a06

File tree

4 files changed

+21
-8
lines changed

4 files changed

+21
-8
lines changed

qa/tasks/mgr/dashboard/helper.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,13 +220,11 @@ def setUpClass(cls):
220220

221221
# To avoid any issues with e.g. unlink bugs, we destroy and recreate
222222
# the filesystem rather than just doing a rm -rf of files
223-
cls.mds_cluster.mds_stop()
224-
cls.mds_cluster.mds_fail()
225223
cls.mds_cluster.delete_all_filesystems()
224+
cls.mds_cluster.mds_restart() # to reset any run-time configs, etc.
226225
cls.fs = None # is now invalid!
227226

228227
cls.fs = cls.mds_cluster.newfs(create=True)
229-
cls.fs.mds_restart()
230228

231229
# In case some test messed with auth caps, reset them
232230
# pylint: disable=not-an-iterable

qa/tasks/mgr/dashboard/test_mgr_module.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import logging
55

66
import requests
7+
from urllib3.exceptions import MaxRetryError
78

89
from .helper import (DashboardTestCase, JLeaf, JList, JObj,
910
module_options_object_schema, module_options_schema,
@@ -24,10 +25,11 @@ def wait_until_rest_api_accessible(self):
2425
def _check_connection():
2526
try:
2627
# Try reaching an API endpoint successfully.
28+
logger.info('Trying to reach the REST API endpoint')
2729
self._get('/api/mgr/module')
2830
if self._resp.status_code == 200:
2931
return True
30-
except requests.ConnectionError:
32+
except (MaxRetryError, requests.ConnectionError):
3133
pass
3234
return False
3335

qa/tasks/mgr/mgr_test_case.py

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import logging
3+
import socket
34

45
from unittest import SkipTest
56

@@ -229,15 +230,22 @@ def _assign_ports(cls, module_name, config_name, min_port=7789):
229230
"""
230231
# Start handing out ports well above Ceph's range.
231232
assign_port = min_port
233+
ip_addr = cls.mgr_cluster.get_mgr_map()['active_addr'].split(':')[0]
232234

233235
for mgr_id in cls.mgr_cluster.mgr_ids:
234236
cls.mgr_cluster.mgr_stop(mgr_id)
235237
cls.mgr_cluster.mgr_fail(mgr_id)
236238

239+
237240
for mgr_id in cls.mgr_cluster.mgr_ids:
238-
log.debug("Using port {0} for {1} on mgr.{2}".format(
239-
assign_port, module_name, mgr_id
240-
))
241+
# Find a port that isn't in use
242+
while True:
243+
if not cls.is_port_in_use(ip_addr, assign_port):
244+
break
245+
log.debug(f"Port {assign_port} in use, trying next")
246+
assign_port += 1
247+
248+
log.debug(f"Using port {assign_port} for {module_name} on mgr.{mgr_id}")
241249
cls.mgr_cluster.set_module_localized_conf(module_name, mgr_id,
242250
config_name,
243251
str(assign_port),
@@ -255,3 +263,8 @@ def is_available():
255263
mgr_map['active_name'], mgr_map['active_gid']))
256264
return done
257265
cls.wait_until_true(is_available, timeout=30)
266+
267+
@classmethod
268+
def is_port_in_use(cls, ip_addr: str, port: int) -> bool:
269+
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
270+
return s.connect_ex((ip_addr, port)) == 0

src/pybind/mgr/dashboard/run-backend-api-tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ run_teuthology_tests() {
134134
export CEPH_OUT_CLIENT_DIR=${LOCAL_BUILD_DIR}/out/client
135135
find . -iname "*${COVERAGE_FILE}*" -type f -delete
136136

137-
python ../qa/tasks/vstart_runner.py --ignore-missing-binaries --no-verbose $OPTIONS $(echo $TEST_CASES) ||
137+
python ../qa/tasks/vstart_runner.py --ignore-missing-binaries --no-verbose --debug $OPTIONS $(echo $TEST_CASES) ||
138138
on_tests_error
139139

140140
deactivate

0 commit comments

Comments
 (0)