Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This patch introduces new type of test - "upgrade". The main idea - try to bootstrap server with old schema version then this changes should be applied to all replicas in replicaset. We significant change from existing integration tests - we try to do this using prepared snaps and wals. Need for #640
- Loading branch information
Showing
30 changed files
with
329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
### Notes about upgrade tests | ||
|
||
This part of tests check that we could perform an upgrade | ||
from a smaller tarantool schema version to more higher. | ||
|
||
This readme demonstrates how this works. | ||
First of all, we should prepare the data with an | ||
initial schema version. | ||
|
||
As example let's see on `test_master_replica`. | ||
The main idea of the tests. At first bootstrap an | ||
instance using Tarantool 1.10 and then upgrade it to | ||
2.2+. | ||
|
||
Our algorithm: | ||
* Bootstrap an instance using Tarantool 1.10 | ||
* Upgrade Tarantool version to 2.2+ | ||
* Start a cluster with upgrade procedure | ||
* Preform some checks. | ||
|
||
|
||
We have a test script that could be used as an | ||
a snippet for bootstrap. | ||
|
||
Let's apply the following diff and run test: | ||
```diff | ||
--- a/test/upgrade/test_master_replica/upgrade_master_replica_1_10_test.lua | ||
+++ b/test/upgrade/test_master_replica/upgrade_master_replica_1_10_test.lua | ||
@@ -6,10 +6,7 @@ local helpers = require('test.helper') | ||
|
||
g.before_all = function() | ||
local cwd = fio.cwd() | ||
- local test_data_dir = fio.pathjoin(cwd, 'test/upgrade/test_master_replica/data') | ||
- local datadir = fio.tempdir() | ||
- local ok, err = fio.copytree(test_data_dir, datadir) | ||
- assert(ok, err) | ||
+ local datadir = fio.pathjoin(cwd, 'test/upgrade/test_master_replica/data') | ||
|
||
local cookie = 'upgrade-1.10-2.2' | ||
|
||
@@ -58,13 +55,12 @@ g.before_all = function() | ||
}) | ||
-- We start cluster from existing 1.10 snapshots | ||
-- with schema version {'1', '10', '2'} | ||
- g.cluster.bootstrapped = true | ||
+ --g.cluster.bootstrapped = true | ||
g.cluster:start() | ||
end | ||
|
||
g.after_all = function() | ||
g.cluster:stop() | ||
- fio.rmtree(g.cluster.datadir) | ||
end | ||
|
||
function g.test_upgrade() | ||
``` | ||
|
||
A result will be written in `'test/upgrade/test_master_replica/data'`. | ||
Then we could uncomment `g.cluster.bootstrapped = true` back and run | ||
a test again to be closer to real situation. | ||
After wals/snaps/configs are ready to be tested. |
Binary file added
BIN
+1.53 KB
test/upgrade/test_master_replica/data/localhost-13301/00000000000000000000.snap
Binary file not shown.
Binary file added
BIN
+247 Bytes
test/upgrade/test_master_replica/data/localhost-13301/00000000000000000000.xlog
Binary file not shown.
Binary file added
BIN
+214 Bytes
test/upgrade/test_master_replica/data/localhost-13301/00000000000000000002.xlog
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
test/upgrade/test_master_replica/data/localhost-13301/00000000000000000003.xlog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
XLOG | ||
0.13 | ||
Version: 1.10.5-31-g9cb39b862 | ||
Instance: aaaaaaaa-aaaa-0000-0000-000000000001 | ||
VClock: {1: 3} | ||
PrevVClock: {1: 2} | ||
|
||
��� |
5 changes: 5 additions & 0 deletions
5
test/upgrade/test_master_replica/data/localhost-13301/config/auth.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
cookie_max_age: 2592000 | ||
enabled: false | ||
cookie_renew_age: 86400 | ||
... |
35 changes: 35 additions & 0 deletions
35
test/upgrade/test_master_replica/data/localhost-13301/config/topology.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
replicasets: | ||
bbbbbbbb-0000-0000-0000-000000000000: | ||
weight: 1 | ||
master: | ||
- bbbbbbbb-bbbb-0000-0000-000000000001 | ||
- bbbbbbbb-bbbb-0000-0000-000000000002 | ||
alias: unnamed | ||
roles: | ||
myrole-permanent: true | ||
vshard-storage: true | ||
vshard_group: default | ||
aaaaaaaa-0000-0000-0000-000000000000: | ||
master: | ||
- aaaaaaaa-aaaa-0000-0000-000000000001 | ||
weight: 0 | ||
roles: | ||
myrole-permanent: true | ||
vshard-router: true | ||
alias: unnamed | ||
servers: | ||
bbbbbbbb-bbbb-0000-0000-000000000002: | ||
disabled: false | ||
replicaset_uuid: bbbbbbbb-0000-0000-0000-000000000000 | ||
uri: localhost:13305 | ||
bbbbbbbb-bbbb-0000-0000-000000000001: | ||
disabled: false | ||
replicaset_uuid: bbbbbbbb-0000-0000-0000-000000000000 | ||
uri: localhost:13303 | ||
aaaaaaaa-aaaa-0000-0000-000000000001: | ||
disabled: false | ||
replicaset_uuid: aaaaaaaa-0000-0000-0000-000000000000 | ||
uri: localhost:13301 | ||
failover: false | ||
... |
10 changes: 10 additions & 0 deletions
10
test/upgrade/test_master_replica/data/localhost-13301/config/vshard_groups.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
default: | ||
rebalancer_max_receiving: 100 | ||
bootstrapped: true | ||
collect_bucket_garbage_interval: 0.5 | ||
collect_lua_garbage: false | ||
sync_timeout: 1 | ||
bucket_count: 3000 | ||
rebalancer_disbalance_threshold: 1 | ||
... |
Binary file added
BIN
+1.53 KB
test/upgrade/test_master_replica/data/localhost-13303/00000000000000000000.snap
Binary file not shown.
Binary file added
BIN
+2.45 KB
test/upgrade/test_master_replica/data/localhost-13303/00000000000000000000.xlog
Binary file not shown.
Binary file added
BIN
+1.89 KB
test/upgrade/test_master_replica/data/localhost-13303/00000000000000000034.snap
Binary file not shown.
Binary file added
BIN
+205 Bytes
test/upgrade/test_master_replica/data/localhost-13303/00000000000000000034.xlog
Binary file not shown.
Binary file added
BIN
+220 Bytes
test/upgrade/test_master_replica/data/localhost-13303/00000000000000000035.xlog
Binary file not shown.
Binary file added
BIN
+7.99 KB
test/upgrade/test_master_replica/data/localhost-13303/00000000000000000036.xlog
Binary file not shown.
Binary file added
BIN
+236 Bytes
test/upgrade/test_master_replica/data/localhost-13303/00000000000000003036.xlog
Binary file not shown.
Binary file added
BIN
+236 Bytes
test/upgrade/test_master_replica/data/localhost-13303/00000000000000003037.xlog
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
test/upgrade/test_master_replica/data/localhost-13303/00000000000000003038.xlog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
XLOG | ||
0.13 | ||
Version: 1.10.5-31-g9cb39b862 | ||
Instance: bbbbbbbb-bbbb-0000-0000-000000000001 | ||
VClock: {1: 3036, 2: 2} | ||
PrevVClock: {1: 3036, 2: 1} | ||
|
||
��� |
5 changes: 5 additions & 0 deletions
5
test/upgrade/test_master_replica/data/localhost-13303/config/auth.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
cookie_max_age: 2592000 | ||
enabled: false | ||
cookie_renew_age: 86400 | ||
... |
35 changes: 35 additions & 0 deletions
35
test/upgrade/test_master_replica/data/localhost-13303/config/topology.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
replicasets: | ||
bbbbbbbb-0000-0000-0000-000000000000: | ||
weight: 1 | ||
master: | ||
- bbbbbbbb-bbbb-0000-0000-000000000001 | ||
- bbbbbbbb-bbbb-0000-0000-000000000002 | ||
alias: unnamed | ||
roles: | ||
myrole-permanent: true | ||
vshard-storage: true | ||
vshard_group: default | ||
aaaaaaaa-0000-0000-0000-000000000000: | ||
master: | ||
- aaaaaaaa-aaaa-0000-0000-000000000001 | ||
weight: 0 | ||
roles: | ||
myrole-permanent: true | ||
vshard-router: true | ||
alias: unnamed | ||
servers: | ||
bbbbbbbb-bbbb-0000-0000-000000000002: | ||
disabled: false | ||
replicaset_uuid: bbbbbbbb-0000-0000-0000-000000000000 | ||
uri: localhost:13305 | ||
bbbbbbbb-bbbb-0000-0000-000000000001: | ||
disabled: false | ||
replicaset_uuid: bbbbbbbb-0000-0000-0000-000000000000 | ||
uri: localhost:13303 | ||
aaaaaaaa-aaaa-0000-0000-000000000001: | ||
disabled: false | ||
replicaset_uuid: aaaaaaaa-0000-0000-0000-000000000000 | ||
uri: localhost:13301 | ||
failover: false | ||
... |
10 changes: 10 additions & 0 deletions
10
test/upgrade/test_master_replica/data/localhost-13303/config/vshard_groups.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
default: | ||
rebalancer_max_receiving: 100 | ||
bootstrapped: true | ||
collect_bucket_garbage_interval: 0.5 | ||
collect_lua_garbage: false | ||
sync_timeout: 1 | ||
bucket_count: 3000 | ||
rebalancer_disbalance_threshold: 1 | ||
... |
Binary file added
BIN
+1.9 KB
test/upgrade/test_master_replica/data/localhost-13305/00000000000000000035.snap
Binary file not shown.
Binary file added
BIN
+200 Bytes
test/upgrade/test_master_replica/data/localhost-13305/00000000000000000035.xlog
Binary file not shown.
Binary file added
BIN
+31.4 KB
test/upgrade/test_master_replica/data/localhost-13305/00000000000000000036.xlog
Binary file not shown.
Binary file added
BIN
+129 KB
test/upgrade/test_master_replica/data/localhost-13305/00000000000000000630.xlog
Binary file not shown.
Binary file added
BIN
+329 Bytes
test/upgrade/test_master_replica/data/localhost-13305/00000000000000003036.xlog
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
test/upgrade/test_master_replica/data/localhost-13305/00000000000000003038.xlog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
XLOG | ||
0.13 | ||
Version: 1.10.5-31-g9cb39b862 | ||
Instance: bbbbbbbb-bbbb-0000-0000-000000000002 | ||
VClock: {1: 3036, 2: 2} | ||
PrevVClock: {1: 3035, 2: 1} | ||
|
||
��� |
5 changes: 5 additions & 0 deletions
5
test/upgrade/test_master_replica/data/localhost-13305/config/auth.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
cookie_max_age: 2592000 | ||
enabled: false | ||
cookie_renew_age: 86400 | ||
... |
35 changes: 35 additions & 0 deletions
35
test/upgrade/test_master_replica/data/localhost-13305/config/topology.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
replicasets: | ||
bbbbbbbb-0000-0000-0000-000000000000: | ||
weight: 1 | ||
master: | ||
- bbbbbbbb-bbbb-0000-0000-000000000001 | ||
- bbbbbbbb-bbbb-0000-0000-000000000002 | ||
alias: unnamed | ||
roles: | ||
myrole-permanent: true | ||
vshard-storage: true | ||
vshard_group: default | ||
aaaaaaaa-0000-0000-0000-000000000000: | ||
master: | ||
- aaaaaaaa-aaaa-0000-0000-000000000001 | ||
weight: 0 | ||
roles: | ||
myrole-permanent: true | ||
vshard-router: true | ||
alias: unnamed | ||
servers: | ||
bbbbbbbb-bbbb-0000-0000-000000000002: | ||
disabled: false | ||
replicaset_uuid: bbbbbbbb-0000-0000-0000-000000000000 | ||
uri: localhost:13305 | ||
bbbbbbbb-bbbb-0000-0000-000000000001: | ||
disabled: false | ||
replicaset_uuid: bbbbbbbb-0000-0000-0000-000000000000 | ||
uri: localhost:13303 | ||
aaaaaaaa-aaaa-0000-0000-000000000001: | ||
disabled: false | ||
replicaset_uuid: aaaaaaaa-0000-0000-0000-000000000000 | ||
uri: localhost:13301 | ||
failover: false | ||
... |
10 changes: 10 additions & 0 deletions
10
test/upgrade/test_master_replica/data/localhost-13305/config/vshard_groups.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
--- | ||
default: | ||
rebalancer_max_receiving: 100 | ||
bootstrapped: true | ||
collect_bucket_garbage_interval: 0.5 | ||
collect_lua_garbage: false | ||
sync_timeout: 1 | ||
bucket_count: 3000 | ||
rebalancer_disbalance_threshold: 1 | ||
... |
94 changes: 94 additions & 0 deletions
94
test/upgrade/test_master_replica/upgrade_master_replica_1_10_test.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
local fio = require('fio') | ||
local t = require('luatest') | ||
local g = t.group() | ||
|
||
local helpers = require('test.helper') | ||
|
||
g.before_all = function() | ||
local cwd = fio.cwd() | ||
local test_data_dir = fio.pathjoin(cwd, 'test/upgrade/test_master_replica/data') | ||
local datadir = fio.tempdir() | ||
local ok, err = fio.copytree(test_data_dir, datadir) | ||
assert(ok, err) | ||
|
||
local cookie = 'upgrade-1.10-2.2' | ||
|
||
g.cluster = helpers.Cluster:new({ | ||
datadir = datadir, | ||
server_command = helpers.entrypoint('srv_basic'), | ||
use_vshard = true, | ||
cookie = cookie, | ||
replicasets = { | ||
{ | ||
uuid = helpers.uuid('a'), | ||
roles = {'vshard-router'}, | ||
servers = { | ||
{ | ||
alias = 'router', | ||
instance_uuid = helpers.uuid('a', 'a', 1), | ||
advertise_port = 13301, | ||
env = { | ||
TARANTOOL_UPGRADE_SCHEMA = 'true', | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
uuid = helpers.uuid('b'), | ||
roles = {'vshard-storage'}, | ||
servers = { | ||
{ | ||
alias = 'storage-1', | ||
instance_uuid = helpers.uuid('b', 'b', 1), | ||
advertise_port = 13303, | ||
env = { | ||
TARANTOOL_UPGRADE_SCHEMA = 'true', | ||
}, | ||
}, { | ||
alias = 'storage-2', | ||
instance_uuid = helpers.uuid('b', 'b', 2), | ||
advertise_port = 13305, | ||
env = { | ||
TARANTOOL_UPGRADE_SCHEMA = 'true', | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}) | ||
-- We start cluster from existing 1.10 snapshots | ||
-- with schema version {'1', '10', '2'} | ||
g.cluster.bootstrapped = true | ||
g.cluster:start() | ||
end | ||
|
||
g.after_all = function() | ||
g.cluster:stop() | ||
fio.rmtree(g.cluster.datadir) | ||
end | ||
|
||
function g.test_upgrade() | ||
local tarantool_version = _G._TARANTOOL | ||
t.skip_if(tarantool_version < '2.0', 'Tarantool version should be greater 2.0') | ||
|
||
local schema_version_1 = g.cluster:server('storage-1').net_box.space._schema:get({'version'}) | ||
t.assert(schema_version_1[1] > '1', 'Schema version is upgraded to 2+') | ||
|
||
local schema_version_2 = g.cluster:server('storage-2').net_box.space._schema:get({'version'}) | ||
t.assert(schema_version_2[1] > '1', 'Schema version is upgraded to 2+') | ||
|
||
-- Test replication is not broken | ||
local storage_1 = g.cluster:server('storage-1').net_box | ||
local storage_2 = g.cluster:server('storage-2').net_box | ||
|
||
storage_1:eval([[ | ||
box.schema.space.create('test') | ||
box.space.test:create_index('pk') | ||
]]) | ||
|
||
local tuple = {1, 0.1, 'str', {a = 'a'}, {1, 2}} | ||
storage_1.space.test:insert(tuple) | ||
|
||
local storage2_tuple = storage_2:eval('return box.space.test:get({1})') | ||
t.assert_equals(storage2_tuple, tuple) | ||
end |