From dd6a291cf01a211eb50701c84f88a74f3fee5282 Mon Sep 17 00:00:00 2001 From: Dennis Maisenbacher Date: Tue, 15 Oct 2024 13:04:33 +0000 Subject: [PATCH] tests: Fixup nvme_create_max_ns_test Fix off by one errors and capacity allocation. Small speedup for nvme_create_max_ns_test by reducing the io done by `run_ns_io`. For this we introduce a new count parameter which can overwrite the default value of 10. Signed-off-by: Dennis Maisenbacher --- tests/nvme_create_max_ns_test.py | 13 +++++++++---- tests/nvme_test.py | 6 +++--- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/tests/nvme_create_max_ns_test.py b/tests/nvme_create_max_ns_test.py index bda93e19..76cd4d4a 100644 --- a/tests/nvme_create_max_ns_test.py +++ b/tests/nvme_create_max_ns_test.py @@ -54,6 +54,10 @@ class TestNVMeCreateMaxNS(TestNVMe): self.flbas = 0 self.nsze = int(self.get_ncap() / self.get_format() / self.get_max_ns()) + # Make sure that we have enough capacity for each ns. + # Creating a ns might allocate more bits (NVMCAP) than specified by + # nsze and ncap. + self.nsze = int(self.nsze / 2) self.ncap = self.nsze self.setup_log_dir(self.__class__.__name__) self.max_ns = self.get_max_ns() @@ -75,11 +79,12 @@ class TestNVMeCreateMaxNS(TestNVMe): self.flbas, self.dps), 0) self.attach_ns(self.ctrl_id, self.default_nsid) - super.tearDown() + super().tearDown() def test_attach_detach_ns(self): """ Testcase main """ - for nsid in range(1, self.max_ns): + print(f"##### Testing max_ns: {self.max_ns}") + for nsid in range(1, self.max_ns + 1): print("##### Creating " + str(nsid)) err = self.create_and_validate_ns(nsid, self.nsze, @@ -90,9 +95,9 @@ class TestNVMeCreateMaxNS(TestNVMe): print("##### Attaching " + str(nsid)) self.assertEqual(self.attach_ns(self.ctrl_id, nsid), 0) print("##### Running IOs in " + str(nsid)) - self.run_ns_io(nsid, 0) + self.run_ns_io(nsid, 9, 1) - for nsid in range(1, self.max_ns): + for nsid in range(1, self.max_ns + 1): print("##### Detaching " + str(nsid)) self.assertEqual(self.detach_ns(self.ctrl_id, nsid), 0) print("#### Deleting " + str(nsid)) diff --git a/tests/nvme_test.py b/tests/nvme_test.py index 235c855a..b248c688 100644 --- a/tests/nvme_test.py +++ b/tests/nvme_test.py @@ -500,7 +500,7 @@ class TestNVMe(unittest.TestCase): return 0 if err_log_entry_count == entry_count else 1 - def run_ns_io(self, nsid, lbads): + def run_ns_io(self, nsid, lbads, count=10): """ Wrapper to run ios on namespace under test. - Args: - lbads : LBA Data size supported in power of 2 format. @@ -510,14 +510,14 @@ class TestNVMe(unittest.TestCase): block_size = mmap.PAGESIZE if int(lbads) < 9 else 2 ** int(lbads) ns_path = self.ctrl + "n" + str(nsid) io_cmd = "dd if=" + ns_path + " of=/dev/null" + " bs=" + \ - str(block_size) + " count=10 > /dev/null 2>&1" + str(block_size) + " count=" + str(count) + " > /dev/null 2>&1" print(io_cmd) run_io = subprocess.Popen(io_cmd, shell=True, stdout=subprocess.PIPE, encoding='utf-8') run_io_result = run_io.communicate()[1] self.assertEqual(run_io_result, None) io_cmd = "dd if=/dev/zero of=" + ns_path + " bs=" + \ - str(block_size) + " count=10 > /dev/null 2>&1" + str(block_size) + " count=" + str(count) + " > /dev/null 2>&1" print(io_cmd) run_io = subprocess.Popen(io_cmd, shell=True, stdout=subprocess.PIPE, encoding='utf-8') -- 2.50.1