示例#1
0
文件: test_cli.py 项目: iffy/grace
    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)
示例#2
0
文件: test_cli.py 项目: iffy/grace
    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")
示例#3
0
文件: test_cli.py 项目: iffy/grace
    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")
示例#4
0
文件: test_cli.py 项目: iffy/grace
 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)