def test_stop(self): """ Stop will stop a running process. """ runner = Runner() # I'm getting AF_UNIX path too long errors using self.mktemp() base = FilePath(tempfile.mkdtemp()) log.msg('tmpdir: %r' % base.path) root = base.child('root') src = base.child('src') dst = base.child('dst') _ = yield runner.start(root.path, 'unix:'+src.path, 'unix:'+dst.path) pidfile = root.child('grace.pid') pid = pidfile.getContent() self.addCleanup(self.kill, pid) _ = yield runner.stop(root.path) # tail the log until you see Server Shut Down # XXX stop should maybe do the same... so that it doesn't return until # the process has actually stopped. logfile = root.child('grace.log') self.assertTrue(logfile.exists()) _ = yield self.tailUntil(logfile.path, 'Server Shut Down.') self.assertFalse(pidfile.exists(), "pidfile should be gone: %r" % pidfile.path)
def test_switch(self): """ Switch should work """ runner = Runner() # I'm getting AF_UNIX path too long errors using self.mktemp() base = FilePath(tempfile.mkdtemp()) log.msg('tmpdir: %r' % base.path) root = base.child('root') src = base.child('src') dst = base.child('dst') _ = yield runner.start(root.path, 'unix:'+src.path, 'unix:'+dst.path) pidfile = root.child('grace.pid') pid = pidfile.getContent() self.addCleanup(self.kill, pid) r = yield runner.switch(root.path, 'unix:'+src.path, 'unix:/foo') r = yield runner.ls(root.path) self.assertEqual(r, [ { 'src': 'unix:'+src.path, 'dst': 'unix:/foo', 'conns': 0, 'active': True, } ], "Should have switched")
def test_start_waits(self): """ Start should not return until it's actually working. """ runner = Runner() base = FilePath(tempfile.mkdtemp()) root = base.child('root') src = base.child('src') dst = base.child('dst') _ = yield runner.start(root.path, 'unix:'+src.path, 'unix:'+dst.path) self.assertTrue(root.child('grace.pid').exists(), "Should have a pid") pid = root.child('grace.pid').getContent().strip() self.addCleanup(self.kill, pid) self.assertTrue(root.child('grace.socket').exists(), "Should have a " "socket") self.assertTrue(root.exists(), "Should have made the root dir") tac = root.child('grace.tac') self.assertTrue(tac.exists(), "Should have made grace.tac") self.assertEqual(tac.getContent(), getTac(('unix:'+src.path, 'unix:'+dst.path)), "Should have made the tac file using getTac")
def test_wait(self): """ Wait should work """ runner = Runner() # I'm getting AF_UNIX path too long errors using self.mktemp() base = FilePath(tempfile.mkdtemp()) log.msg('tmpdir: %r' % base.path) root = base.child('root') src = base.child('src') dst = base.child('dst') _ = yield runner.start(root.path, 'unix:'+src.path, 'unix:'+dst.path) pidfile = root.child('grace.pid') pid = pidfile.getContent() self.addCleanup(self.kill, pid) r = yield runner.wait(root.path, 'unix:'+src.path)