commit c78aca6: [Minor] Tests: Fix robot warning and reformat to better redability
Anton Yuzhaninov
citrin+github at citrin.ru
Fri Jun 21 17:35:06 UTC 2019
Author: Anton Yuzhaninov
Date: 2019-06-20 19:31:56 +0100
URL: https://github.com/rspamd/rspamd/commit/c78aca6959264e6f4998b6c5d360b606d3efa72b
[Minor] Tests: Fix robot warning and reformat to better redability
---
.../cases/210_clickhouse/001_migration.robot | 137 ++++++++++-----------
1 file changed, 62 insertions(+), 75 deletions(-)
diff --git a/test/functional/cases/210_clickhouse/001_migration.robot b/test/functional/cases/210_clickhouse/001_migration.robot
index 9ee526c6c..76e3eabe4 100644
--- a/test/functional/cases/210_clickhouse/001_migration.robot
+++ b/test/functional/cases/210_clickhouse/001_migration.robot
@@ -1,90 +1,77 @@
*** Settings ***
-Documentation Checks if rspamd is able to upgrade migration schema from v0 (very initial) to v2
-Variables ${TESTDIR}/lib/vars.py
-Library ${TESTDIR}/lib/rspamd.py
-Library clickhouse.py
-Resource ${TESTDIR}/lib/rspamd.robot
-
-Test Setup Clickhouse Setup
-Test Teardown Clickhosue Teardown
+Documentation Checks if rspamd is able to upgrade migration schema from v0 (very initial) to v2
+Test Setup Clickhouse Setup
+Test Teardown Clickhosue Teardown
+Variables ${TESTDIR}/lib/vars.py
+Library ${TESTDIR}/lib/rspamd.py
+Library clickhouse.py
+Resource ${TESTDIR}/lib/rspamd.robot
*** Variables ***
-${CONFIG} ${TESTDIR}/configs/clickhouse.conf
-${RSPAMD_SCOPE} Suite
-${CLICKHOUSE_PORT} ${18123}
+${CONFIG} ${TESTDIR}/configs/clickhouse.conf
+${RSPAMD_SCOPE} Suite
+${CLICKHOUSE_PORT} ${18123}
*** 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 3
-
-
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_urls ${TESTDIR}/data/initial_schema/data.rspamd_urls.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
-
- 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 6
-
+ #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 3
+ 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_urls ${TESTDIR}/data/initial_schema/data.rspamd_urls.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
+ 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 6
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
-
+ 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
- Set Global Variable ${TMPDIR}
- Set Directory Ownership ${TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP}
- ${template} = Get File ${TESTDIR}/configs/clickhouse-config.xml
- ${config} = Replace Variables ${template}
- Create File ${TMPDIR}/clickhouse-config.xml ${config}
- Copy File ${TESTDIR}/configs/clickhouse-users.xml ${TMPDIR}/users.xml
- Create Directory ${TMPDIR}/clickhouse
- Set Directory Ownership ${TMPDIR}/clickhouse clickhouse clickhouse
- ${result} = Run Process
- ... su -s /bin/sh clickhouse -c clickhouse-server --daemon --config-file\=${TMPDIR}/clickhouse-config.xml --pid-file\=${TMPDIR}/clickhouse/clickhouse.pid
- Run Keyword If ${result.rc} != 0 Log ${result.stderr}
- Should Be Equal As Integers ${result.rc} 0
- Wait Until Keyword Succeeds 5 sec 50 ms TCP Connect localhost ${CLICKHOUSE_PORT}
- Set Suite Variable ${TMPDIR} ${TMPDIR}
-
-
+ ${TMPDIR} = Make Temporary Directory
+ Set Global Variable ${TMPDIR}
+ Set Directory Ownership ${TMPDIR} ${RSPAMD_USER} ${RSPAMD_GROUP}
+ ${template} = Get File ${TESTDIR}/configs/clickhouse-config.xml
+ ${config} = Replace Variables ${template}
+ Create File ${TMPDIR}/clickhouse-config.xml ${config}
+ Copy File ${TESTDIR}/configs/clickhouse-users.xml ${TMPDIR}/users.xml
+ Create Directory ${TMPDIR}/clickhouse
+ Set Directory Ownership ${TMPDIR}/clickhouse clickhouse clickhouse
+ ${result} = Run Process su -s /bin/sh clickhouse -c
+ ... clickhouse-server --daemon --config-file\=${TMPDIR}/clickhouse-config.xml --pid-file\=${TMPDIR}/clickhouse/clickhouse.pid
+ Run Keyword If ${result.rc} != 0 Log ${result.stderr}
+ Should Be Equal As Integers ${result.rc} 0
+ Wait Until Keyword Succeeds 5 sec 50 ms TCP Connect localhost ${CLICKHOUSE_PORT}
+ Set Suite Variable ${TMPDIR} ${TMPDIR}
Clickhosue Teardown
- # Sleep 30
- ${clickhouse_pid} = Get File ${TMPDIR}/clickhouse/clickhouse.pid
- Shutdown Process With Children ${clickhouse_pid}
- Simple Teardown
-
+ # Sleep 30
+ ${clickhouse_pid} = Get File ${TMPDIR}/clickhouse/clickhouse.pid
+ Shutdown Process With Children ${clickhouse_pid}
+ Simple Teardown
Prepare rspamd
- &{d} = Run Rspamd CONFIG=${TESTDIR}/configs/clickhouse.conf TMPDIR=${TMPDIR}
- ${keys} = Get Dictionary Keys ${d}
- : FOR ${i} IN @{keys}
- \ Run Keyword If '${RSPAMD_SCOPE}' == 'Suite' Set Suite Variable ${${i}} &{d}[${i}]
- \ ... ELSE IF '${RSPAMD_SCOPE}' == 'Test' Set Test Variable ${${i}} &{d}[${i}]
- \ ... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite'
+ &{d} = Run Rspamd CONFIG=${TESTDIR}/configs/clickhouse.conf TMPDIR=${TMPDIR}
+ ${keys} = Get Dictionary Keys ${d}
+ FOR ${i} IN @{keys}
+ Run Keyword If '${RSPAMD_SCOPE}' == 'Suite' Set Suite Variable ${${i}} &{d}[${i}]
+ ... ELSE IF '${RSPAMD_SCOPE}' == 'Test' Set Test Variable ${${i}} &{d}[${i}]
+ ... ELSE Fail 'RSPAMD_SCOPE must be Test or Suite'
+ END
More information about the Commits
mailing list