def step_impl(context, host, mode_name="admin", host_ip="127.0.0.1"): node = get_node(host) context.logger.debug("btrace is running, start query!!!") time.sleep(5) for row in context.table: if mode_name == "admin": query_meta = QueryMeta(row.as_dict(), "admin", node) else: query_meta = QueryMeta(row.as_dict(), "user", node) cmd = u"nohup mysql -u{} -p{} -P{} -c -D{} -h{} -e\"{}\" >/tmp/dble_{}_query.log 2>&1 &".format( query_meta.user, query_meta.passwd, query_meta.port, query_meta.db, host_ip, query_meta.sql, mode_name) rc, sto, ste = node.ssh_conn.exec_command(cmd) assert len(ste) == 0, "impossible err occur"
def execute_sql_in_host(host_name, info_dic, mode="mysql"): if mode in ["admin", "user"]: #query to dble obj = ObjectFactory.create_dble_object(host_name) query_meta = QueryMeta(info_dic, mode, obj._dble_meta) else: obj = ObjectFactory.create_mysql_object(host_name) query_meta = QueryMeta(info_dic, mode, obj._mysql_meta) pre_delegater = PreQueryPrepare(query_meta) pre_delegater.prepare() res, err, time_cost = obj.do_execute_query(query_meta) post_delegater = PostQueryCheck(res, err, time_cost, query_meta) post_delegater.check_result() return res, err
def step_impl(context, host): node = get_node(host) sshClient = node.ssh_conn context.logger.debug("btrace is running, start query!!!") time.sleep(5) for row in context.table: query_meta = QueryMeta(row.as_dict(), "user", node) cmd = u"nohup mysql -u{} -p{} -P{} -c -D{} -h{} -e'{}' >/tmp/dble_user_query.log 2>&1 &".format(query_meta.user, query_meta.passwd, query_meta.port, query_meta.db, query_meta.ip, query_meta.sql) rc, sto, ste = sshClient.exec_command(cmd) assert len(ste) == 0, "impossible err occur"