diff options
author | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-24 09:20:06 +0100 |
---|---|---|
committer | Mikhail Galanin <mgalanin@mimecast.com> | 2018-08-24 09:20:06 +0100 |
commit | 213ba86aaa6c1cf62210db1ce19213eeb6f6d5de (patch) | |
tree | 23558d2f7c727e59a4f3ca492c8849759c5d158a /test/functional/cases/210_clickhouse | |
parent | 0fbaf1290c84643c94712ca26fd53872fddc5fc4 (diff) | |
download | rspamd-213ba86aaa6c1cf62210db1ce19213eeb6f6d5de.tar.gz rspamd-213ba86aaa6c1cf62210db1ce19213eeb6f6d5de.zip |
[Test] More test cases for ClickHouse
Diffstat (limited to 'test/functional/cases/210_clickhouse')
-rw-r--r-- | test/functional/cases/210_clickhouse/001_migration.robot | 29 | ||||
-rw-r--r-- | test/functional/cases/210_clickhouse/clickhouse.py | 13 |
2 files changed, 37 insertions, 5 deletions
diff --git a/test/functional/cases/210_clickhouse/001_migration.robot b/test/functional/cases/210_clickhouse/001_migration.robot index 0d8730ba1..c2db5b3ec 100644 --- a/test/functional/cases/210_clickhouse/001_migration.robot +++ b/test/functional/cases/210_clickhouse/001_migration.robot @@ -5,22 +5,31 @@ Library ${TESTDIR}/lib/rspamd.py Library clickhouse.py Resource ${TESTDIR}/lib/rspamd.robot -Suite Setup Clickhouse Setup -Suite Teardown Clickhosue Teardown +Test Setup Clickhouse Setup +Test Teardown Clickhosue Teardown *** Variables *** ${CONFIG} ${TESTDIR}/configs/clickhouse.conf ${RSPAMD_SCOPE} Suite *** Test Cases *** +Initial schema + Prepare rspamd + Sleep 2 #TODO: replace this check with waiting until migration finishes + Column should exist rspamd Symbols.Scores + Column should exist rspamd Attachments.Digest + Column should exist rspamd Symbols.Scores + Schema version should be 2 + + Migration Upload new schema ${TESTDIR}/data/initial_schema/schema.sql Insert data rspamd ${TESTDIR}/data/initial_schema/data.rspamd.sql Insert data rspamd_asn ${TESTDIR}/data/initial_schema/data.rspamd_asn.sql - Insert data rspamd_emails ${TESTDIR}/data/initial_schema/data.rspamd_emails.sql Insert data rspamd_urls ${TESTDIR}/data/initial_schema/data.rspamd_urls.sql - Insert data rspamd_attachments ${TESTDIR}/data/initial_schema/data.rspamd_attachments.sql + Insert data rspamd_emails ${TESTDIR}/data/initial_schema/data.rspamd_emails.sql Insert data rspamd_symbols ${TESTDIR}/data/initial_schema/data.rspamd_symbols.sql + Insert data rspamd_attachments ${TESTDIR}/data/initial_schema/data.rspamd_attachments.sql Prepare rspamd @@ -32,6 +41,18 @@ Migration Schema version should be 2 +Retention + Upload new schema ${TESTDIR}/data/schema_2/schema.sql + Insert data rspamd ${TESTDIR}/data/schema_2/data.rspamd.sql + + Assert rows count rspamd 56 + Prepare rspamd + + Sleep 2 #TODO: replace this check with waiting until migration finishes + + Assert rows count rspamd 30 + + *** Keywords *** Clickhouse Setup ${TMPDIR} = Make Temporary Directory diff --git a/test/functional/cases/210_clickhouse/clickhouse.py b/test/functional/cases/210_clickhouse/clickhouse.py index 069589fed..4e95eadf6 100644 --- a/test/functional/cases/210_clickhouse/clickhouse.py +++ b/test/functional/cases/210_clickhouse/clickhouse.py @@ -15,6 +15,7 @@ class Client: def execute(self, sql): r = requests.post(self.get_query_string(), sql) + logger.info("Client.execute: response: %s" % str(r)) if r.status_code != 200: raise Exception("Clickhouse request failed: " + r.content) return r @@ -56,6 +57,7 @@ def insert_data(table_name, filename): def column_should_exist(table_name, column_name): sql = "select hasColumnInTable('default', '%s', '%s') as is_exist" % (table_name, column_name) r = client().query(sql) + logger.info("response: %s" % str(r)) if r[0]['is_exist'] != 1: raise Exception("Failed asseting that column '%s' exists in table 'default'.'%s'" % (column_name, table_name)) @@ -63,5 +65,14 @@ def column_should_exist(table_name, column_name): def schema_version_should_be(version): sql = "select max(Version) as version from rspamd_version" r = client().query(sql) + logger.info("response: %s" % str(r)) if r[0]['version'] != 2: - raise Exception("Failed asseting that schema version is '%d'" % version)
\ No newline at end of file + raise Exception("Failed asseting that schema version is '%d'" % version) + + +def assert_rows_count(table_name, number): + sql = "select count(*) as cnt from %s" % table_name + r = client().query(sql) + logger.info("response: %s" % str(r)) + if int(r[0]['cnt']) != int(number): + raise Exception("Failed asserting that table '%s' has %d rows (actual number: %d)" % (table_name, int(number), int(r[0]['cnt']))) |