Skip to content
Snippets Groups Projects
Commit b67a8100 authored by ms.evilhat's avatar ms.evilhat
Browse files

fix(test): fix flaky test on cluster with replication

tarantool uses async replication by default, and it is possible to try selecting from a replica that does not have the space or the data yet, which can cause flaky tests
now, we configure storage replicaset and enable sync replication for spaces to work with
Closes #369
parent 66239c03
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -2,6 +2,7 @@
-- Add common configuration here.
local fio = require('fio')
local fiber = require("fiber")
local t = require('luatest')
local cartridge_helpers = require('cartridge.test-helpers')
local config_handler = require('test.helper.config_handler')
......@@ -56,6 +57,39 @@ helper.start_test_cluster = function (cfg)
})
helper.cluster:start()
local storage11 = helper.cluster:server("storage-1-1").net_box
local storage12 = helper.cluster:server("storage-1-2").net_box
-- storage master
storage11:eval("box.cfg{election_mode='candidate'}")
-- storage replica
storage12:eval("box.cfg{election_mode='voter'}")
local WAITING_TIMEOUT = 20
local fiber_sleep = 0.01
local wait_start = fiber.clock()
local s11_ro = storage11:eval("return box.info.ro")
local s12_ro = storage12:eval("return box.info.ro")
-- wait until new replicaset configuration finishes
-- when it happens, master will be readable/writable while replica will be only readable
while s11_ro do
fiber.sleep(fiber_sleep)
s11_ro = storage11:eval("return box.info.ro")
s12_ro = storage12:eval("return box.info.ro")
local current_time = fiber.clock()
if current_time > wait_start + WAITING_TIMEOUT then
t.fail("timeout exceed waiting replication")
end
end
t.assert_equals({s11_ro, s12_ro}, {false, true})
-- replicaset has master and one replica
storage11:eval("box.cfg{replication_synchro_quorum=2}")
helper.cluster:upload_config(cfg)
end
......
local t = require('luatest')
local g = t.group('configuration.sql_cache')
local helper = require('test.helper.cluster_async_replication')
local helper = require('test.helper.cluster_sync_replication')
local cluster = nil
g.before_all(
......@@ -10,9 +10,10 @@ g.before_all(
cluster = helper.cluster
local storage1 = cluster:server("storage-1-1").net_box
storage1:call("box.execute", { [[truncate table "space_for_breake_cache"]] })
local storage2 = cluster:server("storage-2-1").net_box
storage1:call("box.space.space_for_breake_cache:alter", { {is_sync = true}})
storage1:call("box.execute", { [[truncate table "space_for_breake_cache"]] })
storage2:call("box.execute", { [[truncate table "space_for_breake_cache"]] })
end
)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment