def setUpTutorials(test): setUp(test) import_dir = '/tmp/best_practice_data' source_dir = 'sql/src/test/resources/essetup/data/best_practice' if not os.path.isdir(import_dir): os.mkdir(import_dir) shutil.copy(project_path(source_dir, 'data_import.json'), os.path.join(import_dir, "users.json")) shutil.copy(project_path(source_dir, 'data_import.json.gz'), os.path.join(import_dir, "users.json.gz")) shutil.copy(project_path(source_dir, 'data_import_1408312800.json'), os.path.join(import_dir, "users_1408312800.json"))
def setUpQuotes(test): test.globs['cmd'] = cmd cmd.stmt(""" create table quotes ( id integer primary key, quote string, index quote_ft using fulltext (quote) ) clustered by(id) into 2 shards with(number_of_replicas=0)""") import_dir = '/tmp/import_data' if not os.path.isdir(import_dir): os.mkdir(import_dir) shutil.copy(project_path('sql/src/test/resources/essetup/data/copy', 'test_copy_from.json'), os.path.join(import_dir, "quotes.json"))
class CrateTestCmd(CrateCmd): def __init__(self, **kwargs): super(CrateTestCmd, self).__init__(**kwargs) doctest_print = PrintWrapper() self.logger = ColorPrinter(False, stream=doctest_print, line_end='\n') def stmt(self, stmt): stmt = stmt.replace('\n', ' ') if stmt.startswith('\\'): self.process(stmt) else: self.execute(stmt) cmd = CrateTestCmd(is_tty=False) jars = [project_path('blackbox', 'tmp')] jars += glob.glob(crate_path('lib', '*.jar')) java_repl = JavaRepl(jars=jars, port=GLOBAL_PORT_POOL.get()) def wait_for_schema_update(schema, table, column): conn = connect('localhost:' + str(CRATE_HTTP_PORT)) c = conn.cursor() count = 0 while count == 0: c.execute(('select count(*) from information_schema.columns ' 'where table_schema = ? and table_name = ? ' 'and column_name = ?'), (schema, table, column)) count = c.fetchone()[0]
class CrateTestCmd(CrateCmd): def __init__(self, **kwargs): super(CrateTestCmd, self).__init__(**kwargs) doctest_print = PrintWrapper() self.logger = ColorPrinter(False, stream=doctest_print, line_end='\n') def stmt(self, stmt): stmt = stmt.replace('\n', ' ') if stmt.startswith('\\'): self.process(stmt) else: self.execute(stmt) cmd = CrateTestCmd(is_tty=False) jars = [project_path('blackbox', 'tmp', 'crateClient', 'crate-client.jar')] jars += glob.glob(crate_path('lib', '*.jar')) java_repl = JavaRepl( jars=jars, port=GLOBAL_PORT_POOL.get() ) def wait_for_schema_update(schema, table, column): conn = connect('localhost:' + str(CRATE_HTTP_PORT)) c = conn.cursor() count = 0 while count == 0: c.execute(('select count(*) from information_schema.columns ' 'where schema_name = ? and table_name = ? ' 'and column_name = ?'),
class CrateTestCmd(CrateCmd): def __init__(self, **kwargs): super(CrateTestCmd, self).__init__(**kwargs) doctest_print = PrintWrapper() self.logger = ColorPrinter(False, stream=doctest_print, line_end='\n') def stmt(self, stmt): stmt = stmt.replace('\n', ' ') if stmt.startswith('\\'): self.process(stmt) else: self.execute(stmt) cmd = CrateTestCmd(is_tty=False) jars = [project_path('blackbox', 'tmp', 'crateClient', 'crate-client.jar')] jars += glob.glob(crate_path('lib', '*.jar')) java_repl = JavaRepl(jars=jars, port=GLOBAL_PORT_POOL.get()) def wait_for_schema_update(schema, table, column): conn = connect('localhost:' + str(CRATE_HTTP_PORT)) c = conn.cursor() count = 0 while count == 0: c.execute(('select count(*) from information_schema.columns ' 'where schema_name = ? and table_name = ? ' 'and column_name = ?'), (schema, table, column)) count = c.fetchone()[0]