import sys
import tempfile
import json
-from util.rados import (rados, create_replicated_pool)
+from util.rados import (rados, create_replicated_pool, create_ec_pool)
# from util.rados import (rados, create_ec_pool,
# create_replicated_pool,
# create_cache_pool)
# def rados(ctx, remote, cmd, wait=True, check_status=False):
-def cod_setup(log, ctx, remote, NUM_OBJECTS, DATADIR, BASE_NAME, DATALINECOUNT, POOL, db):
+def cod_setup(log, ctx, remote, NUM_OBJECTS, DATADIR, BASE_NAME, DATALINECOUNT, POOL, db, ec):
ERRORS = 0
log.info("Creating {objs} objects in pool".format(objs=NUM_OBJECTS))
nullfd = open(os.devnull, "w")
ERRORS += 1
db[NAME]["xattr"][mykey] = myval
+ # Erasure coded pools don't support omap
+ if ec:
+ continue
+
# Create omap header in all objects but REPobject1
if i != 1:
myhdr = "hdr{i}".format(i=i)
# assert len(clients) > 0,
# 'ceph_objectstore_tool task needs at least 1 client'
- # EC_POOL = "ec_pool"
- # EC_NAME = "ECobject"
#ERRORS = 0
#DATADIR = os.path.join(TEUTHDIR, "data")
# Put a test dir below the data dir
create_replicated_pool(cli_remote, REP_POOL, PGNUM)
ERRORS += test_objectstore(ctx, config, cli_remote, REP_POOL, REP_NAME)
+ EC_POOL = "ec_pool"
+ EC_NAME = "ECobject"
+ create_ec_pool(cli_remote, EC_POOL, 'default', PGNUM)
+ ERRORS += test_objectstore(ctx, config, cli_remote, EC_POOL, EC_NAME, ec = True)
+
if ERRORS == 0:
log.info("TEST PASSED")
else:
log.info('Ending ceph_objectstore_tool')
-def test_objectstore(ctx, config, cli_remote, REP_POOL, REP_NAME):
+def test_objectstore(ctx, config, cli_remote, REP_POOL, REP_NAME, ec = False):
manager = ctx.manager
osds = ctx.cluster.only(teuthology.is_type('osd'))
for remote in allremote:
cod_setup_remote_data(log, ctx, remote, NUM_OBJECTS, DATADIR, REP_NAME, DATALINECOUNT)
- ERRORS += cod_setup(log, ctx, cli_remote, NUM_OBJECTS, DATADIR, REP_NAME, DATALINECOUNT, REP_POOL, db)
+ ERRORS += cod_setup(log, ctx, cli_remote, NUM_OBJECTS, DATADIR, REP_NAME, DATALINECOUNT, REP_POOL, db, ec)
pgs = {}
- jsontext = manager.raw_cluster_cmd('pg', 'dump_json')
- pgdump = json.loads(jsontext)
- PGS = [str(p["pgid"]) for p in pgdump["pg_stats"] if p["pgid"].find(str(REPID) + ".") == 0]
- for stats in pgdump["pg_stats"]:
- if stats["pgid"] in PGS:
+ for stats in manager.get_pg_stats():
+ if stats["pgid"].find(str(REPID) + ".") != 0:
+ continue
+ if pool_dump["type"] == ceph_manager.CephManager.REPLICATED_POOL:
for osd in stats["acting"]:
- if not pgs.has_key(osd):
- pgs[osd] = []
- pgs[osd].append(stats["pgid"])
-
+ pgs.setdefault(osd, []).append(stats["pgid"])
+ elif pool_dump["type"] == ceph_manager.CephManager.ERASURE_CODED_POOL:
+ shard = 0
+ for osd in stats["acting"]:
+ pgs.setdefault(osd, []).append("{pgid}s{shard}".format(pgid=stats["pgid"], shard=shard))
+ shard += 1
+ else:
+ raise Exception("{pool} has an unexpected type {type}".format(pool=REP_POOL, type=pool_dump["type"]))
log.info(pgs)
log.info(db)