def test_empty_include(self, mock_logger_warn): """https://github.com/mozilla-services/circus/pull/473""" try: get_config(_CONF['empty_include']) except: self.fail('Non-existent includes should not raise') self.assertTrue(mock_logger_warn.called)
def test_expand_vars(self): """ https://github.com/mozilla-services/circus/pull/554 """ conf = get_config(_CONF["expand_vars"]) watcher = conf["watchers"][0] self.assertEqual(watcher["stdout_stream"]["filename"], "/tmp/echo.log")
def test_expand_vars(self): ''' https://github.com/mozilla-services/circus/pull/554 ''' conf = get_config(_CONF['expand_vars']) watcher = conf['watchers'][0] self.assertEqual(watcher['stdout_stream']['filename'], '/tmp/echo.log')
def load_from_config(cls, config_file): cfg = get_config(config_file) # hack reload ioloop to use the monkey patched version reload(ioloop) watchers = [] for watcher in cfg.get('watchers', []): watchers.append(Watcher.load_from_config(watcher)) sockets = [] for socket in cfg.get('sockets', []): sockets.append(CircusSocket.load_from_config(socket)) # creating arbiter arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'], check_delay=cfg.get('check_delay', 1.), prereload_fn=cfg.get('prereload_fn'), stats_endpoint=cfg.get('stats_endpoint'), plugins=cfg.get('plugins'), sockets=sockets) return arbiter
def test_issue1088(self): # #1088 - graceful_timeout should be float conf = get_config(_CONF['issue1088']) watcher = conf['watchers'][0] self.assertEqual(watcher['graceful_timeout'], 25.5) watcher = Watcher.load_from_config(conf['watchers'][0]) watcher.stop()
def load_from_config(cls, config_file): cfg = get_config(config_file) watchers = [] for watcher in cfg.get('watchers', []): watchers.append(Watcher.load_from_config(watcher)) sockets = [] for socket in cfg.get('sockets', []): sockets.append(CircusSocket.load_from_config(socket)) httpd = cfg.get('httpd', False) if httpd: # controlling that we have what it takes to run the web UI # if something is missing this will tell the user try: import circusweb # NOQA except ImportError: logger.error('You need to install circus-web') sys.exit(1) # creating arbiter arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'], check_delay=cfg.get('check_delay', 1.), prereload_fn=cfg.get('prereload_fn'), stats_endpoint=cfg.get('stats_endpoint'), plugins=cfg.get('plugins'), sockets=sockets, warmup_delay=cfg.get('warmup_delay', 0), httpd=httpd, httpd_host=cfg.get('httpd_host', 'localhost'), httpd_port=cfg.get('httpd_port', 8080), debug=cfg.get('debug', False), ssh_server=cfg.get('ssh_server', None)) return arbiter
def load_from_config(cls, config_file): cfg = get_config(config_file) # hack reload ioloop to use the monkey patched version reload(ioloop) watchers = [] for watcher in cfg.get('watchers', []): watchers.append(Watcher.load_from_config(watcher)) sockets = [] for socket in cfg.get('sockets', []): sockets.append(CircusSocket.load_from_config(socket)) # creating arbiter arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'], check_delay=cfg.get('check_delay', 1.), prereload_fn=cfg.get('prereload_fn'), stats_endpoint=cfg.get('stats_endpoint'), plugins=cfg.get('plugins'), sockets=sockets, warmup_delay=cfg.get('warmup_delay', 0), httpd=cfg.get('httpd', False), httpd_host=cfg.get('httpd_host', 'localhost'), httpd_port=cfg.get('httpd_port', 8080), debug=cfg.get('debug', False), stream_backend=cfg.get('stream_backend', 'thread'), ssh_server=cfg.get('ssh_server', None)) return arbiter
def test_issue567(self): os.environ['GRAVITY'] = 'down' conf = get_config(_CONF['issue567']) # make sure the global environment makes it into the cfg environment # even without [env] section self.assertEqual(conf['watchers'][0]['cmd'], 'down')
def test_issue310(self): ''' https://github.com/mozilla-services/circus/pull/310 Allow $(circus.sockets.name) to be used in args. ''' conf = get_config(_CONF['issue310']) watcher = Watcher.load_from_config(conf['watchers'][0]) socket = CircusSocket.load_from_config(conf['sockets'][0]) try: watcher.initialize(None, {'web': socket}, None) process = Process(watcher._nextwid, watcher.cmd, args=watcher.args, working_dir=watcher.working_dir, shell=watcher.shell, uid=watcher.uid, gid=watcher.gid, env=watcher.env, rlimits=watcher.rlimits, spawn=False, executable=watcher.executable, use_fds=watcher.use_sockets, watcher=watcher) sockets_fds = watcher._get_sockets_fds() formatted_args = process.format_args(sockets_fds=sockets_fds) fd = sockets_fds['web'] self.assertEqual(formatted_args, ['foo', '--fd', str(fd)]) finally: socket.close()
def test_issue310(self): """ https://github.com/mozilla-services/circus/pull/310 Allow $(circus.sockets.name) to be used in args. """ conf = get_config(_CONF["issue310"]) watcher = Watcher.load_from_config(conf["watchers"][0]) socket = CircusSocket.load_from_config(conf["sockets"][0]) watcher.initialize(None, {"web": socket}, None) process = Process( watcher._process_counter, watcher.cmd, args=watcher.args, working_dir=watcher.working_dir, shell=watcher.shell, uid=watcher.uid, gid=watcher.gid, env=watcher.env, rlimits=watcher.rlimits, spawn=False, executable=watcher.executable, use_fds=watcher.use_sockets, watcher=watcher, ) fd = watcher._get_sockets_fds()["web"] formatted_args = process.format_args() self.assertEquals(formatted_args, ["foo", "--fd", str(fd)])
def load_from_config(cls, config_file): cfg = get_config(config_file) watchers = [] for watcher in cfg.get('watchers', []): watchers.append(Watcher.load_from_config(watcher)) sockets = [] for socket in cfg.get('sockets', []): sockets.append(CircusSocket.load_from_config(socket)) # creating arbiter arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'], check_delay=cfg.get('check_delay', 1.), prereload_fn=cfg.get('prereload_fn'), stats_endpoint=cfg.get('stats_endpoint'), plugins=cfg.get('plugins'), sockets=sockets, warmup_delay=cfg.get('warmup_delay', 0), httpd=cfg.get('httpd', False), httpd_host=cfg.get('httpd_host', 'localhost'), httpd_port=cfg.get('httpd_port', 8080), debug=cfg.get('debug', False), stream_backend=cfg.get('stream_backend', 'thread'), ssh_server=cfg.get('ssh_server', None)) return arbiter
def test_issue567(self): os.environ["GRAVITY"] = "down" conf = get_config(_CONF["issue567"]) # make sure the global environment makes it into the cfg environment # even without [env] section self.assertEqual(conf["watchers"][0]["cmd"], "down")
def load_from_config(cls, config_file): cfg = get_config(config_file) # hack reload ioloop to use the monkey patched version reload(ioloop) watchers = [] for watcher in cfg.get("watchers", []): watchers.append(Watcher.load_from_config(watcher)) sockets = [] for socket in cfg.get("sockets", []): sockets.append(CircusSocket.load_from_config(socket)) # creating arbiter arbiter = cls( watchers, cfg["endpoint"], cfg["pubsub_endpoint"], check_delay=cfg.get("check_delay", 1.0), prereload_fn=cfg.get("prereload_fn"), stats_endpoint=cfg.get("stats_endpoint"), plugins=cfg.get("plugins"), sockets=sockets, ) return arbiter
def load_from_config(cls, config_file): cfg = get_config(config_file) # hack reload ioloop to use the monkey patched version reload(ioloop) watchers = [] for watcher in cfg.get('watchers', []): watchers.append(Watcher.load_from_config(watcher)) sockets = [] for socket in cfg.get('sockets', []): sockets.append(CircusSocket.load_from_config(socket)) # creating arbiter arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'], check_delay=cfg.get('check_delay', 1.), prereload_fn=cfg.get('prereload_fn'), stats_endpoint=cfg.get('stats_endpoint'), plugins=cfg.get('plugins'), sockets=sockets, warmup_delay=cfg.get('warmup_delay', 0), httpd=cfg.get('httpd', False), httpd_host=cfg.get('httpd_host', 'localhost'), httpd_port=cfg.get('httpd_port', 8080)) return arbiter
def test_override(self): conf = get_config(_CONF['multiple_wildcard']) watchers = conf['watchers'] self.assertEqual(len(watchers), 3) watchers = conf['watchers'] watchers = sorted(watchers, key=lambda a: a['__name__']) self.assertEqual(watchers[2]['env']['INI'], 'private.ini') self.assertEqual(conf['check_delay'], 555)
def test_override(self): conf = get_config(_CONF['multiple_wildcard']) watchers = conf['watchers'] self.assertEquals(len(watchers), 3) watchers = conf['watchers'] watchers.sort() self.assertEquals(watchers[2]['env']['INI'], 'private.ini') self.assertEqual(conf['check'], 555)
def test_override(self): conf = get_config(_CONF["multiple_wildcard"]) watchers = conf["watchers"] self.assertEquals(len(watchers), 3) watchers = conf["watchers"] watchers.sort() self.assertEquals(watchers[2]["env"]["INI"], "private.ini") self.assertEqual(conf["check"], 555)
def test_override(self): conf = get_config(_CONF['multiple_wildcard']) watchers = conf['watchers'] self.assertEquals(len(watchers), 3) watchers = conf['watchers'] watchers.sort() self.assertEquals(watchers[2]['env'], {'INI': 'private.ini'}) self.assertEqual(conf['check'], 555)
def test_copy_env(self): # #564 make sure we respect copy_env os.environ['BAM'] = '1' conf = get_config(_CONF['copy_env']) for watcher in conf['watchers']: if watcher['name'] == 'watcher1': self.assertFalse('BAM' in watcher['env']) else: self.assertTrue('BAM' in watcher['env']) self.assertTrue('TEST1' in watcher['env'])
def load_from_config(cls, config_file, loop=None): cfg = get_config(config_file) watchers = [] for watcher in cfg.get('watchers', []): watchers.append(Watcher.load_from_config(watcher)) sockets = [] for socket_ in cfg.get('sockets', []): sockets.append(CircusSocket.load_from_config(socket_)) httpd = cfg.get('httpd', False) if httpd: # controlling that we have what it takes to run the web UI # if something is missing this will tell the user try: import circusweb # NOQA except ImportError: logger.error('You need to install circus-web') sys.exit(1) # creating arbiter arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'], check_delay=cfg.get('check_delay', 1.), prereload_fn=cfg.get('prereload_fn'), statsd=cfg.get('statsd', False), stats_endpoint=cfg.get('stats_endpoint'), papa_endpoint=cfg.get('papa_endpoint'), multicast_endpoint=cfg.get('multicast_endpoint'), plugins=cfg.get('plugins'), sockets=sockets, warmup_delay=cfg.get('warmup_delay', 0), httpd=httpd, loop=loop, httpd_host=cfg.get('httpd_host', 'localhost'), httpd_port=cfg.get('httpd_port', 8080), debug=cfg.get('debug', False), debug_gc=cfg.get('debug_gc', False), ssh_server=cfg.get('ssh_server', None), pidfile=cfg.get('pidfile', None), loglevel=cfg.get('loglevel', None), logoutput=cfg.get('logoutput', None), loggerconfig=cfg.get('loggerconfig', None), fqdn_prefix=cfg.get('fqdn_prefix', None), umask=cfg['umask'], endpoint_owner=cfg.get('endpoint_owner', None)) # store the cfg which will be used, so it can be used later # for checking if the cfg has been changed arbiter._cfg = cls.get_arbiter_config(cfg) arbiter.config_file = config_file return arbiter
def test_override(self): conf = get_config(_CONF["multiple_wildcard"]) watchers = conf["watchers"] self.assertEqual(len(watchers), 3) watchers = conf["watchers"] if PY2: watchers.sort() else: watchers = sorted(watchers, key=lambda a: a["__name__"]) self.assertEqual(watchers[2]["env"]["INI"], "private.ini") self.assertEqual(conf["check_delay"], 555)
def test_copy_env(self): # #564 make sure we respect copy_env os.environ["BAM"] = "1" conf = get_config(_CONF["copy_env"]) for watcher in conf["watchers"]: if watcher["name"] == "watcher1": self.assertFalse("BAM" in watcher["env"]) else: self.assertTrue("BAM" in watcher["env"]) self.assertTrue("TEST1" in watcher["env"])
def test_override(self): conf = get_config(_CONF['multiple_wildcard']) watchers = conf['watchers'] self.assertEqual(len(watchers), 3) watchers = conf['watchers'] if PY2: watchers.sort() else: watchers = sorted(watchers, key=lambda a: a['__name__']) self.assertEqual(watchers[2]['env']['INI'], 'private.ini') self.assertEqual(conf['check_delay'], 555)
def load_from_config(cls, config_file, loop=None): cfg = get_config(config_file) watchers = [] for watcher in cfg.get("watchers", []): watchers.append(Watcher.load_from_config(watcher)) sockets = [] for socket in cfg.get("sockets", []): sockets.append(CircusSocket.load_from_config(socket)) httpd = cfg.get("httpd", False) if httpd: # controlling that we have what it takes to run the web UI # if something is missing this will tell the user try: import circusweb # NOQA except ImportError: logger.error("You need to install circus-web") sys.exit(1) # creating arbiter arbiter = cls( watchers, cfg["endpoint"], cfg["pubsub_endpoint"], check_delay=cfg.get("check_delay", 1.0), prereload_fn=cfg.get("prereload_fn"), statsd=cfg.get("statsd", False), stats_endpoint=cfg.get("stats_endpoint"), multicast_endpoint=cfg.get("multicast_endpoint"), plugins=cfg.get("plugins"), sockets=sockets, warmup_delay=cfg.get("warmup_delay", 0), httpd=httpd, loop=loop, httpd_host=cfg.get("httpd_host", "localhost"), httpd_port=cfg.get("httpd_port", 8080), debug=cfg.get("debug", False), ssh_server=cfg.get("ssh_server", None), pidfile=cfg.get("pidfile", None), loglevel=cfg.get("loglevel", None), logoutput=cfg.get("logoutput", None), fqdn_prefix=cfg.get("fqdn_prefix", None), umask=cfg["umask"], ) # store the cfg which will be used, so it can be used later # for checking if the cfg has been changed arbiter._cfg = cls.get_arbiter_config(cfg) arbiter.config_file = config_file return arbiter
def test_env_casesense(self): # #730 make sure respect case conf = get_config(_CONF['env_sensecase']) w = conf['watchers'][0] self.assertEqual(w['name'], 'webapp') self.assertTrue('http_proxy' in w['env']) self.assertEqual(w['env']['http_proxy'], 'http://localhost:8080') self.assertTrue('HTTPS_PROXY' in w['env']) self.assertEqual(w['env']['HTTPS_PROXY'], 'http://localhost:8043') self.assertTrue('FunKy_soUl' in w['env']) self.assertEqual(w['env']['FunKy_soUl'], 'scorpio')
def test_env_casesense(self): # #730 make sure respect case conf = get_config(_CONF["env_sensecase"]) w = conf["watchers"][0] self.assertEqual(w["name"], "webapp") self.assertTrue("http_proxy" in w["env"]) self.assertEqual(w["env"]["http_proxy"], "http://localhost:8080") self.assertTrue("HTTPS_PROXY" in w["env"]) self.assertEqual(w["env"]["HTTPS_PROXY"], "http://localhost:8043") self.assertTrue("FunKy_soUl" in w["env"]) self.assertEqual(w["env"]["FunKy_soUl"], "scorpio")
def test_variables_everywhere(self): os.environ["circus_stats_endpoint"] = "tcp://0.0.0.0:9876" os.environ["circus_statsd"] = "True" # these will be overriden os.environ["circus_uid"] = "ubuntu" os.environ["circus_gid"] = "ubuntu" conf = get_config(_CONF["issue442"]) self.assertEqual(conf["stats_endpoint"], "tcp://0.0.0.0:9876") self.assertTrue(conf["statsd"]) self.assertEqual(conf["watchers"][0]["uid"], "tarek") self.assertEqual(conf["watchers"][0]["gid"], "root")
def test_env_section(self): conf = get_config(_CONF['env_section']) watchers_conf = {} for watcher_conf in conf['watchers']: watchers_conf[watcher_conf['name']] = watcher_conf watcher1 = Watcher.load_from_config(watchers_conf['watcher1']) watcher2 = Watcher.load_from_config(watchers_conf['watcher2']) self.assertEquals('lie', watcher1.env['CAKE']) self.assertEquals('cake', watcher2.env['LIE']) for watcher in [watcher1, watcher2]: self.assertEquals("%s:/bin" % os.getenv('PATH'), watcher.env['PATH'])
def test_variables_everywhere(self): os.environ['circus_stats_endpoint'] = 'tcp://0.0.0.0:9876' os.environ['circus_statsd'] = 'True' # these will be overriden os.environ['circus_uid'] = 'ubuntu' os.environ['circus_gid'] = 'ubuntu' conf = get_config(_CONF['issue442']) self.assertEqual(conf['stats_endpoint'], 'tcp://0.0.0.0:9876') self.assertTrue(conf['statsd']) self.assertEqual(conf['watchers'][0]['uid'], 'tarek') self.assertEqual(conf['watchers'][0]['gid'], 'root')
def load_from_config(cls, config_file): cfg = get_config(config_file) # hack reload ioloop to use the monkey patched version reload(ioloop) watchers = [] for watcher in cfg.get('watchers', []): watchers.append(Watcher.load_from_config(watcher)) # creating arbiter arbiter = cls(watchers, cfg['endpoint'], cfg['pubsub_endpoint'], check_delay=cfg.get('check_delay', 1.), prereload_fn=cfg.get('prereload_fn')) return arbiter
def message(self, *args, **opts): if len(args) != 2: raise ArgumentError("invalid number of arguments") config_file, name = args config = get_config(config_file) watchers = config.get('watchers', []) config = filter(lambda w: w['name'] == name, watchers) if not config: raise ArgumentError("watcher not found") config = config[0] config['stdout_stream'] = {'class': 'StdoutStream'} config['stderr_stream'] = {'class': 'StdoutStream'} config['_exec'] = True watcher = Watcher.load_from_config(config) # the next call will exec(), replacing the current process watcher.start()
def load_from_config(cls, config_file): cfg = get_config(config_file) # hack reload ioloop to use the monkey patched version reload(ioloop) watchers = [] for watcher in cfg.get("watchers", []): watchers.append(Watcher.load_from_config(watcher)) # creating arbiter arbiter = cls( watchers, cfg["endpoint"], cfg["pubsub_endpoint"], check_delay=cfg.get("check_delay", 1.0), prereload_fn=cfg.get("prereload_fn"), ) return arbiter
def test_issue310(self): """ https://github.com/mozilla-services/circus/pull/310 Allow $(circus.sockets.name) to be used in args. """ conf = get_config(_CONF["issue310"]) watcher = Watcher.load_from_config(conf["watchers"][0]) socket = CircusSocket.load_from_config(conf["sockets"][0]) try: watcher.initialize(None, {"web": socket}, None) if IS_WINDOWS: # We can't close the sockets on Windows as we # are redirecting stdout watcher.use_sockets = True process = Process( watcher._nextwid, watcher.cmd, args=watcher.args, working_dir=watcher.working_dir, shell=watcher.shell, uid=watcher.uid, gid=watcher.gid, env=watcher.env, rlimits=watcher.rlimits, spawn=False, executable=watcher.executable, use_fds=watcher.use_sockets, watcher=watcher, ) sockets_fds = watcher._get_sockets_fds() formatted_args = process.format_args(sockets_fds=sockets_fds) fd = sockets_fds["web"] self.assertEqual(formatted_args, ["foo", "--fd", str(fd)]) finally: socket.close()
def test_env_section(self): conf = get_config(_CONF["env_section"]) watchers_conf = {} for watcher_conf in conf["watchers"]: watchers_conf[watcher_conf["name"]] = watcher_conf watcher1 = Watcher.load_from_config(watchers_conf["watcher1"]) watcher2 = Watcher.load_from_config(watchers_conf["watcher2"]) self.assertEqual("lie", watcher1.env["CAKE"]) self.assertEqual("cake", watcher2.env["LIE"]) for watcher in [watcher1, watcher2]: self.assertEqual("%s:/bin" % os.getenv("PATH"), watcher.env["PATH"]) self.assertEqual("test1", watcher1.env["TEST1"]) self.assertEqual("test1", watcher2.env["TEST1"]) self.assertEqual("test2", watcher1.env["TEST2"]) self.assertEqual("test2", watcher2.env["TEST2"]) self.assertEqual("test3", watcher1.env["TEST3"]) self.assertEqual("test3", watcher2.env["TEST3"])
def test_legacy_stream_settings(self): """The legacy stream settings should create a plugin when used. """ conf = get_config(_CONF['publish']) watcher = conf['watchers'][0] self.assertTrue(watcher['publish']['stdout']) pub_watcher = conf['watchers'][1] self.assertTrue(pub_watcher['publish']['stdout']) print(conf['plugins']) plugins = dict( (plugin_conf['topic'], plugin_conf) for plugin_conf in conf['plugins'] ) self.assertTrue(plugins['watcher.legacy.stdout']) self.assertEqual(plugins['watcher.legacy.stdout']['use'], 'circus.plugins.loggers.StdoutStream') self.assertTrue(plugins['watcher.publisher.stdout']) self.assertEqual(plugins['watcher.publisher.stdout']['use'], 'circus.plugins.loggers.FancyStdoutStream')
def test_issue137(self): conf = get_config(_CONF['issue137']) watcher = conf['watchers'][0] self.assertEqual(watcher['uid'], 'me')
def test_check_delay(self): conf = get_config(_CONF['issue651']) self.assertEqual(conf['check_delay'], 10.5)
def test_socket_so_reuseport_no(self): conf = get_config(_CONF['reuseport']) s1 = conf['sockets'][1] self.assertEqual(s1['so_reuseport'], False)
def test_socket_so_reuseport_yes(self): conf = get_config(_CONF['reuseport']) s1 = conf['sockets'][0] self.assertEqual(s1['so_reuseport'], True)
def test_watcher_stop_signal(self): conf = get_config(_CONF['issue594']) self.assertEqual(conf['watchers'][0]['stop_signal'], signal.SIGINT) watcher = Watcher.load_from_config(conf['watchers'][0]) watcher.stop()
def test_logoutput(self): conf = get_config(_CONF['circus']) self.assertEqual(conf['logoutput'], 'logoutput')
def test_env_everywhere(self): conf = get_config(_CONF['env_everywhere']) self.assertEqual(conf['endpoint'], 'tcp://127.0.0.1:1234') self.assertEqual(conf['sockets'][0]['path'], '/var/run/broken.sock') self.assertEqual(conf['plugins'][0]['use'], 'bad.has.been.broken')
def test_watcher_graceful_timeout(self): conf = get_config(_CONF['issue210']) watcher = Watcher.load_from_config(conf['watchers'][0]) watcher.stop()
def test_watcher_env_var(self): conf = get_config(_CONF['env_var']) watcher = Watcher.load_from_config(conf['watchers'][0]) self.assertEqual("%s:/bin" % os.getenv('PATH'), watcher.env['PATH']) watcher.stop()
def test_issue395(self): conf = get_config(_CONF['issue395']) watcher = conf['watchers'][0] self.assertEqual(watcher['graceful_timeout'], 88)
def test_loglevel(self): conf = get_config(_CONF['circus']) self.assertEqual(conf['loglevel'], 'debug')
def test_issues665(self): ''' https://github.com/mozilla-services/circus/pull/665 Ensure args formatting when shell = True. ''' conf = get_config(_CONF['issue665']) def load(watcher_conf): watcher = Watcher.load_from_config(watcher_conf.copy()) process = Process(watcher._nextwid, watcher.cmd, args=watcher.args, working_dir=watcher.working_dir, shell=watcher.shell, uid=watcher.uid, gid=watcher.gid, env=watcher.env, rlimits=watcher.rlimits, spawn=False, executable=watcher.executable, use_fds=watcher.use_sockets, watcher=watcher) return process.format_args() import circus.process is_win = circus.process.is_win try: # force nix circus.process.is_win = lambda: False # without shell_args with patch.object(logger, 'warn') as mock_logger_warn: formatted_args = load(conf['watchers'][0]) self.assertEqual(formatted_args, ['foo --fd']) self.assertFalse(mock_logger_warn.called) # with shell_args with patch.object(logger, 'warn') as mock_logger_warn: formatted_args = load(conf['watchers'][1]) self.assertEqual(formatted_args, ['foo --fd', 'bar', 'baz', 'qux']) self.assertFalse(mock_logger_warn.called) # with shell_args but not shell with patch.object(logger, 'warn') as mock_logger_warn: formatted_args = load(conf['watchers'][2]) self.assertEqual(formatted_args, ['foo', '--fd']) self.assertTrue(mock_logger_warn.called) # force win circus.process.is_win = lambda: True # without shell_args with patch.object(logger, 'warn') as mock_logger_warn: formatted_args = load(conf['watchers'][0]) self.assertEqual(formatted_args, ['foo --fd']) self.assertFalse(mock_logger_warn.called) # with shell_args with patch.object(logger, 'warn') as mock_logger_warn: formatted_args = load(conf['watchers'][1]) self.assertEqual(formatted_args, ['foo --fd']) self.assertTrue(mock_logger_warn.called) # with shell_args but not shell with patch.object(logger, 'warn') as mock_logger_warn: formatted_args = load(conf['watchers'][2]) self.assertEqual(formatted_args, ['foo', '--fd']) self.assertTrue(mock_logger_warn.called) finally: circus.process.is_win = is_win
def test_hooks(self): conf = get_config(_CONF['hooks']) watcher = Watcher.load_from_config(conf['watchers'][0]) self.assertEqual(watcher.hooks['before_start'].__doc__, hook.__doc__) self.assertTrue('before_start' not in watcher.ignore_hook_failure)
def test_dashes(self): conf = get_config(_CONF['issue546']) replaced = replace_gnu_args(conf['watchers'][0]['cmd'], sockets={'some-socket': 3}) self.assertEqual(replaced, '../bin/chaussette --fd 3')
def test_pidfile(self): conf = get_config(_CONF['circus']) self.assertEqual(conf['pidfile'], 'pidfile')