From f29704420368b09aa4f5fca1b9f747b94af0765b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Garc=C3=ADa=20Aubert?= Date: Thu, 28 Nov 2019 17:30:06 +0100 Subject: [PATCH] Exec redis comands in batches --- test/index.js | 82 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 19 deletions(-) diff --git a/test/index.js b/test/index.js index 17a5dca1..892b6fed 100644 --- a/test/index.js +++ b/test/index.js @@ -86,26 +86,70 @@ async function populateDatabase () { } async function populateRedis () { - await exec(`redis-cli -p ${REDIS_PORT} -n 5 HMSET rails:users:localhost id ${TEST_USER_ID} database_name "${TEST_DB}" database_host localhost map_key 1234`); - await exec(`redis-cli -p ${REDIS_PORT} -n 5 HMSET rails:users:cartodb250user id ${TEST_USER_ID} database_name "${TEST_DB}" database_host "localhost" database_password "${TEST_PASSWORD}" map_key 4321`); - await exec(`redis-cli -p ${REDIS_PORT} -n 0 HSET rails:${TEST_DB}:my_table infowindow "this, that, the other"`); - await exec(`redis-cli -p ${REDIS_PORT} -n 0 HSET rails:${TEST_DB}:test_table_private_1 privacy "0"`); - // API keys - // User localhost - // API Key Master - await exec(`redis-cli -p ${REDIS_PORT} -n 5 HMSET api_keys:localhost:1234 user "localhost" type "master" grants_sql "true" grants_maps "true" database_role "${TEST_USER}" database_password "${TEST_PASSWORD}"`); - // API Key Default public - await exec(`redis-cli -p ${REDIS_PORT} -n 5 HMSET api_keys:localhost:default_public user "localhost" type "default" grants_sql "true" grants_maps "true" database_role "test_windshaft_publicuser" database_password "public"`); - // API Key Regular - await exec(`redis-cli -p ${REDIS_PORT} -n 5 HMSET api_keys:localhost:regular1 user "localhost" type "regular" grants_sql "true" grants_maps "true" database_role "test_windshaft_regular1" database_password "regular1"`); - // API Key Regular 2 no Maps API access, only to check grants permissions to the API - await exec(`redis-cli -p ${REDIS_PORT} -n 5 HMSET api_keys:localhost:regular2 user "localhost" type "regular" grants_sql "true" grants_maps "false" database_role "test_windshaft_publicuser" database_password "public"`); + const commands = ` + HMSET rails:users:localhost \ + id ${TEST_USER_ID} \ + database_name "${TEST_DB}" \ + database_host localhost \ + map_key 1234 - // User cartodb250user - // API Key Master - await exec(`redis-cli -p ${REDIS_PORT} -n 5 HMSET api_keys:cartodb250user:4321 user "localhost" type "master" grants_sql "true" grants_maps "true" database_role "${TEST_USER}" database_password "${TEST_PASSWORD}"`); - // API Key Default - await exec(`cat <