Tarantool development patches archive
 help / color / mirror / Atom feed
From: Alex Khatskevich <avkhatskevich@tarantool.org>
To: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH 3/4] Tests: separate bootstrap routine to a lua_libs
Date: Mon, 23 Jul 2018 20:19:30 +0300	[thread overview]
Message-ID: <51aa3816-965c-ab43-6a81-d90dac6ef380@tarantool.org> (raw)
In-Reply-To: <fa637357-df35-6446-07ab-fe126f6c8b5f@tarantool.org>


On 23.07.2018 16:36, Vladislav Shpilevoy wrote:
> Thank you for working on the patch!
>
> 1. Please, do not start commit title with capital letter,
> when it is related to a subsystem. Here you should write
>
>     test: separate bootstrap ...
fixed: `tests: separate bootstrap routine to a lua_libs`
>
> On 23/07/2018 14:14, AKhatskevich wrote:
>> What is moved to `test/lul_libs/bootstrap_test_storage.lua`:
>
> 2. 'lul' libs?
fixed
>
>>
>> diff --git a/test/lua_libs/bootstrap_test_storage.lua 
>> b/test/lua_libs/bootstrap_test_storage.lua
>> new file mode 100644
>> index 0000000..62c2f78
>> --- /dev/null
>> +++ b/test/lua_libs/bootstrap_test_storage.lua
>
> 3. Please, just merge it into util. It is actually just util.
3. discussed verbally. file renamed to bootstrap.lua
>
>> diff --git a/test/rebalancer/errinj.result 
>> b/test/rebalancer/errinj.result
>> index d09349e..826c2c6 100644
>> --- a/test/rebalancer/errinj.result
>> +++ b/test/rebalancer/errinj.result
>> @@ -13,7 +13,7 @@ test_run:create_cluster(REPLICASET_1, 'rebalancer')
>>   test_run:create_cluster(REPLICASET_2, 'rebalancer')
>>   ---
>>   ...
>> -util = require('util')
>> +util = require('lua_libs.util')
>
> 4. Please, don't. This should disappear when you merge the utils
> into util.lua. 
4. Same as (3)

full diff:

commit c4c5a3a9678153e7e3315bd11f2f7c882dafbb0c
Author: AKhatskevich <avkhatskevich@tarantool.org>
Date:   Sat Jul 21 02:25:08 2018 +0300

     tests: separate bootstrap routine to a lua_libs

     What is moved to `test/lua_libs/bootstrap.lua`:
     1. create schema
     2. create main stored procedures
     3. `wait_rebalancer_state` procedure

     This code will be reused in further commits.

diff --git a/test/lua_libs/bootstrap.lua b/test/lua_libs/bootstrap.lua
new file mode 100644
index 0000000..62c2f78
--- /dev/null
+++ b/test/lua_libs/bootstrap.lua
@@ -0,0 +1,50 @@
+local log = require('log')
+
+function init_schema()
+    local format = {}
+    format[1] = {name = 'field', type = 'unsigned'}
+    format[2] = {name = 'bucket_id', type = 'unsigned'}
+    local s = box.schema.create_space('test', {format = format})
+    local pk = s:create_index('pk')
+    local bucket_id_idx =
+        s:create_index('vbucket', {parts = {'bucket_id'},
+                       unique = false})
+end
+
+box.once('schema', function()
+    box.schema.func.create('do_replace')
+    box.schema.role.grant('public', 'execute', 'function', 'do_replace')
+    box.schema.func.create('do_select')
+    box.schema.role.grant('public', 'execute', 'function', 'do_select')
+    init_schema()
+end)
+
+function do_replace(...)
+    box.space.test:replace(...)
+    return true
+end
+
+function do_select(...)
+    return box.space.test:select(...)
+end
+
+function check_consistency()
+    for _, tuple in box.space.test:pairs() do
+        assert(box.space._bucket:get{tuple.bucket_id})
+    end
+    return true
+end
+
+--
+-- Wait a specified log message.
+-- Requirements:
+-- * Should be executed from a storage with a rebalancer.
+-- * NAME - global variable, name of instance should be set.
+function wait_rebalancer_state(state, test_run)
+    log.info(string.rep('a', 1000))
+    vshard.storage.rebalancer_wakeup()
+    while not test_run:grep_log(NAME, state, 1000) do
+        fiber.sleep(0.1)
+        vshard.storage.rebalancer_wakeup()
+    end
+end
diff --git a/test/rebalancer/box_1_a.lua b/test/rebalancer/box_1_a.lua
index 8fddcf0..2ca8306 100644
--- a/test/rebalancer/box_1_a.lua
+++ b/test/rebalancer/box_1_a.lua
@@ -2,7 +2,7 @@
  -- Get instance name
  require('strict').on()
  local fio = require('fio')
