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()
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,
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))
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.
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')