stderr=subprocess.DEVNULL,
shell=True)
assert(ret == 0)
+
+ # Minimum test of --dry-run by using it, but not checking anything
+ cmd = CFSD_PREFIX + "--op set-osdmap --file {osdmap_file} --epoch {epoch} --force --dry-run"
+ cmd = cmd.format(osd=osd_path, osdmap_file=osdmap_file.name, epoch=epoch)
+ ret = call(cmd, stdout=subprocess.DEVNULL, shell=True)
+ assert(ret == 0)
+
# osdmaptool increases the epoch of the changed osdmap, so we need to force the tool
# to use use a different epoch than the one in osdmap
cmd = CFSD_PREFIX + "--op set-osdmap --file {osdmap_file} --epoch {epoch} --force"
cmd = CFSD_PREFIX + "--op set-inc-osdmap --force --epoch {epoch} --file {file}"
ret = call(cmd.format(osd=osd_path, epoch=epoch, file=file_e2.name), shell=True)
if ret: return 1
+ # Use dry-run to set back to e1 which shouldn't happen
+ cmd = CFSD_PREFIX + "--op set-inc-osdmap --dry-run --epoch {epoch} --file {file}"
+ ret = call(cmd.format(osd=osd_path, epoch=epoch, file=file_e1_backup.name), shell=True)
+ if ret: return 1
# read from e1
file_e1_read = tempfile.NamedTemporaryFile(delete=False)
cmd = CFSD_PREFIX + "--op get-inc-osdmap --epoch {epoch} --file {file}"
cmd = ("echo -n foobar | " + CFSD_PREFIX + " --pgid {pg} '{json}' set-attr {key}").format(osd=osd, pg=pg, json=JSON, key=attrkey)
logging.debug(cmd)
ret = call(cmd, shell=True)
+ if ret != 0:
+ logging.error("Bad exit status {ret} from set-attr".format(ret=ret))
+ ERRORS += 1
+ continue
+ # Test set-attr with dry-run
+ cmd = ("echo -n dryrunbroken | " + CFSD_PREFIX + "--dry-run '{json}' set-attr {key}").format(osd=osd, pg=pg, json=JSON, key=attrkey)
+ logging.debug(cmd)
+ ret = call(cmd, shell=True, stdout=nullfd)
if ret != 0:
logging.error("Bad exit status {ret} from set-attr".format(ret=ret))
ERRORS += 1
cmd = (CFSD_PREFIX + "'{json}' rm-attr {key}").format(osd=osd, pg=pg, json=JSON, key=attrkey)
logging.debug(cmd)
ret = call(cmd, shell=True)
+ if ret != 0:
+ logging.error("Bad exit status {ret} from rm-attr".format(ret=ret))
+ ERRORS += 1
+ continue
+ # Check rm-attr with dry-run
+ cmd = (CFSD_PREFIX + "--dry-run '{json}' rm-attr {key}").format(osd=osd, pg=pg, json=JSON, key=attrkey)
+ logging.debug(cmd)
+ ret = call(cmd, shell=True, stdout=nullfd)
if ret != 0:
logging.error("Bad exit status {ret} from rm-attr".format(ret=ret))
ERRORS += 1
logging.error("Check of set-omaphdr failed because we got {val}".format(val=getval))
ERRORS += 1
continue
+ # Test dry-run with set-omaphdr
+ cmd = ("echo -n dryrunbroken | " + CFSD_PREFIX + "--dry-run '{json}' set-omaphdr").format(osd=osd, pg=pg, json=JSON)
+ logging.debug(cmd)
+ ret = call(cmd, shell=True, stdout=nullfd)
+ if ret != 0:
+ logging.error("Bad exit status {ret} from set-omaphdr".format(ret=ret))
+ ERRORS += 1
+ continue
# Put back value
cmd = ("echo -n {val} | " + CFSD_PREFIX + "'{json}' set-omaphdr").format(osd=osd, pg=pg, json=JSON, val=hdr)
logging.debug(cmd)
cmd = ("echo -n foobar | " + CFSD_PREFIX + " --pgid {pg} '{json}' set-omap {key}").format(osd=osd, pg=pg, json=JSON, key=omapkey)
logging.debug(cmd)
ret = call(cmd, shell=True)
+ if ret != 0:
+ logging.error("Bad exit status {ret} from set-omap".format(ret=ret))
+ ERRORS += 1
+ continue
+ # Check set-omap with dry-run
+ cmd = ("echo -n dryrunbroken | " + CFSD_PREFIX + "--dry-run --pgid {pg} '{json}' set-omap {key}").format(osd=osd, pg=pg, json=JSON, key=omapkey)
+ logging.debug(cmd)
+ ret = call(cmd, shell=True, stdout=nullfd)
if ret != 0:
logging.error("Bad exit status {ret} from set-omap".format(ret=ret))
ERRORS += 1
cmd = (CFSD_PREFIX + "'{json}' rm-omap {key}").format(osd=osd, pg=pg, json=JSON, key=omapkey)
logging.debug(cmd)
ret = call(cmd, shell=True)
+ if ret != 0:
+ logging.error("Bad exit status {ret} from rm-omap".format(ret=ret))
+ ERRORS += 1
+ # Check rm-omap with dry-run
+ cmd = (CFSD_PREFIX + "--dry-run '{json}' rm-omap {key}").format(osd=osd, pg=pg, json=JSON, key=omapkey)
+ logging.debug(cmd)
+ ret = call(cmd, shell=True, stdout=nullfd)
if ret != 0:
logging.error("Bad exit status {ret} from rm-omap".format(ret=ret))
ERRORS += 1
}
cout << "Creating a new epoch." << std::endl;
}
+ if (dry_run)
+ return 0;
ObjectStore::Transaction t;
t.write(META_COLL, inc_oid, 0, bl.length(), bl);
t.truncate(META_COLL, inc_oid, bl.length());
}
cout << "Creating a new epoch." << std::endl;
}
+ if (dry_run)
+ return 0;
ObjectStore::Transaction t;
t.write(META_COLL, full_oid, 0, bl.length(), bl);
t.truncate(META_COLL, full_oid, bl.length());
if (ret < 0)
return ret;
+ if (dry_run)
+ return 0;
+
t->touch(coll, ghobj);
t->setattr(coll, ghobj, key, bl);
if (debug)
cerr << "Rmattr " << ghobj << std::endl;
+ if (dry_run)
+ return 0;
+
t->rmattr(coll, ghobj, key);
store->apply_transaction(*t);
attrset.insert(pair<string, bufferlist>(key, valbl));
+ if (dry_run)
+ return 0;
+
t->touch(coll, ghobj);
t->omap_setkeys(coll, ghobj, attrset);
if (debug)
cerr << "Rm_omap " << ghobj << std::endl;
+ if (dry_run)
+ return 0;
+
t->omap_rmkeys(coll, ghobj, keys);
store->apply_transaction(*t);
if (ret)
return ret;
+ if (dry_run)
+ return 0;
+
t->touch(coll, ghobj);
t->omap_setheader(coll, ghobj, hdrbl);
ret = remove_from(snapset.clone_size, "clone_size", cloneid, force);
if (ret) return ret;
+ if (dry_run)
+ return 0;
+
bufferlist bl;
::encode(snapset, bl);
ObjectStore::Transaction t;
cout << "Remove past-intervals " << past_intervals << std::endl;
past_intervals.clear();
+ if (dry_run) {
+ ret = 0;
+ goto out;
+ }
ret = write_info(*t, map_epoch, info, past_intervals);
if (ret == 0) {
info.history.last_epoch_clean = superblock.current_epoch;
past_intervals.clear();
- ret = write_info(*t, map_epoch, info, past_intervals);
- if (ret == 0) {
+ if (!dry_run) {
+ ret = write_info(*t, map_epoch, info, past_intervals);
+ if (ret != 0)
+ goto out;
fs->apply_transaction(*t);
- cout << "Marking complete succeeded" << std::endl;
}
+ cout << "Marking complete succeeded" << std::endl;
} else {
assert(!"Should have already checked for valid --op");
}