Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial Map-Reduce #491

Merged
merged 17 commits into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions test/instances/storage.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,21 @@ local function get_first_bucket()
return res ~= nil and res.id or nil
end

local function get_n_buckets(n)
if n <= 0 then
error('Invalid number of buckets')
end
local index = box.space._bucket.index.status
local ids = table.new(0, n)
for _, tuple in index:pairs(vconst.BUCKET.ACTIVE) do
table.insert(ids, tuple.id)
if #ids == n then
return ids
end
end
error('Not enough buckets')
end

local function session_set(key, value)
box.session.storage[key] = value
return true
Expand Down Expand Up @@ -167,6 +182,7 @@ _G.box_error = box_error
_G.echo = echo
_G.get_uuid = get_uuid
_G.get_first_bucket = get_first_bucket
_G.get_n_buckets = get_n_buckets
_G.session_set = session_set
_G.session_get = session_get
_G.bucket_gc_wait = bucket_gc_wait
Expand Down
4 changes: 3 additions & 1 deletion test/lua_libs/util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,10 @@ if not BUILDDIR then
BUILDDIR = SOURCEDIR
end

local VARDIR = fio.abspath(os.getenv('VARDIR') or './')

local function git_checkout(dst_dir, version)
local vshard_copy_path = BUILDDIR..'/test/var/'..dst_dir
local vshard_copy_path = VARDIR..'/'..dst_dir
-- Cleanup the directory after a previous build.
os.execute('rm -rf ' .. vshard_copy_path)
-- `git worktree` cannot be used because PACKPACK mounts
Expand Down
13 changes: 13 additions & 0 deletions test/luatest_helpers/vtest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ local yaml = require('yaml')
local vcfg = require('vshard.cfg')
local vrepset = require('vshard.replicaset')
local log = require('log')
-- Otherwise in non-Debug builds apparently the unknown variables are treated as
-- nil-global-variables.
require('strict').on()

local wait_timeout = 50
-- Use it in busy-loops like `while !cond do fiber.sleep(busy_step) end`.
Expand Down Expand Up @@ -463,6 +466,15 @@ local function storage_first_bucket(storage)
end)
end

--
-- Get n active buckets from the storage.
--
local function storage_get_n_buckets(storage, n)
return storage:exec(function(n)
return _G.get_n_buckets(n)
end, {n})
end

--
-- Disable rebalancer on all storages.
--
Expand Down Expand Up @@ -851,6 +863,7 @@ return {
cluster_wait_fullsync = cluster_wait_fullsync,
cluster_rebalancer_find = cluster_rebalancer_find,
storage_first_bucket = storage_first_bucket,
storage_get_n_buckets = storage_get_n_buckets,
storage_stop = storage_stop,
storage_start = storage_start,
router_new = router_new,
Expand Down
4 changes: 2 additions & 2 deletions test/reload_evolution/storage.result
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ REPLICASET_1 = { 'storage_1_a', 'storage_1_b' }
REPLICASET_2 = { 'storage_2_a', 'storage_2_b' }
---
...
test_run:create_cluster(REPLICASET_1, 'reload_evolution')
test_run:create_cluster(REPLICASET_1, 'reload_evolution', {args = vshard_copy_path})
---
...
test_run:create_cluster(REPLICASET_2, 'reload_evolution')
test_run:create_cluster(REPLICASET_2, 'reload_evolution', {args = vshard_copy_path})
---
...
util = require('util')
Expand Down
4 changes: 2 additions & 2 deletions test/reload_evolution/storage.test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ vshard_copy_path = util.git_checkout('vshard_git_tree_copy',

REPLICASET_1 = { 'storage_1_a', 'storage_1_b' }
REPLICASET_2 = { 'storage_2_a', 'storage_2_b' }
test_run:create_cluster(REPLICASET_1, 'reload_evolution')
test_run:create_cluster(REPLICASET_2, 'reload_evolution')
test_run:create_cluster(REPLICASET_1, 'reload_evolution', {args = vshard_copy_path})
test_run:create_cluster(REPLICASET_2, 'reload_evolution', {args = vshard_copy_path})
util = require('util')
util.wait_master(test_run, REPLICASET_1, 'storage_1_a')
util.wait_master(test_run, REPLICASET_2, 'storage_2_a')
Expand Down
12 changes: 3 additions & 9 deletions test/reload_evolution/storage_1_a.lua
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
#!/usr/bin/env tarantool
local util = require('util')
NAME = require('fio').basename(arg[0], '.lua')

-- Run one storage on a different vshard version.
-- To do that, place vshard src to
-- BUILDDIR/test/var/vshard_git_tree_copy/.
local source_path = arg[1]
original_package_path = package.path
if NAME == 'storage_2_a' then
vshard_copy = util.BUILDDIR .. '/test/var/vshard_git_tree_copy'
package.path = string.format(
'%s/?.lua;%s/?/init.lua;%s',
vshard_copy, vshard_copy, original_package_path
)
package.path = string.format('%s/?.lua;%s/?/init.lua;%s', source_path,
source_path, package.path)
end
require('storage_template')
Loading
Loading