-local NAME = fio.basename(arg[0], '.lua')
+NAME = fio.basename(arg[0], '.lua')
  log = require('log')
  require('console').listen(os.getenv('ADMIN'))
  fiber = require('fiber')
@@ -23,40 +23,8 @@ if NAME == 'box_4_a' or NAME == 'box_4_b' or
  end
  vshard.storage.cfg(cfg, names.replica_uuid[NAME])

-function init_schema()
-    local format = {}
-    format[1] = {name = 'field', type = 'unsigned'}
-    format[2] = {name = 'bucket_id', type = 'unsigned'}
-    local s = box.schema.create_space('test', {format = format})
-    local pk = s:create_index('pk')
-    local bucket_id_idx =
-        s:create_index('vbucket', {parts = {'bucket_id'},
-                       unique = false})
-end
-
-box.once('schema', function()
-    box.schema.func.create('do_replace')
-    box.schema.role.grant('public', 'execute', 'function', 'do_replace')
-    box.schema.func.create('do_select')
-    box.schema.role.grant('public', 'execute', 'function', 'do_select')
-    init_schema()
-end)
-
-function do_replace(...)
-    box.space.test:replace(...)
-    return true
-end
-
-function do_select(...)
-    return box.space.test:select(...)
-end
-
-function check_consistency()
-    for _, tuple in box.space.test:pairs() do
-        assert(box.space._bucket:get{tuple.bucket_id})
-    end
-    return true
-end
+-- Bootstrap storage.
+require('lua_libs.bootstrap')

  function switch_rs1_master()
      local replica_uuid = names.replica_uuid
@@ -68,12 +36,3 @@ end
  function nullify_rs_weight()
      cfg.sharding[names.rs_uuid[1]].weight = 0
  end
-
-function wait_rebalancer_state(state, test_run)
-    log.info(string.rep('a', 1000))
-    vshard.storage.rebalancer_wakeup()
-    while not test_run:grep_log(NAME, state, 1000) do
-        fiber.sleep(0.1)
-        vshard.storage.rebalancer_wakeup()
-    end
-end
diff --git a/test/rebalancer/errinj.result b/test/rebalancer/errinj.result
index d09349e..826c2c6 100644
--- a/test/rebalancer/errinj.result
+++ b/test/rebalancer/errinj.result
@@ -13,7 +13,7 @@ test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
  ---
  ...
-util = require('util')
+util = require('lua_libs.util')
  ---
  ...
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
diff --git a/test/rebalancer/errinj.test.lua 
b/test/rebalancer/errinj.test.lua
index d6a2920..fc0730c 100644
--- a/test/rebalancer/errinj.test.lua
+++ b/test/rebalancer/errinj.test.lua
@@ -5,7 +5,7 @@ REPLICASET_2 = { 'box_2_a', 'box_2_b' }

  test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
-util = require('util')
+util = require('lua_libs.util')
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
  util.wait_master(test_run, REPLICASET_2, 'box_2_a')

diff --git a/test/rebalancer/rebalancer.result 
b/test/rebalancer/rebalancer.result
index 88cbaae..71e43e1 100644
--- a/test/rebalancer/rebalancer.result
+++ b/test/rebalancer/rebalancer.result
@@ -13,7 +13,7 @@ test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
  ---
  ...
