From 389020e14594e4894e28d1eb9103c210b142509e Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Thu, 23 May 2024 18:45:13 +0200 Subject: Adding upstream version 18.2.3. Signed-off-by: Daniel Baumann --- src/test/pybind/test_cephfs.py | 33 +++++++++++++++++++++++++++++++++ src/test/pybind/test_rbd.py | 24 +++++++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) (limited to 'src/test/pybind') diff --git a/src/test/pybind/test_cephfs.py b/src/test/pybind/test_cephfs.py index d16807de9..247ddca37 100644 --- a/src/test/pybind/test_cephfs.py +++ b/src/test/pybind/test_cephfs.py @@ -10,6 +10,7 @@ import random import time import stat import uuid +import json from datetime import datetime cephfs = None @@ -907,3 +908,35 @@ def test_snapdiff(testdir): # remove directory purge_dir(b"/snapdiff_test"); + +def test_single_target_command(): + command = {'prefix': u'session ls', 'format': 'json'} + mds_spec = "a" + inbuf = b'' + ret, outbl, outs = cephfs.mds_command(mds_spec, json.dumps(command), inbuf) + if outbl: + session_map = json.loads(outbl) + # Standby MDSs will return -38 + assert(ret == 0 or ret == -38) + +def test_multi_target_command(): + mds_get_command = {'prefix': 'status', 'format': 'json'} + inbuf = b'' + ret, outbl, outs = cephfs.mds_command('*', json.dumps(mds_get_command), inbuf) + print(outbl) + mds_status = json.loads(outbl) + print(mds_status) + + command = {'prefix': u'session ls', 'format': 'json'} + mds_spec = "*" + inbuf = b'' + + ret, outbl, outs = cephfs.mds_command(mds_spec, json.dumps(command), inbuf) + # Standby MDSs will return -38 + assert(ret == 0 or ret == -38) + print(outbl) + session_map = json.loads(outbl) + + if isinstance(mds_status, list): # if multi target command result + for mds_sessions in session_map: + assert(list(mds_sessions.keys())[0].startswith('mds.')) diff --git a/src/test/pybind/test_rbd.py b/src/test/pybind/test_rbd.py index 7b5f31b57..df47b0d29 100644 --- a/src/test/pybind/test_rbd.py +++ b/src/test/pybind/test_rbd.py @@ -415,6 +415,18 @@ def test_remove_canceled(tmp_image): assert_raises(OperationCanceled, RBD().remove, ioctx, image_name, on_progress=progress_cb) +def test_remove_with_progress_except(): + create_image() + d = {'received_callback': False} + def progress_cb(current, total): + d['received_callback'] = True + raise Exception() + + # exception is logged and ignored with a Cython warning: + # Exception ignored in: 'rbd.progress_callback' + RBD().remove(ioctx, image_name, on_progress=progress_cb) + eq(True, d['received_callback']) + def test_rename(tmp_image): rbd = RBD() image_name2 = get_temp_image_name() @@ -1251,6 +1263,16 @@ class TestImage(object): assert(comp.get_return_value() < 0) eq(sys.getrefcount(comp), 2) + # test3: except case + def cbex(_, buf): + raise KeyError() + + def test3(): + comp = self.image.aio_read(IMG_SIZE, 20, cbex) + comp.wait_for_complete_and_cb() + + assert_raises(KeyError, test3) + def test_aio_write(self): retval = [None] def cb(comp): @@ -1449,7 +1471,7 @@ def check_diff(image, offset, length, from_snapshot, expected): extents = [] def cb(offset, length, exists): extents.append((offset, length, exists)) - image.diff_iterate(0, IMG_SIZE, None, cb) + image.diff_iterate(0, IMG_SIZE, from_snapshot, cb) eq(extents, expected) class TestClone(object): -- cgit v1.2.3