Skip to content

Commit

Permalink
Merge d8fb8fb into 9d16c7a
Browse files Browse the repository at this point in the history
  • Loading branch information
mfussenegger committed Apr 6, 2018
2 parents 9d16c7a + d8fb8fb commit da73cc4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 13 deletions.
2 changes: 2 additions & 0 deletions blackbox/setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[pycodestyle]
ignore = E501
28 changes: 18 additions & 10 deletions blackbox/sqllogictest/src/sqllogictest.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@


QUERY_WHITELIST = [re.compile(o, re.IGNORECASE) for o in [
'CREATE INDEX.*', # CREATE INDEX is not supported, but raises SQLParseException
# CREATE INDEX is not supported, but raises SQLParseException
'CREATE INDEX.*',
'.*BETWEEN.*NULL.*',
'SELECT - SUM \\( col1 \\) \\* \\+ col1 FROM tab0 cor0 GROUP BY col1, col1', # Result is not deterministic
# Result is not deterministic
'SELECT - SUM \\( col1 \\) \\* \\+ col1 FROM tab0 cor0 GROUP BY col1, col1',
]]

varchar_to_string = partial(re.compile('VARCHAR\(\d+\)').sub, 'STRING')
text_to_string = partial(re.compile('TEXT').sub, 'STRING')
real_to_double = partial(re.compile('REAL').sub, 'DOUBLE')


Expand All @@ -51,8 +54,7 @@ def __init__(self, cmd):
self.query = '\n'.join(cmd[1:])

def execute(self, cursor):
stmt = varchar_to_string(self.query)
stmt = real_to_double(stmt)
stmt = real_to_double(text_to_string(varchar_to_string(self.query)))
try:
cursor.execute(stmt)
except psycopg2.Error as e:
Expand Down Expand Up @@ -259,17 +261,23 @@ def _exec_on_crate(cmd):


def _refresh_tables(cursor):
cursor.execute("select table_name from information_schema.tables where table_schema = 'doc'")
cursor.execute("select table_name from information_schema.tables "
"where table_type = 'BASE TABLE' and table_schema = 'doc'")
rows = cursor.fetchall()
for (table,) in rows:
cursor.execute('refresh table ' + table)


def _drop_tables(cursor):
cursor.execute("select table_name from information_schema.tables where table_schema = 'doc'")
rows = cursor.fetchall()
for (table, ) in rows:
def _drop_relations(cursor):
cursor.execute("select table_name from information_schema.tables "
"where table_type = 'BASE TABLE' and table_schema = 'doc'")
for (table,) in cursor.fetchall():
cursor.execute('drop table ' + table)
cursor.execute("select table_name from information_schema.tables "
"where table_type = 'VIEW' and table_schema = 'doc'")
views = [row[0] for row in cursor.fetchall()]
if views:
cursor.execute('drop view ' + ', '.join(views))


def get_logger(level, filename=None):
Expand Down Expand Up @@ -314,7 +322,7 @@ def run_file(filename, host, port, log_level, log_file, failfast):
logger.warn('%s; %s', s_or_q.query, e, extra=attr)
finally:
fh.close()
_drop_tables(cursor)
_drop_relations(cursor)
cursor.close()
conn.close()

Expand Down
8 changes: 5 additions & 3 deletions blackbox/sqllogictest/src/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
'select[1-5].test',
'random/select/slt_good_\d+.test',
'random/groupby/slt_good_\d+.test',
'evidence/slt_lang_createview\.test',
'evidence/slt_lang_dropview\.test'
]]

log = logging.getLogger('crate.testing.layer')
Expand Down Expand Up @@ -67,9 +69,9 @@ def test_suite():
settings={
'psql.port': CRATE_PSQL_PORT,
# The disk.watermark settings can be removed once crate-python > 0.21.1 has been released
"cluster.routing.allocation.disk.watermark.low" : "100k",
"cluster.routing.allocation.disk.watermark.high" : "10k",
"cluster.routing.allocation.disk.watermark.flood_stage" : "1k",
"cluster.routing.allocation.disk.watermark.low": "100k",
"cluster.routing.allocation.disk.watermark.high": "10k",
"cluster.routing.allocation.disk.watermark.flood_stage": "1k",
}
)
suite.layer = crate_layer
Expand Down

0 comments on commit da73cc4

Please sign in to comment.