-util = require('util')
+util = require('lua_libs.util')
  ---
  ...
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
diff --git a/test/rebalancer/rebalancer.test.lua 
b/test/rebalancer/rebalancer.test.lua
index 01f2061..1b7ddae 100644
--- a/test/rebalancer/rebalancer.test.lua
+++ b/test/rebalancer/rebalancer.test.lua
@@ -5,7 +5,7 @@ REPLICASET_2 = { 'box_2_a', 'box_2_b' }

  test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
-util = require('util')
+util = require('lua_libs.util')
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
  util.wait_master(test_run, REPLICASET_2, 'box_2_a')

diff --git a/test/rebalancer/rebalancer_lock_and_pin.result 
b/test/rebalancer/rebalancer_lock_and_pin.result
index dd9fe47..0f2921c 100644
--- a/test/rebalancer/rebalancer_lock_and_pin.result
+++ b/test/rebalancer/rebalancer_lock_and_pin.result
@@ -16,7 +16,7 @@ test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
  ---
  ...
-util = require('util')
+util = require('lua_libs.util')
  ---
  ...
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
diff --git a/test/rebalancer/rebalancer_lock_and_pin.test.lua 
b/test/rebalancer/rebalancer_lock_and_pin.test.lua
index fe866c4..3a2daa0 100644
--- a/test/rebalancer/rebalancer_lock_and_pin.test.lua
+++ b/test/rebalancer/rebalancer_lock_and_pin.test.lua
@@ -6,7 +6,7 @@ REPLICASET_3 = { 'box_3_a', 'box_3_b' }

  test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
-util = require('util')
+util = require('lua_libs.util')
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
  util.wait_master(test_run, REPLICASET_2, 'box_2_a')

diff --git a/test/rebalancer/restart_during_rebalancing.result 
b/test/rebalancer/restart_during_rebalancing.result
index d2b8a12..0eb0f2e 100644
--- a/test/rebalancer/restart_during_rebalancing.result
+++ b/test/rebalancer/restart_during_rebalancing.result
@@ -25,7 +25,7 @@ test_run:create_cluster(REPLICASET_3, 'rebalancer')
  test_run:create_cluster(REPLICASET_4, 'rebalancer')
  ---
  ...
-util = require('util')
+util = require('lua_libs.util')
  ---
  ...
  util.wait_master(test_run, REPLICASET_1, 'fullbox_1_a')
diff --git a/test/rebalancer/restart_during_rebalancing.test.lua 
b/test/rebalancer/restart_during_rebalancing.test.lua
index 5b1a8df..7b707ca 100644
--- a/test/rebalancer/restart_during_rebalancing.test.lua
+++ b/test/rebalancer/restart_during_rebalancing.test.lua
@@ -9,7 +9,7 @@ test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
  test_run:create_cluster(REPLICASET_3, 'rebalancer')
  test_run:create_cluster(REPLICASET_4, 'rebalancer')
-util = require('util')
+util = require('lua_libs.util')
  util.wait_master(test_run, REPLICASET_1, 'fullbox_1_a')
  util.wait_master(test_run, REPLICASET_2, 'fullbox_2_a')
  util.wait_master(test_run, REPLICASET_3, 'fullbox_3_a')
diff --git a/test/rebalancer/stress_add_remove_rs.result 
b/test/rebalancer/stress_add_remove_rs.result
index 8a955e2..10bcaac 100644
--- a/test/rebalancer/stress_add_remove_rs.result
+++ b/test/rebalancer/stress_add_remove_rs.result
@@ -16,7 +16,7 @@ test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
  ---
  ...
-util = require('util')
+util = require('lua_libs.util')
  ---
  ...
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
diff --git a/test/rebalancer/stress_add_remove_rs.test.lua 
b/test/rebalancer/stress_add_remove_rs.test.lua
index c80df40..b9bb027 100644
--- a/test/rebalancer/stress_add_remove_rs.test.lua
+++ b/test/rebalancer/stress_add_remove_rs.test.lua
@@ -6,7 +6,7 @@ REPLICASET_3 = { 'box_3_a', 'box_3_b' }

  test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
