Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
better0fdead committed Sep 26, 2023
1 parent b2f352c commit 1b84579
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions test/integration/select_readview_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,71 @@ pgroup.before_each(function(g)
helpers.truncate_space_on_cluster(g.cluster, 'cars')
end)

local function set_master(cluster, uuid, master_uuid)
cluster.main_server:graphql({
query = [[
mutation(
$uuid: String!
$master_uuid: [String!]!
) {
edit_replicaset(
uuid: $uuid
master: $master_uuid
)
}
]],
variables = {uuid = uuid, master_uuid = {master_uuid}}
})
end

pgroup.test_select_switch_master = function(g)
helpers.insert_objects(g, 'customers', {
{
id = 1, name = "Elizabeth", last_name = "Jackson",
age = 12, city = "New York",
}, {
id = 2, name = "Mary", last_name = "Brown",
age = 46, city = "Los Angeles",
}, {
id = 3, name = "David", last_name = "Smith",
age = 33, city = "Los Angeles",
}, {
id = 4, name = "William", last_name = "White",
age = 81, city = "Chicago",
},
})

local _, err = g.cluster.main_server.net_box:eval([[
local crud = require('crud')
local foo, err = crud.readview({name = 'foo'})
if err ~= nil then
return nil, err
end
rawset(_G, 'foo', foo)
return nil, err
]])
t.assert_equals(err, nil)
local replicasets = helpers.get_test_replicasets()
set_master(g.cluster, replicasets[2].uuid, replicasets[2].servers[2].instance_uuid)
local obj, err = g.cluster.main_server.net_box:eval([[
local crud = require('crud')
local foo = rawget(_G, 'foo')
local result, err = foo:select('customers', nil, {fullscan = true})
foo:close()
return result, err
]])
set_master(g.cluster, replicasets[2].uuid, replicasets[2].servers[1].instance_uuid)
t.assert_equals(err, nil)
t.assert_equals(obj.rows, {
{1, 477, "Elizabeth", "Jackson", 12, "New York"},
{2, 401, "Mary", "Brown", 46, "Los Angeles"},
{3, 2804, "David", "Smith", 33, "Los Angeles"},
{4, 1161, "William", "White", 81, "Chicago"},
})

end

pgroup.test_non_existent_space = function(g)
local obj, err = g.cluster.main_server.net_box:eval([[
local crud = require('crud')
Expand Down

0 comments on commit 1b84579

Please sign in to comment.