/* If we're in the background then trap subprocess stdout/stderr */
if(!(pid = xfork())) {
exitfn = _exit;
- ev_signal_atfork(ev);
+ if(ev)
+ ev_signal_atfork(ev);
signal(SIGPIPE, SIG_DFL);
if(outputfd != -1) {
xdup2(outputfd, 1);
*/
void trackdb_open(int flags) {
int newdb, err;
+ pid_t pid;
/* sanity checks */
assert(opened == 0);
oldversion, config->dbversion);
case TRACKDB_CAN_UPGRADE:
/* This database needs upgrading */
- fatal(0, "database needs upgrading from %ld to %ld, which is not yet supported",
- oldversion, config->dbversion);
+ info("invoking disorder-dbupgrade to upgrade from %ld to %ld",
+ oldversion, config->dbversion);
+ pid = subprogram(0, "disorder-dbupgrade", -1);
+ while(waitpid(pid, &err, 0) == -1 && errno == EINTR)
+ ;
+ if(err)
+ fatal(0, "disorder-dbupgrade %s", wstat(err));
+ info("disorder-dbupgrade succeeded");
+ break;
case TRACKDB_OPEN_FOR_UPGRADE:
break;
default:
time.sleep(2)
dtest.stop_daemon()
# Revert to default configuration
- print "Checking daemon won't start with an old database"
dtest.copyfile(configsave, config)
+ print "Testing daemon manages to upgrade..."
dtest.start_daemon()
- time.sleep(2)
- c = disorder.client()
- try:
- v = c.version()
- print "unexpected success"
- ok = False
- except disorder.communicationError, e:
- if re.search("connection refused", str(e)):
- print "unexpected error: %s" % e
- ok = False
- else:
- ok = True
- dtest.stop_daemon()
- if not ok:
- sys.exit(1)
- # Try running the upgrade tool
- print "Attempting an upgrade..."
- rc = subprocess.call(["disorder-dbupgrade",
- "--config", "%s/config" % dtest.testroot])
- if rc != 0:
- print "disorder-dbupgrade: FAILED: exit code %s" % rc
- sys.exit(1)
- print "Testing daemon after upgrade..."
- dtest.start_daemon()
- time.sleep(2)
+ time.sleep(4)
assert dtest.check_files() == 0
if __name__ == '__main__':