def test_update_log(): """ Test for UpgradeLog class. Adds record to it, gets it back and compares. Then opens the same file file another instance and tries to read added record """ tmpFilePath = path.join(tmpDir, tmpFileName) if not os.path.exists(tmpDir): os.makedirs(tmpDir) elif os.path.exists(tmpFilePath): os.remove(tmpFilePath) log = UpgradeLog(tmpFilePath) assert log.lastEvent is None now = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc()) version = "1.2.3" upgrade_id = '1' # Check that we can add and then get event log.appendScheduled(now, version, upgrade_id) last = log.lastEvent assert last[1] is UpgradeLog.UPGRADE_SCHEDULED assert last[2] == now assert last[3] == version assert last[4] == upgrade_id # Check that the we can load and parse the line we appended before assert UpgradeLog(tmpFilePath).lastEvent == last
def populate_log_with_upgrade_events(tdir_with_pool_txns, pool_txn_node_names, tconf, version: Tuple[str, str, str]): for nm in pool_txn_node_names: path = os.path.join(tdir_with_pool_txns, tconf.nodeDataDir, nm) os.makedirs(path) log = UpgradeLog(os.path.join(path, tconf.upgradeLogFile)) when = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc()) log.appendScheduled(when, version, randomString(10)) log.appendStarted(when, version, randomString(10))
def populate_log_with_upgrade_events( pool_txn_node_names, tdir, tconf, version: Tuple[str, str, str]): for nm in pool_txn_node_names: config_helper = NodeConfigHelper(nm, tconf, chroot=tdir) ledger_dir = config_helper.ledger_dir os.makedirs(ledger_dir) log = UpgradeLog(os.path.join(ledger_dir, tconf.upgradeLogFile)) when = datetime.utcnow().replace(tzinfo=dateutil.tz.tzutc()) log.appendScheduled(when, version, randomString(10)) log.appendStarted(when, version, randomString(10))