-util = require('util')
+util = require('lua_libs.util')
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
  util.wait_master(test_run, REPLICASET_2, 'box_2_a')

diff --git a/test/rebalancer/stress_add_remove_several_rs.result 
b/test/rebalancer/stress_add_remove_several_rs.result
index d6008b8..611362c 100644
--- a/test/rebalancer/stress_add_remove_several_rs.result
+++ b/test/rebalancer/stress_add_remove_several_rs.result
@@ -19,7 +19,7 @@ test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
  ---
  ...
-util = require('util')
+util = require('lua_libs.util')
  ---
  ...
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
diff --git a/test/rebalancer/stress_add_remove_several_rs.test.lua 
b/test/rebalancer/stress_add_remove_several_rs.test.lua
index 3cc105e..9acb8de 100644
--- a/test/rebalancer/stress_add_remove_several_rs.test.lua
+++ b/test/rebalancer/stress_add_remove_several_rs.test.lua
@@ -7,7 +7,7 @@ REPLICASET_4 = { 'box_4_a', 'box_4_b' }

  test_run:create_cluster(REPLICASET_1, 'rebalancer')
  test_run:create_cluster(REPLICASET_2, 'rebalancer')
-util = require('util')
+util = require('lua_libs.util')
  util.wait_master(test_run, REPLICASET_1, 'box_1_a')
  util.wait_master(test_run, REPLICASET_2, 'box_2_a')

diff --git a/test/rebalancer/suite.ini b/test/rebalancer/suite.ini
index afc5141..8689da5 100644
--- a/test/rebalancer/suite.ini
+++ b/test/rebalancer/suite.ini
@@ -4,6 +4,6 @@ description = Rebalancer tests
  script = test.lua
  is_parallel = False
  release_disabled = errinj.test.lua
-lua_libs = ../lua_libs/util.lua config.lua names.lua router_1.lua
+lua_libs = ../lua_libs config.lua names.lua router_1.lua
             box_1_a.lua box_1_b.lua box_2_a.lua box_2_b.lua
             box_3_a.lua box_3_b.lua rebalancer_utils.lua

  reply	other threads:[~2018-07-23 17:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-23 11:14 [tarantool-patches] [PATCH v2] vshard reload mechanism AKhatskevich
2018-07-23 11:14 ` [tarantool-patches] [PATCH 1/4] Add test on error during reconfigure AKhatskevich
2018-07-23 13:18   ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-23 11:14 ` [tarantool-patches] [PATCH 2/4] Complete module reload AKhatskevich
2018-07-23 13:31   ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-23 13:45     ` Alex Khatskevich
2018-07-23 14:58       ` Vladislav Shpilevoy
2018-07-23 11:14 ` [tarantool-patches] [PATCH 3/4] Tests: separate bootstrap routine to a lua_libs AKhatskevich
2018-07-23 13:36   ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-23 17:19     ` Alex Khatskevich [this message]
2018-07-23 11:14 ` [tarantool-patches] [PATCH 4/4] Introduce storage reload evolution AKhatskevich
2018-07-23 14:44   ` [tarantool-patches] " Vladislav Shpilevoy
2018-07-23 20:10     ` Alex Khatskevich
2018-07-30  8:56 [tarantool-patches] [PATCH v4] vshard module reload AKhatskevich
2018-07-30  8:56 ` [tarantool-patches] [PATCH 3/4] tests: separate bootstrap routine to a lua_libs AKhatskevich
2018-08-01 12:03   ` [tarantool-patches] " Vladislav Shpilevoy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51aa3816-965c-ab43-6a81-d90dac6ef380@tarantool.org \
    --to=avkhatskevich@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='[tarantool-patches] Re: [PATCH 3/4] Tests: separate bootstrap routine to a lua_libs' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox