def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'core': 'bee', 'gdb': False, 'script': None, 'lua_libs': [], 'valgrind': False, 'vardir': None, 'use_unix_sockets': False, 'bee_port': None } ini.update(_ini) Server.__init__(self, ini) self.testdir = os.path.abspath(os.curdir) self.sourcedir = os.path.abspath(os.path.join(os.path.basename( sys.argv[0]), "..", "..")) self.re_vardir_cleanup += [ "*.snap", "*.xlog", "*.inprogress", "*.sup", "*.lua", "*.pid"] self.name = "default" self.conf = {} self.status = None #-----InitBasicVars-----# self.core = ini['core'] self.gdb = ini['gdb'] self.script = ini['script'] self.lua_libs = ini['lua_libs'] self.valgrind = ini['valgrind'] self.use_unix_sockets = ini['use_unix_sockets'] self._start_against_running = ini['bee_port']
def start(self): pid = self.read_pid() if pid: log.error(u"Server already running, pid %s." % pid) sys.exit(-1) else: self.write_pid(os.getpid()) server = None try: time.sleep(0.001) server = Server((Config.hostname, self.port)) log.info(u"Bloops and bleeps at http://%s:%s" % server.server_address) server.serve_forever() # will never reach this line except socket.error, se: if se.errno == errno.EACCES: log.warn(u"Bad port: %s" % self.port) sys.exit(se.errno) elif se.errno == errno.ECONNREFUSED: log.warn(u"Connection refused: %s" % self.port) sys.exit(se.errno) else: log.exception(se)
def __init__(self, core="tarantool"): Server.__init__(self, core) self.default_bin_name = "tarantool_box" self.default_config_name = "tarantool.cfg" self.default_init_lua_name = "init.lua" # append additional cleanup patterns self.re_vardir_cleanup += [ '*.snap', '*.xlog', '*.inprogress', '*.cfg', '*.sup', '*.lua', '*.pid' ] self.process = None self.config = None self.vardir = None self.valgrind_log = "valgrind.log" self.valgrind_sup = os.path.join("share/", "%s.sup" % ('tarantool')) self.init_lua = None self.default_suppression_name = "valgrind.sup" self.pidfile = None self.port = None self.binary = None self.is_started = False self.mem = False self.start_and_exit = False self.gdb = False self.valgrind = False self.installed = False self.need_init = True
def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'core': 'tarantool', 'gdb': False, 'script': None, 'lua_libs': [], 'valgrind': False, 'vardir': None, 'start_and_exit': False, 'use_unix_sockets': False } ini.update(_ini) Server.__init__(self, ini) self.testdir = os.path.abspath(os.curdir) self.re_vardir_cleanup += [ "*.snap", "*.xlog", "*.inprogress", "*.sup", "*.lua", "*.pid"] self.name = "default" self.conf = {} self.status = None #-----InitBasicVars-----# self.core = ini['core'] self.gdb = ini['gdb'] self.script = ini['script'] self.lua_libs = ini['lua_libs'] self.valgrind = ini['valgrind'] self._start_and_exit = ini['start_and_exit'] self.use_unix_sockets = ini['use_unix_sockets']
def __init__(self, core="tarantool"): Server.__init__(self, core) self.default_bin_name = "tarantool_box" self.default_config_name = "tarantool.cfg" self.default_init_lua_name = "init.lua" # append additional cleanup patterns self.re_vardir_cleanup += ['*.snap', '*.xlog', '*.inprogress', '*.cfg', '*.sup', '*.lua', '*.pid'] self.process = None self.config = None self.vardir = None self.valgrind_log = "valgrind.log" self.valgrind_sup = os.path.join("share/", "%s.sup" % ('tarantool')) self.init_lua = None self.default_suppression_name = "valgrind.sup" self.pidfile = None self.port = None self.binary = None self.is_started = False self.mem = False self.start_and_exit = False self.gdb = False self.valgrind = False self.installed = False self.need_init = True
def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'config': None, 'core': 'tarantool', 'gdb': False, 'init_lua': None, 'lua_libs': [], 'random_ports': True, 'valgrind': False, 'vardir': None, 'start_and_exit': False }; ini.update(_ini) Server.__init__(self, ini) self.generated_fields = self.generate_ports + self.generated_props self.testdir = os.path.abspath(os.curdir) self.re_vardir_cleanup += [ "*.snap", "*.xlog", "*.inprogress", "*.cfg", "*.sup", "*.lua", "*.pid"] self.name = "default" self.conf = {} self.status = None #-----InitBasicVars-----# self.cfgfile_source = ini['config'] self.core = ini['core'] self.gdb = ini['gdb'] self.init_lua_source = ini['init_lua'] self.lua_libs = ini['lua_libs'] self.random_ports = ini['random_ports'] self.valgrind = ini['valgrind'] self._start_and_exit = ini['start_and_exit']
def __init__(self, _ini=None, test_suite=None): if _ini is None: _ini = {} ini = {'vardir': None} ini.update(_ini) Server.__init__(self, ini, test_suite) self.testdir = os.path.abspath(os.curdir) self.vardir = ini['vardir'] self.builddir = ini['builddir'] self.name = 'unittest_server'
def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'vardir': None }; ini.update(_ini) Server.__init__(self, ini) self.vardir = ini['vardir'] self.builddir = ini['builddir'] self.debug = False
def __init__(self, _ini=None, test_suite=None): ini = dict(vardir=None) ini.update({} if _ini is None else _ini) Server.__init__(self, ini, test_suite) self.testdir = os.path.abspath(os.curdir) self.vardir = ini['vardir'] self.builddir = ini['builddir'] self.lua_libs = ini['lua_libs'] self.name = 'app_server' self.process = None self.use_unix_sockets_iproto = ini['use_unix_sockets_iproto']
def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'vardir': None } ini.update(_ini) Server.__init__(self, ini) self.vardir = ini['vardir'] self.builddir = ini['builddir'] self.debug = False
def __init__(self, _ini=None, test_suite=None): ini = dict(vardir=None) ini.update({} if _ini is None else _ini) Server.__init__(self, ini, test_suite) self.testdir = os.path.abspath(os.curdir) self.vardir = ini['vardir'] self.builddir = ini['builddir'] self.debug = False self.lua_libs = ini['lua_libs'] self.name = 'app_server' self.process = None self.binary = TarantoolServer.binary
def __init__(self, _ini=None, test_suite=None): if _ini is None: _ini = {} ini = { 'vardir': None, }; ini.update(_ini) Server.__init__(self, ini, test_suite) self.testdir = os.path.abspath(os.curdir) self.vardir = ini['vardir'] self.builddir = ini['builddir'] self.debug = False self.name = 'unittest_server'
def __init__(self, suite_path, args): """Initialize a test suite: check that it exists and contains a syntactically correct configuration file. Then create a test instance for each found test.""" self.args = args self.tests = [] self.ini = {} self.suite_path = suite_path self.ini["core"] = "tarantool" if os.access(suite_path, os.F_OK) == False: raise RuntimeError("Suite %s doesn't exist" % repr(suite_path)) # read the suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) self.ini.update(self.args.__dict__) self.multi_run = self.get_multirun_conf(suite_path) if self.args.stress is None and self.ini['core'] == 'stress': return for i in ["script"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None for i in ["disabled", "valgrind_disabled", "release_disabled"]: self.ini[i] = dict.fromkeys( self.ini[i].split()) if i in self.ini else dict() for i in ["lua_libs"]: self.ini[i] = map( lambda x: os.path.join(suite_path, x), dict.fromkeys(self.ini[i].split()) if i in self.ini else dict()) try: if self.ini['core'] in ['tarantool', 'stress']: self.server = TarantoolServer(self.ini) else: self.server = Server(self.ini) self.ini["server"] = self.server except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"])) color_stdout("Collecting tests in ", schema='ts_text') color_stdout(repr(suite_path), schema='path') color_stdout(": ", self.ini["description"], ".\n", schema='ts_text') self.server.find_tests(self, suite_path) color_stdout("Found ", str(len(self.tests)), " tests.\n", schema='path')
def __init__(self, _ini=None, test_suite=None): if _ini is None: _ini = {} ini = { 'core': 'tarantool', 'gdb': False, 'lldb': False, 'script': None, 'lua_libs': [], 'valgrind': False, 'vardir': None, 'use_unix_sockets': False, 'tarantool_port': None, 'strace': False } ini.update(_ini) Server.__init__(self, ini, test_suite) self.testdir = os.path.abspath(os.curdir) self.sourcedir = os.path.abspath( os.path.join(os.path.basename(sys.argv[0]), "..", "..")) self.re_vardir_cleanup += [ "*.snap", "*.xlog", "*.vylog", "*.inprogress", "*.sup", "*.lua", "*.pid", "[0-9]*/" ] self.name = "default" self.conf = {} self.status = None # -----InitBasicVars-----# self.core = ini['core'] self.gdb = ini['gdb'] self.lldb = ini['lldb'] self.script = ini['script'] self.lua_libs = ini['lua_libs'] self.valgrind = ini['valgrind'] self.strace = ini['strace'] self.use_unix_sockets = ini['use_unix_sockets'] self._start_against_running = ini['tarantool_port'] self.crash_detector = None # use this option with inspector # to enable crashes in test self.crash_enabled = False # set in from a test let test-run ignore server's crashes self.crash_expected = False # filled in {Test,FuncTest,LuaTest,PythonTest}.execute() # or passed through execfile() for PythonTest self.current_test = None caller_globals = inspect.stack()[1][0].f_globals if 'test_run_current_test' in caller_globals.keys(): self.current_test = caller_globals['test_run_current_test']
def run(ip, port, new_key, sleep_time): # 获取当前使用的rc4加密key rc4_key = get_rc4_key(new_key) Log.log_message( '[*]server cipher key: {}'.format(BOLD(rc4_key)), log_type=Log.SERVER) # 启动http监听服务 session = Session() shell = Shell(session) httpd = Server(ip, port, JSCatServer, session, shell, rc4_key, sleep_time) httpd.start() Log.log_message( '[*]server running in {}:{}...'.format(BOLD('0.0.0.0'), BOLD(port)), log_type=Log.SERVER) Log.log_message( '[*]host connect ip is {}:{}...'.format(BOLD(ip), BOLD(port)), log_type=Log.SERVER) print_online_cmd(ip, port) # 控制台命令输入 try: while True: if not httpd.shell.get_command(): httpd.shutdown() exit() except KeyboardInterrupt: httpd.shutdown() Log.log_message('server shutdown', log_type=Log.SERVER)
def run(cmdArguments): # 获取当前使用的rc4加密key rc4_key = get_rc4_key(cmdArguments.get('new_key')) Log.log_message( '[*]server cipher key: {}'.format(BOLD(rc4_key)), log_type=Log.SERVER) cmdArguments['new_key'] = rc4_key # 启动http监听服务 host = cmdArguments['host'] port = int(cmdArguments['port']) httpd = Server(cmdArguments) httpd.start() Log.log_message( '[*]host connect ip is {}:{}...'.format(BOLD(host), BOLD(port)), log_type=Log.SERVER) print_online_cmd(host, port) # 控制台命令输入 try: while True: if not httpd.shell.get_command(): httpd.shutdown() exit() except KeyboardInterrupt: httpd.shutdown() Log.log_message('server shutdown', log_type=Log.SERVER)
def __init__(self, _ini=None, test_suite=None): if _ini is None: _ini = {} ini = { 'core': 'tarantool', 'gdb': False, 'lldb': False, 'script': None, 'lua_libs': [], 'valgrind': False, 'vardir': None, 'use_unix_sockets': False, 'use_unix_sockets_iproto': False, 'tarantool_port': None, 'strace': False } ini.update(_ini) Server.__init__(self, ini, test_suite) self.testdir = os.path.abspath(os.curdir) self.sourcedir = os.path.abspath(os.path.join(os.path.basename( sys.argv[0]), "..", "..")) self.name = "default" self.conf = {} self.status = None # -----InitBasicVars-----# self.core = ini['core'] self.gdb = ini['gdb'] self.lldb = ini['lldb'] self.script = ini['script'] self.lua_libs = ini['lua_libs'] self.valgrind = ini['valgrind'] self.strace = ini['strace'] self.use_unix_sockets = ini['use_unix_sockets'] self.use_unix_sockets_iproto = ini['use_unix_sockets_iproto'] self._start_against_running = ini['tarantool_port'] self.crash_detector = None # use this option with inspector to enable crashes in test self.crash_enabled = False # set in from a test let test-run ignore server's crashes self.crash_expected = False # filled in {Test,FuncTest,LuaTest,PythonTest}.execute() # or passed through execfile() for PythonTest self.current_test = None caller_globals = inspect.stack()[1][0].f_globals if 'test_run_current_test' in caller_globals.keys(): self.current_test = caller_globals['test_run_current_test']
def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'core': 'tarantool', 'gdb': False, 'init_lua': None, 'lua_libs': [], 'valgrind': False, 'vardir': None }; ini.update(_ini) core = ini['core'] Server.__init__(self, ini) self.vardir = ini['vardir'] self.builddir = ini['builddir'] self.debug = False
def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'vardir': None }; ini.update(_ini) Server.__init__(self, ini) self.testdir = os.path.abspath(os.curdir) self.vardir = ini['vardir'] self.re_vardir_cleanup += [ "*.snap", "*.xlog", "*.inprogress", "*.sup", "*.lua", "*.pid"] self.cleanup() self.builddir = ini['builddir'] self.debug = False self.lua_libs = ini['lua_libs']
def gen_server(self): try: return Server(self.ini, test_suite=self) except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"]))
def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'vardir': None } ini.update(_ini) Server.__init__(self, ini) self.testdir = os.path.abspath(os.curdir) self.vardir = ini['vardir'] self.re_vardir_cleanup += [ "*.snap", "*.xlog", "*.inprogress", "*.sup", "*.lua", "*.pid" ] self.cleanup() self.builddir = ini['builddir'] self.debug = False self.lua_libs = ini['lua_libs']
def __init__(self, suite_path, args): """Initialize a test suite: check that it exists and contains a syntactically correct configuration file. Then create a test instance for each found test.""" self.args = args self.tests = [] self.ini = {} self.suite_path = suite_path self.ini["core"] = "tarantool" if os.access(suite_path, os.F_OK) == False: raise RuntimeError("Suite \"" + suite_path + \ "\" doesn't exist") # read the suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) self.ini.update(self.args.__dict__) for i in ["config", "init_lua"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None for i in ["disabled", "valgrind_disabled", "release_disabled"]: self.ini[i] = dict.fromkeys(self.ini[i].split()) if i in self.ini else dict() for i in ["lua_libs"]: self.ini[i] = map(lambda x: os.path.join(suite_path, x), dict.fromkeys(self.ini[i].split()) if i in self.ini else dict()) for i in ["random_ports"]: self.ini[i] = True if i not in self.ini or self.ini[i].lower() == 'true' else False try: if self.ini['core'] == 'tarantool': self.server = TarantoolServer(self.ini) else: self.server = Server(self.ini) self.ini["server"] = self.server except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"])) color_stdout("Collecting tests in ", schema='ts_text') color_stdout(repr(suite_path), schema='path') color_stdout(": ", self.ini["description"], ".\n", schema='ts_text') self.server.find_tests(self, suite_path) color_stdout("Found ", str(len(self.tests)), " tests.\n", schema='path')
class Utils(metaclass=Singleton): def __init__(self): self.logger = logging.getLogger(__name__) self.server = Server('publish', timeout=15) def get_fh(self, plant, start_time, end_time): start_time = (datetime.now() - timedelta(minutes=60 * 3)).strftime('%Y-%m-%d %H:%M:%S') end_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S') res = dict() _fh_info = dict() self.logger.info('start get plant_id: %s of fh' % plant) units = self.server.get_units(plant) for item in units: _unit_info = { 'name': item['unit_name'], 'code': '%(plant_id)s,%(zone_id)s,%(unit_id)s,you_gfh' % item } _zone_info = { 'name': item['zone_name'], 'code': '%(plant_id)s,%(zone_id)s,0,you_gfh' % item } _plant_info = { 'name': item['plant_name'], 'code': '%(plant_id)s,0,0,you_gfh' % item } if 'unit' not in _fh_info: _fh_info['unit'] = [_unit_info] elif _unit_info not in _fh_info['unit']: _fh_info['unit'].append(_unit_info) if 'zone' not in _fh_info: _fh_info['zone'] = [_zone_info] elif _zone_info not in _fh_info['zone']: _fh_info['zone'].append(_zone_info) if 'plant' not in _fh_info: _fh_info['plant'] = [_plant_info] for key, info in _fh_info.items(): if key not in res: res[key] = list() res[key].append({ item['name']: self.server.get_his_data(item['code'], start_time, end_time) for item in info }) return res
def __init__(self, suite_path, args): """Initialize a test suite: check that it exists and contains a syntactically correct configuration file. Then create a test instance for each found test.""" self.args = args self.tests = [] self.ini = {} self.suite_path = suite_path self.ini["core"] = "tarantool" if os.access(suite_path, os.F_OK) == False: raise RuntimeError("Suite \"" + suite_path + \ "\" doesn't exist") # read the suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) for i in ["config", "init_lua"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None for i in ["disabled", "valgrind_disabled", "release_disabled"]: self.ini[i] = dict.fromkeys( self.ini[i].split()) if i in self.ini else dict() for i in ["lua_libs"]: self.ini[i] = map( lambda x: os.path.join(suite_path, x), dict.fromkeys(self.ini[i].split()) if i in self.ini else dict()) try: self.server = Server(self.ini["core"]) self.ini["server"] = self.server except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"])) print "Collecting tests in \"" + suite_path + "\": " +\ self.ini["description"] + "." self.server.find_tests(self, suite_path) print "Found " + str(len(self.tests)) + " tests."
def main(): """ Main. :return: """ global hup_flag, quit_flag logging.basicConfig( format= "%(asctime)s %(levelname)s %(name)s: %(message)s {%(filename)s:%(funcName)s:%(lineno)s}", level=logging.DEBUG) register_signals() parser = ArgumentParser() parser.add_argument("-f", "--config", help="Config file", default="/etc/mon/probe.conf", dest="config") args = parser.parse_args() server = None while not quit_flag: if hup_flag: try: cf = ConfigParser() try: cf.read_file(open(args.config, "r"), args.config) except FileNotFoundError as e: logging.error( "Config file '%s' was not found. Not reconfiguring." % (e.filename, )) continue server = Server(cf.get("server", "Address")) services = Service.scan(cf.get("probe", "services")) server.register_probe(services) finally: hup_flag = False if server: mapped = server.get_mapped_services() responses = {} time_point = datetime.now() for service in mapped: responses[service.id] = service.fetch() server.update(responses, time_point) sleep()
def __init__(self, _ini=None, test_suite=None): if _ini is None: _ini = {} ini = { 'vardir': None } ini.update(_ini) Server.__init__(self, ini, test_suite) self.testdir = os.path.abspath(os.curdir) self.vardir = ini['vardir'] self.re_vardir_cleanup += [ "*.snap", "*.xlog", "*.vylog", "*.inprogress", "*.sup", "*.lua", "*.pid" ] self.cleanup() self.builddir = ini['builddir'] self.debug = False self.lua_libs = ini['lua_libs'] self.name = 'app_server' self.process = None self.binary = TarantoolServer.binary
def __init__(self, _ini=None): if _ini is None: _ini = {} ini = { 'core': 'tarantool', 'gdb': False, 'lldb': False, 'script': None, 'lua_libs': [], 'valgrind': False, 'vardir': None, 'use_unix_sockets': False, 'tarantool_port': None } ini.update(_ini) Server.__init__(self, ini) self.testdir = os.path.abspath(os.curdir) self.sourcedir = os.path.abspath( os.path.join(os.path.basename(sys.argv[0]), "..", "..")) self.re_vardir_cleanup += [ "*.snap", "*.xlog", "*.inprogress", "*.sup", "*.lua", "*.pid", "[0-9]*/" ] self.name = "default" self.conf = {} self.status = None # -----InitBasicVars-----# self.core = ini['core'] self.gdb = ini['gdb'] self.lldb = ini['lldb'] self.script = ini['script'] self.lua_libs = ini['lua_libs'] self.valgrind = ini['valgrind'] self.use_unix_sockets = ini['use_unix_sockets'] self._start_against_running = ini['tarantool_port'] self.crash_detector = None # use this option with inspector # to enable crashes in test self.crash_enabled = False
def __init__(self): self.__root = Tk() self.__frame = Frame(self.__root) self.__label = Label(self.__frame) self.__chat = Label(self.__frame) self.__host = [(s.connect( ('8.8.8.8', 53)), s.getsockname()[0], s.close()) for s in [socket(AF_INET, SOCK_DGRAM)]][0][1] self.__port = 9001 self.__server = Server(self.__host, self.__port) self.__server_thread = MyServerThread(self.__server, self.__chat)
def main(args): utils.clearscreen() try: if(len(args) == 2): config = ConfigParser.ConfigParser() config.read(args[1]) # Datos de servidor. s_host = config.get("SERVER", "Host") s_port = config.getint("SERVER", "Port") s_webdir = config.get("SERVER", "Webdir") s_idxdir = config.get("SERVER", "Idxpath") s_errdir = config.get("SERVER", "ErrPath") s_logdir = config.get("SERVER", "Logpath") elif len(args) == 7: s_host = args[1] s_port = int(args[2]) s_webdir = args[3] s_idxdir = args[4] s_errdir = args[5] s_logdir = args[6] else: print utils.msg_argv raw_input() sys.exit(0) # Inicio de servidor. server = Server(s_host, s_port, s_webdir, s_idxdir, s_errdir, s_logdir) server.start() except KeyboardInterrupt: pass except Exception, e: print utils.msg_file_not_found print e raw_input() sys.exit(0)
def start(self): pid = self.read_pid() if pid: log.error(u"Server already running, pid %s." % pid) sys.exit( -1 ) else: self.write_pid( os.getpid() ) server = None try: time.sleep(0.001) server = Server((Config.hostname, self.port)) log.info(u"Bloops and bleeps at http://%s:%s" % server.server_address) server.serve_forever() # will never reach this line except socket.error, se: if se.errno == errno.EACCES: log.warn(u"Bad port: %s" % self.port) sys.exit( se.errno ) elif se.errno == errno.ECONNREFUSED: log.warn(u"Connection refused: %s" % self.port) sys.exit( se.errno ) else: log.exception(se)
def run(ip, port, new_key, sleep_time): # 获取当前使用的rc4加密key rc4_key = get_rc4_key(new_key) print('[*]server encrypt key is {}'.format(BOLD(rc4_key))) # 启动http监听服务 session = Session() shell = Shell(session) httpd = Server(ip, port, JSCatServer, session, shell, rc4_key, sleep_time) httpd.start() print('[*]server running in {}:{}...'.format(BOLD(ip), BOLD(port))) print_online_cmd(ip, port) # 控制台命令输入 try: while True: if not httpd.shell.get_command(): httpd.shutdown() exit() except KeyboardInterrupt: httpd.shutdown() print('server shutdown')
def __init__(self, suite_path, args): """Initialize a test suite: check that it exists and contains a syntactically correct configuration file. Then create a test instance for each found test.""" self.args = args self.tests = [] self.ini = {} self.suite_path = suite_path self.ini["core"] = "tarantool" if os.access(suite_path, os.F_OK) == False: raise RuntimeError("Suite \"" + suite_path + \ "\" doesn't exist") # read the suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) for i in ["config", "init_lua"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None for i in ["disabled", "valgrind_disabled", "release_disabled"]: self.ini[i] = dict.fromkeys(self.ini[i].split()) if i in self.ini else dict() for i in ["lua_libs"]: self.ini[i] = map(lambda x: os.path.join(suite_path, x), dict.fromkeys(self.ini[i].split()) if i in self.ini else dict()) try: self.server = Server(self.ini["core"]) self.ini["server"] = self.server except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"])) print "Collecting tests in \"" + suite_path + "\": " +\ self.ini["description"] + "." self.server.find_tests(self, suite_path) print "Found " + str(len(self.tests)) + " tests."
def find_tests(test_suite, suite_path): def patterned(test, patterns): answer = [] for i in patterns: if test.name.find(i) != -1: answer.append(test) return answer test_suite.ini['suite'] = suite_path tests = glob.glob(os.path.join(suite_path, "*.test")) if not tests: executable_path_glob = os.path.join(test_suite.args.builddir, 'test', suite_path, '*.test') tests = glob.glob(executable_path_glob) tests = Server.exclude_tests(tests, test_suite.args.exclude) test_suite.tests = [ UnitTest(k, test_suite.args, test_suite.ini) for k in sorted(tests) ] test_suite.tests = sum( [patterned(x, test_suite.args.tests) for x in test_suite.tests], [])
def find_tests(test_suite, suite_path): def patterned(test_name, patterns): answer = [] for i in patterns: if test_name.find(i) != -1: answer.append(test_name) return answer def is_correct(run): return test_suite.args.conf is None or test_suite.args.conf == run test_suite.ini['suite'] = suite_path test_names = sorted(glob.glob(os.path.join(suite_path, "*.test.lua"))) test_names = Server.exclude_tests(test_names, test_suite.args.exclude) test_names = sum( map((lambda x: patterned(x, test_suite.args.tests)), test_names), []) tests = [] for test_name in test_names: runs = test_suite.get_multirun_params(test_name) if runs: tests.extend([ AppTest(test_name, test_suite.args, test_suite.ini, params=params, conf_name=conf_name) for conf_name, params in runs.iteritems() if is_correct(conf_name) ]) else: tests.append( AppTest(test_name, test_suite.args, test_suite.ini)) test_suite.tests = tests
def __new__(cls, ini=None): return Server.__new__(cls)
def __get_servers_data(): '''obtains the filtered data from the pointed report from the environment variable FACTS_REPORT''' servers = Server() return servers.get_data()
class TestSuite: """Each test suite contains a number of related tests files, located in the same directory on disk. Each test file has extention .test and contains a listing of server commands, followed by their output. The commands are executed, and obtained results are compared with pre-recorded output. In case of a comparision difference, an exception is raised. A test suite must also contain suite.ini, which describes how to start the server for this suite, the client program to execute individual tests and other suite properties. The server is started once per suite.""" def __init__(self, suite_path, args): """Initialize a test suite: check that it exists and contains a syntactically correct configuration file. Then create a test instance for each found test.""" self.args = args self.tests = [] self.ini = {} self.suite_path = suite_path self.ini["core"] = "tarantool" if os.access(suite_path, os.F_OK) == False: raise RuntimeError("Suite %s doesn't exist" % repr(suite_path)) # read the suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) self.ini.update(self.args.__dict__) if self.args.stress is None and self.ini['core'] == 'stress': return for i in ["script"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None for i in ["disabled", "valgrind_disabled", "release_disabled"]: self.ini[i] = dict.fromkeys(self.ini[i].split()) if i in self.ini else dict() for i in ["lua_libs"]: self.ini[i] = map(lambda x: os.path.join(suite_path, x), dict.fromkeys(self.ini[i].split()) if i in self.ini else dict()) try: if self.ini['core'] in ['tarantool', 'stress']: self.server = TarantoolServer(self.ini) else: self.server = Server(self.ini) self.ini["server"] = self.server except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"])) color_stdout("Collecting tests in ", schema='ts_text') color_stdout(repr(suite_path), schema='path') color_stdout(": ", self.ini["description"], ".\n", schema='ts_text') self.server.find_tests(self, suite_path) color_stdout("Found ", str(len(self.tests)), " tests.\n", schema='path') def run_all(self): """For each file in the test suite, run client program assuming each file represents an individual test.""" if not self.tests: # noting to test, exit return [] self.server.deploy(silent=False) if self.args.start_and_exit: color_stdout(" Start and exit requested, exiting...\n", schema='info') exit(0) longsep = '='*70 shortsep = '-'*60 color_stdout(longsep, "\n", schema='separator') color_stdout("TEST".ljust(48), schema='t_name') color_stdout("RESULT\n", schema='test_pass') color_stdout(shortsep, "\n", schema='separator') failed_tests = [] try: for test in self.tests: color_stdout(test.name.ljust(48), schema='t_name') # for better diagnostics in case of a long-running test test_name = os.path.basename(test.name) if (test_name in self.ini["disabled"] or not self.server.debug and test_name in self.ini["release_disabled"] or self.args.valgrind and test_name in self.ini["valgrind_disabled"]): color_stdout("[ disabled ]\n", schema='t_name') else: test.run(self.server) if not test.passed(): failed_tests.append(test.name) color_stdout(shortsep, "\n", schema='separator') self.server.stop(silent=False) except (KeyboardInterrupt) as e: color_stdout("\n%s\n" % shortsep, schema='separator') self.server.stop(silent=False) raise finally: self.server.cleanup() if failed_tests: color_stdout("Failed {0} tests: {1}.\n".format(len(failed_tests), ", ".join(failed_tests)), schema='error') if self.args.valgrind and check_valgrind_log(self.server.valgrind_log): color_stdout(shortsep, "\n", schema='separator') color_stdout(" Error! There were warnings/errors in valgrind log file:\n", schema='error') print_tail_n(self.server.valgrind_log, 20) color_stdout(shortsep, "\n", schema='separator') return ['valgrind error in ' + self.suite_path] return failed_tests
def plant_status(request): context = {'plants_status': Server().get_plants_status()} return render(request, 'torch/plant_status.html', context)
def __new__(cls, ini=None, *args, **kwargs): cls = Server.get_mixed_class(cls, ini) return object.__new__(cls)
def main(): """Start the application""" server = Server() server.start()
class TestSuite: """Each test suite contains a number of related tests files, located in the same directory on disk. Each test file has extention .test and contains a listing of server commands, followed by their output. The commands are executed, and obtained results are compared with pre-recorded output. In case of a comparision difference, an exception is raised. A test suite must also contain suite.ini, which describes how to start the server for this suite, the client program to execute individual tests and other suite properties. The server is started once per suite.""" def __init__(self, suite_path, args): """Initialize a test suite: check that it exists and contains a syntactically correct configuration file. Then create a test instance for each found test.""" self.args = args self.tests = [] self.ini = {} self.suite_path = suite_path self.ini["core"] = "tarantool" if os.access(suite_path, os.F_OK) == False: raise RuntimeError("Suite \"" + suite_path + \ "\" doesn't exist") # read the suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) for i in ["config", "init_lua"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None for i in ["disabled", "valgrind_disabled", "release_disabled"]: self.ini[i] = dict.fromkeys(self.ini[i].split()) if i in self.ini else dict() for i in ["lua_libs"]: self.ini[i] = map(lambda x: os.path.join(suite_path, x), dict.fromkeys(self.ini[i].split()) if i in self.ini else dict()) try: self.server = Server(self.ini["core"]) self.ini["server"] = self.server except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"])) print "Collecting tests in \"" + suite_path + "\": " +\ self.ini["description"] + "." self.server.find_tests(self, suite_path) print "Found " + str(len(self.tests)) + " tests." def run_all(self): """For each file in the test suite, run client program assuming each file represents an individual test.""" if not self.tests: # noting to test, exit return [] self.server.deploy(self.ini["config"], self.server.find_exe(self.args.builddir, silent=False), self.args.vardir, self.args.mem, self.args.start_and_exit, self.args.gdb, self.args.valgrind, init_lua=self.ini["init_lua"], silent=False) if self.ini['core'] != 'unittest': self.ini['servers'] = {'default' : self.server} self.ini['connections'] = {'default' : self.server.admin} self.ini['vardir'] = self.args.vardir self.ini['builddir'] = self.args.builddir for i in self.ini['lua_libs']: shutil.copy(i, self.args.vardir) if self.args.start_and_exit: print " Start and exit requested, exiting..." exit(0) longsep = '='*70 shortsep = '-'*60 print longsep print "TEST".ljust(48), "RESULT" print shortsep failed_tests = [] try: for test in self.tests: sys.stdout.write(test.name.ljust(48)) # for better diagnostics in case of a long-running test sys.stdout.flush() test_name = os.path.basename(test.name) if (test_name in self.ini["disabled"] or not self.server.debug and test_name in self.ini["release_disabled"] or self.args.valgrind and test_name in self.ini["valgrind_disabled"]): print "[ disabled ]" else: test.run(self.server) if not test.passed(): failed_tests.append(test.name) except (KeyboardInterrupt) as e: print '\n', raise finally: print shortsep self.server.stop(silent=False) self.server.cleanup() if failed_tests: print "Failed {0} tests: {1}.".format(len(failed_tests), ", ".join(failed_tests)) if self.args.valgrind and check_valgrind_log(self.server.valgrind_log): print " Error! There were warnings/errors in valgrind log file:" print_tail_n(self.server.valgrind_log, 20) return ['valgrind error in ' + self.suite_path] return failed_tests
class TestSuite: """Each test suite contains a number of related tests files, located in the same directory on disk. Each test file has extention .test and contains a listing of server commands, followed by their output. The commands are executed, and obtained results are compared with pre-recorded output. In case of a comparision difference, an exception is raised. A test suite must also contain suite.ini, which describes how to start the server for this suite, the client program to execute individual tests and other suite properties. The server is started once per suite.""" def get_multirun_conf(self, suite_path): conf_name = self.ini.get('config', None) if conf_name is None: return None path = os.path.join(suite_path, conf_name) result = None with open(path) as cfg: try: result = json.load(cfg) except ValueError: raise RuntimeError('Ivalid multirun json') return result def get_multirun_params(self, test_path): test = test_path.split('/')[-1] if self.multi_run is None: return result = self.multi_run.get(test, None) if result is not None: return result result = self.multi_run.get('*', None) return result def __init__(self, suite_path, args): """Initialize a test suite: check that it exists and contains a syntactically correct configuration file. Then create a test instance for each found test.""" self.args = args self.tests = [] self.ini = {} self.suite_path = suite_path self.ini["core"] = "tarantool" if os.access(suite_path, os.F_OK) == False: raise RuntimeError("Suite %s doesn't exist" % repr(suite_path)) # read the suite config config = ConfigParser.ConfigParser() config.read(os.path.join(suite_path, "suite.ini")) self.ini.update(dict(config.items("default"))) self.ini.update(self.args.__dict__) self.multi_run = self.get_multirun_conf(suite_path) if self.args.stress is None and self.ini['core'] == 'stress': return for i in ["script"]: self.ini[i] = os.path.join(suite_path, self.ini[i]) if i in self.ini else None for i in ["disabled", "valgrind_disabled", "release_disabled"]: self.ini[i] = dict.fromkeys( self.ini[i].split()) if i in self.ini else dict() for i in ["lua_libs"]: self.ini[i] = map( lambda x: os.path.join(suite_path, x), dict.fromkeys(self.ini[i].split()) if i in self.ini else dict()) try: if self.ini['core'] in ['tarantool', 'stress']: self.server = TarantoolServer(self.ini) else: self.server = Server(self.ini) self.ini["server"] = self.server except Exception as e: print e raise RuntimeError("Unknown server: core = {0}".format( self.ini["core"])) color_stdout("Collecting tests in ", schema='ts_text') color_stdout(repr(suite_path), schema='path') color_stdout(": ", self.ini["description"], ".\n", schema='ts_text') self.server.find_tests(self, suite_path) color_stdout("Found ", str(len(self.tests)), " tests.\n", schema='path') def run_all(self): """For each file in the test suite, run client program assuming each file represents an individual test.""" if not self.tests: # noting to test, exit return [] # fixme: remove this string if we fix all legacy tests self.server.cls = self.tests[0].__class__ # create inspectpor daemon for cluster tests inspector = TarantoolInspector('localhost', self.server.inspector_port) inspector.start() self.server.deploy(silent=False) longsep = '=' * 80 shortsep = '-' * 75 color_stdout(longsep, "\n", schema='separator') color_stdout("TEST".ljust(48), schema='t_name') color_stdout("PARAMS\t\t", schema='test_var') color_stdout("RESULT\n", schema='test_pass') color_stdout(shortsep, "\n", schema='separator') failed_tests = [] try: for test in self.tests: test.inspector = inspector color_stdout(os.path.join(self.ini['suite'], os.path.basename( test.name)).ljust(48), schema='t_name') # for better diagnostics in case of a long-running test conf = '' if test.run_params: conf = test.conf_name color_stdout("%s" % conf.ljust(16), schema='test_var') test_name = os.path.basename(test.name) if (test_name in self.ini["disabled"] or not self.server.debug and test_name in self.ini["release_disabled"] or self.args.valgrind and test_name in self.ini["valgrind_disabled"] or not self.args.long and test_name in self.ini.get("long_run", [])): color_stdout("[ disabled ]\n", schema='t_name') else: test.run(self.server) if not test.passed(): failed_tests.append(test.name) color_stdout(shortsep, "\n", schema='separator') self.server.stop(silent=False) # don't delete core files or state of the data dir # in case of exception, which is raised when the # server crashes inspector.stop() self.server.cleanup() except KeyboardInterrupt: color_stdout("\n%s\n" % shortsep, schema='separator') self.server.stop(silent=False) raise if failed_tests: color_stdout("Failed {0} tests: {1}.\n".format( len(failed_tests), ", ".join(failed_tests)), schema='error') if self.args.valgrind and check_valgrind_log(self.server.valgrind_log): color_stdout(shortsep, "\n", schema='separator') color_stdout( " Error! There were warnings/errors in valgrind log file:\n", schema='error') print_tail_n(self.server.valgrind_log, 20) color_stdout(shortsep, "\n", schema='separator') return ['valgrind error in ' + self.suite_path] return failed_tests
def get_tests(*patterns): res = [] for pattern in patterns: path_pattern = os.path.join(suite_path, pattern) res.extend(sorted(glob.glob(path_pattern))) return Server.exclude_tests(res, test_suite.args.exclude)