class TestCommand(object): def setUp(self): self.rados = Rados(conffile="") self.rados.connect() def tearDown(self): self.rados.shutdown() def test_monmap_dump(self): # check for success and some plain output with epoch in it cmd = {"prefix": "mon dump"} ret, buf, errs = self.rados.mon_command(json.dumps(cmd), "", timeout=30) eq(ret, 0) assert len(buf) > 0 assert "epoch" in buf # JSON, and grab current epoch cmd["format"] = "json" ret, buf, errs = self.rados.mon_command(json.dumps(cmd), "", timeout=30) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert "epoch" in d epoch = d["epoch"] # assume epoch + 1000 does not exist; test for ENOENT cmd["epoch"] = epoch + 1000 ret, buf, errs = self.rados.mon_command(json.dumps(cmd), "", timeout=30) eq(ret, -errno.ENOENT) eq(len(buf), 0) del cmd["epoch"] # send to specific target by name target = d["mons"][0]["name"] print target ret, buf, errs = self.rados.mon_command(json.dumps(cmd), "", timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert "epoch" in d # and by rank target = d["mons"][0]["rank"] print target ret, buf, errs = self.rados.mon_command(json.dumps(cmd), "", timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert "epoch" in d def test_osd_bench(self): cmd = dict(prefix="bench", size=4096, count=8192) ret, buf, err = self.rados.osd_command(0, json.dumps(cmd), "", timeout=30) eq(ret, 0) assert len(err) > 0 out = json.loads(err) eq(out["blocksize"], cmd["size"]) eq(out["bytes_written"], cmd["count"])
class TestCommand(object): def setUp(self): self.rados = Rados(conffile='') self.rados.connect() def tearDown(self): self.rados.shutdown() def test_monmap_dump(self): # check for success and some plain output with epoch in it cmd = {"prefix": "mon dump"} ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30) eq(ret, 0) assert len(buf) > 0 assert (b'epoch' in buf) # JSON, and grab current epoch cmd['format'] = 'json' ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf.decode("utf-8")) assert ('epoch' in d) epoch = d['epoch'] # assume epoch + 1000 does not exist; test for ENOENT cmd['epoch'] = epoch + 1000 ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30) eq(ret, -errno.ENOENT) eq(len(buf), 0) del cmd['epoch'] # send to specific target by name target = d['mons'][0]['name'] print(target) ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf.decode("utf-8")) assert ('epoch' in d) # and by rank target = d['mons'][0]['rank'] print(target) ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf.decode("utf-8")) assert ('epoch' in d) def test_osd_bench(self): cmd = dict(prefix='bench', size=4096, count=8192) ret, buf, err = self.rados.osd_command(0, json.dumps(cmd), b'', timeout=30) eq(ret, 0) assert len(err) > 0 out = json.loads(err) eq(out['blocksize'], cmd['size']) eq(out['bytes_written'], cmd['count']) def test_ceph_osd_pool_create_utf8(self): if _python2: # Use encoded bytestring poolname = b"\351\273\205" else: poolname = "\u9ec5" cmd = {"prefix": "osd pool create", "pg_num": 16, "pool": poolname} ret, buf, out = self.rados.mon_command(json.dumps(cmd), b'') eq(ret, 0) assert len(out) > 0 eq(u"pool '\u9ec5' created", out)
class TestCommand(object): def setUp(self): self.rados = Rados(conffile='') self.rados.connect() def tearDown(self): self.rados.shutdown() def test_monmap_dump(self): # check for success and some plain output with epoch in it cmd = {"prefix":"mon dump"} ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30) eq(ret, 0) assert len(buf) > 0 assert(b'epoch' in buf) # JSON, and grab current epoch cmd['format'] = 'json' ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf.decode("utf-8")) assert('epoch' in d) epoch = d['epoch'] # assume epoch + 1000 does not exist; test for ENOENT cmd['epoch'] = epoch + 1000 ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30) eq(ret, -errno.ENOENT) eq(len(buf), 0) del cmd['epoch'] # send to specific target by name target = d['mons'][0]['name'] print(target) ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf.decode("utf-8")) assert('epoch' in d) # and by rank target = d['mons'][0]['rank'] print(target) ret, buf, errs = self.rados.mon_command(json.dumps(cmd), b'', timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf.decode("utf-8")) assert('epoch' in d) def test_osd_bench(self): cmd = dict(prefix='bench', size=4096, count=8192) ret, buf, err = self.rados.osd_command(0, json.dumps(cmd), b'', timeout=30) eq(ret, 0) assert len(err) > 0 out = json.loads(err) eq(out['blocksize'], cmd['size']) eq(out['bytes_written'], cmd['count']) def test_ceph_osd_pool_create_utf8(self): if _python2: # Use encoded bytestring poolname = b"\351\273\205" else: poolname = "\u9ec5" cmd = {"prefix": "osd pool create", "pg_num": 16, "pool": poolname} ret, buf, out = self.rados.mon_command(json.dumps(cmd), b'') eq(ret, 0) assert len(out) > 0 eq(u"pool '\u9ec5' created", out)
class TestCommand(object): def setUp(self): self.rados = Rados(conffile='') self.rados.connect() def tearDown(self): self.rados.shutdown() def test_monmap_dump(self): # check for success and some plain output with epoch in it cmd = {"prefix": "mon dump"} ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30) eq(ret, 0) assert len(buf) > 0 assert ('epoch' in buf) # JSON, and grab current epoch cmd['format'] = 'json' ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert ('epoch' in d) epoch = d['epoch'] # assume epoch + 1000 does not exist; test for ENOENT cmd['epoch'] = epoch + 1000 ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30) eq(ret, -errno.ENOENT) eq(len(buf), 0) del cmd['epoch'] # send to specific target by name target = d['mons'][0]['name'] print target ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert ('epoch' in d) # and by rank target = d['mons'][0]['rank'] print target ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert ('epoch' in d) def test_osd_bench(self): cmd = dict(prefix='bench', size=4096, count=8192) ret, buf, err = self.rados.osd_command(0, json.dumps(cmd), '', timeout=30) eq(ret, 0) assert len(err) > 0 out = json.loads(err) eq(out['blocksize'], cmd['size']) eq(out['bytes_written'], cmd['count'])
class TestCommand(object): def setUp(self): self.rados = Rados(conffile='') self.rados.connect() def tearDown(self): self.rados.shutdown() def test_monmap_dump(self): # check for success and some plain output with epoch in it cmd = {"prefix":"mon dump"} ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30) eq(ret, 0) assert len(buf) > 0 assert('epoch' in buf) # JSON, and grab current epoch cmd['format'] = 'json' ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert('epoch' in d) epoch = d['epoch'] # assume epoch + 1000 does not exist; test for ENOENT cmd['epoch'] = epoch + 1000 ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30) eq(ret, -errno.ENOENT) eq(len(buf), 0) del cmd['epoch'] # send to specific target by name target = d['mons'][0]['name'] print target ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert('epoch' in d) # and by rank target = d['mons'][0]['rank'] print target ret, buf, errs = self.rados.mon_command(json.dumps(cmd), '', timeout=30, target=target) eq(ret, 0) assert len(buf) > 0 d = json.loads(buf) assert('epoch' in d) def test_osd_bench(self): cmd = dict(prefix='bench', size=4096, count=8192) ret, buf, err = self.rados.osd_command(0, json.dumps(cmd), '', timeout=30) eq(ret, 0) assert len(err) > 0 out = json.loads(err) eq(out['blocksize'], cmd['size']) eq(out['bytes_written'], cmd['count'])