tarantool / test-run

Tarantool functional testing framework
14 stars 15 forks source link

test-run:create_cluster and test-run:cmd args duplication #347

Open grafin opened 2 years ago

grafin commented 2 years ago

Adding following line at the top of tarantool/test/replication/election_replica.lua

print('DEBUG', require'yaml'.encode(arg))

And running gh-5445-leader-inconsistency.test.lua

Produces following log when test_run:create_cluster(SERVERS, "replication", {args='2 0.4'}) is called:

DEBUG   ---
0: election_replica1.lua
1: '2'
2: '0.4'
4: '0.4'
-1: /home/boris/dev/github/tarantool/tarantool/build/src/tarantool
...

And following, when test_run:cmd('start server '..other..' with args="1 0.4 voter 2"') is called:

DEBUG   ---
0: election_replica1.lua
1: '1'
2: '0.4'
3: voter
4: '2'
6: '2'
-1: /home/boris/dev/github/tarantool/tarantool/build/src/tarantool
...

The problem is last (N'th) argument is passed twice (as N' and N'th+2), this leads to incorrect default values handling in my case, when I add following changes, and expect 'off' as the default value for 5th argument:

diff --git a/test/replication/election_replica.lua b/test/replication/election_replica.lua
index 4848775f2..2ae29877a 100644
--- a/test/replication/election_replica.lua
+++ b/test/replication/election_replica.lua
@@ -6,7 +6,7 @@ local SYNCHRO_QUORUM = arg[1] and tonumber(arg[1]) or 3
 local ELECTION_TIMEOUT = arg[2] and tonumber(arg[2]) or 0.1
 local ELECTION_MODE = arg[3] or 'candidate'
 local CONNECT_QUORUM = arg[4] and tonumber(arg[4]) or 3
-local ELECTION_FENCING_ENABLED = arg[5] and true or false
+local ELECTION_FENCING_MODE = arg[5] or 'off'

 local function instance_uri(instance_id)
     return SOCKET_DIR..'/election_replica'..instance_id..'.sock';
@@ -25,7 +25,7 @@ box.cfg({
     replication_connect_quorum = CONNECT_QUORUM,
     election_mode = ELECTION_MODE,
     election_timeout = ELECTION_TIMEOUT,
-    election_fencing_enabled = ELECTION_FENCING_ENABLED,
+    election_fencing_mode = ELECTION_FENCING_MODE,
     replication_synchro_quorum = SYNCHRO_QUORUM,
     replication_synchro_timeout = 0.1,
     -- To reveal more election logs.

Call like test_run:cmd('start server '..leader..' with args="3 0.4 voter"') leads to 'voter' being passed as arg[5] and tarantool replica reporting:

[001] Configuration failed: Incorrect value for option 'election_fencing_mode': the value must be one of the following strings: 'off', 'soft', 'strict'