Skip to content

Commit b3c27b3

Browse files
TotktonadaGerold103
authored andcommitted
test: use dofile() for configs instead of require
The main reason of this change is that we're going to introduce a new built-in module `config`. See [1] for details. Introducing a new module in the global namespace is legal according to our compatibility rules. Quoted from [2]: > Adding a new built-in module or a new global value is considered as > the compatible change. Moreover, in the real-world applications configs may be changed and reloaded, so they likely will be loaded using dofile() or loadfile() without require()'s caching. [1]: tarantool/tarantool#8724 [2]: https://github.com/orgs/tarantool/discussions/6182 NO_DOC=adjust tests for the new tarantool version
1 parent 950f0da commit b3c27b3

17 files changed

+20
-20
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ On storages call `vshard.storage.cfg(cfg, <INSTANCE_UUID>)`:
240240
local MY_UUID = "de0ea826-e71d-4a82-bbf3-b04a6413e417"
241241

242242
-- Call a configuration provider
243-
local cfg = require('localcfg')
243+
local cfg = dofile('localcfg.lua')
244244

245245
-- Start the database with sharding
246246
vshard = require('vshard')

example/router.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ replicasets = {'cbf06940-0790-498b-948d-042b62cf3d29',
1313
'ac522f65-aa94-4134-9f64-51ee384f1a54'}
1414

1515
-- Call a configuration provider
16-
cfg = require('localcfg')
16+
cfg = dofile('localcfg.lua')
1717
if arg[1] == 'discovery_disable' then
1818
cfg.discovery_mode = 'off'
1919
end

example/storage.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ if os.getenv('ADMIN') then
1414
end
1515

1616
-- Call a configuration provider
17-
cfg = require('localcfg')
17+
cfg = dofile('localcfg.lua')
1818
-- Name to uuid map
1919
names = {
2020
['storage_1_a'] = '8a274925-a26d-47fc-9e1b-af88ce939412',

test/failover/box_1_a.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ test_run = require('test_run').new()
77
require('console').listen(os.getenv('ADMIN'))
88

99
vshard = require('vshard')
10-
names = require('names')
11-
cfg = require('config')
10+
names = dofile('names.lua')
11+
cfg = dofile('config.lua')
1212
cfg.weights = nil
1313
vshard.storage.cfg(cfg, names.replica_uuid[NAME])
1414

test/failover/config.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
names = require('names')
1+
names = dofile('names.lua')
22
replica = names.replica_uuid
33
rs = names.rs_uuid
44
weights = {

test/failover/router_1.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ test_run = require('test_run').new()
55

66
local fio = require('fio')
77
local name = fio.basename(arg[0], '.lua')
8-
cfg = require('config')
8+
cfg = dofile('config.lua')
99
vshard = require('vshard')
1010
os = require('os')
1111
fiber = require('fiber')
12-
local names = require('names')
12+
local names = dofile('names.lua')
1313
log = require('log')
1414
rs_uuid = names.rs_uuid
1515
replica_uuid = names.replica_uuid

test/lua_libs/storage_template.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ fiber = require('fiber')
77
test_run = require('test_run').new()
88
util = require('util')
99
require('console').listen(os.getenv('ADMIN'))
10-
cfg = rawget(_G, "cfg") or require('localcfg')
10+
cfg = rawget(_G, "cfg") or dofile('localcfg.lua')
1111
log = require('log')
1212
if not cfg.shard_index then
1313
cfg.shard_index = 'bucket_id'

test/misc/reconfigure.result

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test_run:cmd('start server router_1')
3333
_ = test_run:switch('default')
3434
---
3535
...
36-
cfg = require('localcfg')
36+
cfg = dofile('localcfg.lua')
3737
---
3838
...
3939
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b] = nil

test/misc/reconfigure.test.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ test_run:cmd('create server router_1 with script="misc/router_1.lua", wait=True,
1111
test_run:cmd('start server router_1')
1212

1313
_ = test_run:switch('default')
14-
cfg = require('localcfg')
14+
cfg = dofile('localcfg.lua')
1515
cfg.sharding[util.replicasets[1]].replicas[util.name_to_uuid.storage_1_b] = nil
1616
cfg.sharding[util.replicasets[2]].replicas[util.name_to_uuid.storage_2_a].master = nil
1717
cfg.sharding[util.replicasets[2]].replicas[util.name_to_uuid.storage_2_b].master = true

test/misc/storage_3_a.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ local fio = require('fio')
55
local NAME = fio.basename(arg[0], '.lua')
66

77
-- Call a configuration provider
8-
cfg = require('localcfg')
8+
cfg = dofile('localcfg.lua')
99
cfg.sharding['cbf06940-0790-498b-948d-042b62cf3d29'].replicas['3de2e3e1-9ebe-4d0d-abb1-26d301b84633'] = nil
1010
cfg.sharding['ac522f65-aa94-4134-9f64-51ee384f1a54'].replicas['1e02ae8a-afc0-4e91-ba34-843a356b8ed7'].master = nil
1111
cfg.sharding['ac522f65-aa94-4134-9f64-51ee384f1a54'].replicas['001688c3-66f8-4a31-8e19-036c17d489c2'].master = true

test/multiple_routers/router_1.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local NAME = fio.basename(arg[0], '.lua')
88

99
require('console').listen(os.getenv('ADMIN'))
1010

11-
configs = require('configs')
11+
configs = dofile('configs.lua')
1212

1313
-- Start the database with sharding
1414
vshard = require('vshard')

test/multiple_routers/storage_1_1_a.lua

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ NAME = require('fio').basename(arg[0], '.lua')
55

66
-- Fetch config for the cluster of the instance.
77
if NAME:sub(9,9) == '1' then
8-
cfg = require('configs').cfg_1
8+
cfg = dofile('configs.lua').cfg_1
99
else
10-
cfg = require('configs').cfg_2
10+
cfg = dofile('configs.lua').cfg_2
1111
end
1212
require('storage_template')

test/rebalancer/box_1_a.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env tarantool
22
NAME = require('fio').basename(arg[0], '.lua')
3-
cfg = require('config')
3+
cfg = dofile('config.lua')
44
util = require('util')
55
if NAME == 'box_3_a' or NAME == 'box_3_b' or
66
NAME == 'box_4_a' or NAME == 'box_4_b' or

test/rebalancer/router_1.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env tarantool
2-
cfg = require('config')
2+
cfg = dofile('config.lua')
33
vshard = require('vshard')
44
os = require('os')
55
fiber = require('fiber')

test/router/box_1_a.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/usr/bin/env tarantool
2-
cfg = require('config')
2+
cfg = dofile('config.lua')
33
require('storage_template')

test/router/router_2.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env tarantool
2-
cfg = require('config')
2+
cfg = dofile('config.lua')
33
cfg.listen = 3300
44
require('console').listen(os.getenv('ADMIN'))
55
vshard = require('vshard')

test/router/router_3.lua

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/usr/bin/env tarantool
22
fiber = require('fiber')
3-
cfg = require('config')
3+
cfg = dofile('config.lua')
44
cfg.listen = 3300
55
require('console').listen(os.getenv('ADMIN'))
66
vshard = require('vshard')

0 commit comments

Comments
 (0)