Skip to content

Commit 26bfdc9

Browse files
oleg-jukovecDifferentialOrange
authored andcommitted
test: support tests with vshard
The patch updates all tests to work with `vshard` and `cartridge` at the same time. But tests of the `cartridge` role of the cartridge or special features are skipping for `vshard`. If `cartridge` is not installed or not supported (Tarantool 3.0+), tests will run only with `vshard`. The source of `vshard_helpers` folder is `vshard` repository [1] with minor modifications. 1. https://github.com/tarantool/vshard/tree/b3c27b32637863e9a03503e641bb7c8c69779a00/test/luatest_helpers Closes #364
1 parent d1faa80 commit 26bfdc9

File tree

77 files changed

+3734
-1986
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+3734
-1986
lines changed

.github/workflows/test_on_push.yaml

Lines changed: 93 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@ jobs:
1313
matrix:
1414
# We need 1.10.6 here to check that module works with
1515
# old Tarantool versions that don't have "tuple-keydef"/"tuple-merger" support.
16+
# We test old metrics with Tarantool 2.10 because since Tarantool 2.11.1
17+
# it uses its own metrics package.
18+
# We test old metrics with Cartridge 2.7.9 because since 2.8.0 it
19+
# requires metrics 1.0.0.
1620
tarantool-version: ["1.10.6", "1.10", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7", "2.8", "2.10", "2.11"]
1721
metrics-version: [""]
1822
cartridge-version: ["2.8.0"]
@@ -24,16 +28,19 @@ jobs:
2428
- tarantool-version: "2.7"
2529
remove-merger: true
2630
cartridge-version: "2.8.0"
27-
- tarantool-version: "2.11"
28-
metrics-version: "0.1.8"
29-
cartridge-version: "2.8.0"
30-
- tarantool-version: "2.11"
31+
- tarantool-version: "2.10"
3132
metrics-version: "0.10.0"
32-
cartridge-version: "2.8.0"
33+
cartridge-version: "2.7.9"
3334
- tarantool-version: "2.11"
3435
coveralls: true
3536
metrics-version: "1.0.0"
3637
cartridge-version: "2.8.0"
38+
- tarantool-version: "2.11"
39+
metrics-version: "1.0.0"
40+
vshard-version: "0.1.24"
41+
- tarantool-version: "master"
42+
metrics-version: "1.0.0"
43+
vshard-version: "0.1.24"
3744
fail-fast: false
3845
# Can't install older versions on 22.04,
3946
# see https://github.com/tarantool/setup-tarantool/issues/36
@@ -42,10 +49,42 @@ jobs:
4249
- uses: actions/checkout@master
4350

4451
- name: Setup Tarantool CE
52+
if: matrix.tarantool-version != 'master'
4553
uses: tarantool/setup-tarantool@v2
4654
with:
4755
tarantool-version: ${{ matrix.tarantool-version }}
4856

57+
- name: Setup tt
58+
run: |
59+
curl -L https://tarantool.io/release/2/installer.sh | sudo bash
60+
sudo apt install -y tt
61+
tt version
62+
63+
- name: Get Tarantool master latest commit
64+
if: matrix.tarantool-version == 'master'
65+
run: |
66+
commit_hash=$(git ls-remote https://github.com/tarantool/tarantool.git --branch master | head -c 8)
67+
echo "LATEST_COMMIT=${commit_hash}" >> $GITHUB_ENV
68+
shell: bash
69+
70+
- name: Cache Tarantool master
71+
if: matrix.tarantool-version == 'master'
72+
id: cache-latest
73+
uses: actions/cache@v3
74+
with:
75+
path: "${GITHUB_WORKSPACE}/bin"
76+
key: cache-latest-${{ env.LATEST_COMMIT }}
77+
78+
- name: Setup Tarantool master
79+
if: matrix.tarantool-version == 'master' && steps.cache-latest.outputs.cache-hit != 'true'
80+
run: |
81+
tt init
82+
tt install tarantool master
83+
84+
- name: Add Tarantool master to PATH
85+
if: matrix.tarantool-version == 'master'
86+
run: echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
87+
4988
- name: Fix luarocks in Tarantool CE 1.10.6
5089
if: matrix.tarantool-version == '1.10.6'
5190
run: |
@@ -57,10 +96,11 @@ jobs:
5796
./deps.sh
5897
env:
5998
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
99+
VSHARD_VERSION: ${{ matrix.vshard-version }}
60100

61101
- name: Install metrics
62102
if: matrix.metrics-version != ''
63-
run: tarantoolctl rocks install metrics ${{ matrix.metrics-version }}
103+
run: tt rocks install metrics ${{ matrix.metrics-version }}
64104

65105
- name: Remove external merger if needed
66106
if: ${{ matrix.remove-merger }}
@@ -90,23 +130,64 @@ jobs:
90130
matrix:
91131
tarantool-version: ["1.10", "2.11"]
92132
metrics-version: ["1.0.0"]
133+
cartridge-version: ["2.8.0"]
134+
include:
135+
- tarantool-version: "master"
136+
metrics-version: "1.0.0"
137+
vshard-version: "0.1.24"
93138
fail-fast: false
94139
runs-on: ubuntu-20.04
95140
steps:
96141
- uses: actions/checkout@master
97142

98143
- name: Setup Tarantool CE
144+
if: matrix.tarantool-version != 'master'
99145
uses: tarantool/setup-tarantool@v2
100146
with:
101147
tarantool-version: ${{ matrix.tarantool-version }}
102148

149+
- name: Setup tt
150+
run: |
151+
curl -L https://tarantool.io/release/2/installer.sh | sudo bash
152+
sudo apt install -y tt
153+
tt version
154+
155+
- name: Get Tarantool master latest commit
156+
if: matrix.tarantool-version == 'master'
157+
run: |
158+
commit_hash=$(git ls-remote https://github.com/tarantool/tarantool.git --branch master | head -c 8)
159+
echo "LATEST_COMMIT=${commit_hash}" >> $GITHUB_ENV
160+
shell: bash
161+
162+
- name: Cache Tarantool master
163+
if: matrix.tarantool-version == 'master'
164+
id: cache-latest
165+
uses: actions/cache@v3
166+
with:
167+
path: "${GITHUB_WORKSPACE}/bin"
168+
key: cache-latest-${{ env.LATEST_COMMIT }}
169+
170+
- name: Setup Tarantool master
171+
if: matrix.tarantool-version == 'master' && steps.cache-latest.outputs.cache-hit != 'true'
172+
run: |
173+
tt init
174+
tt install tarantool master
175+
176+
- name: Add Tarantool master to PATH
177+
if: matrix.tarantool-version == 'master'
178+
run: echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH
179+
103180
- name: Install requirements for community
104181
run: |
105182
tarantool --version
106183
./deps.sh
184+
env:
185+
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
186+
VSHARD_VERSION: ${{ matrix.vshard-version }}
107187

108188
- name: Install metrics
109-
run: tarantoolctl rocks install metrics ${{ matrix.metrics-version }}
189+
if: matrix.metrics-version != ''
190+
run: tt rocks install metrics ${{ matrix.metrics-version }}
110191

111192
# This server starts and listen on 8084 port that is used for tests
112193
- name: Stop Mono server
@@ -127,6 +208,7 @@ jobs:
127208
- folder: "2.11"
128209
bundle: "tarantool-enterprise-sdk-nogc64-2.11.0-0-r563.linux.x86_64"
129210
metrics-version: ["", "1.0.0"]
211+
cartridge-version: ["2.8.0"]
130212
fail-fast: false
131213
runs-on: ubuntu-20.04
132214
steps:
@@ -138,9 +220,13 @@ jobs:
138220
tar -xzf ${{ matrix.tarantool-version.bundle }}.tar.gz
139221
rm -f ${{ matrix.tarantool-version.bundle }}.tar.gz
140222
sudo cp tarantool-enterprise/tarantool /usr/bin/tarantool
223+
sudo rm tarantool-enterprise/tt
141224
source tarantool-enterprise/env.sh
142225
tarantool --version
143226
./deps.sh
227+
env:
228+
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
229+
VSHARD_VERSION: ${{ matrix.vshard-version }}
144230

145231
- name: Install metrics
146232
if: matrix.metrics-version != ''

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
77

88
## Unreleased
99

10+
### Changed
11+
* `deps.sh` installs the `vshard` instead of the `cartridge` by default (#364).
12+
You could to specify an environment variable `CARTIRDGE_VERSION` to install
13+
the `cartridge` and run tests cases with it.
14+
1015
### Fixed
1116
* `crud.readview` resource cleanup on garbage collect (#379).
1217
* `doc/playground.lua` does not work with Tarantool 3 (#371).
18+
* Tests with Tarantool 3 (#364).
1319

1420
## [1.3.0] - 27-09-23
1521

deps.sh

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,29 @@
1-
#!/bin/sh
1+
#!/usr/bin/env bash
22
# Call this script to install test dependencies
33

44
set -e
55

6+
TTCTL=tt
7+
if ! [ -x "$(command -v tt)" ];
8+
then
9+
if ! [ -x "$(command -v tarantoolctl)" ];
10+
then
11+
echo "tt or tarantoolctl not found"
12+
exit 1
13+
fi
14+
TTCTL=tarantoolctl
15+
fi
16+
617
# Test dependencies:
7-
tarantoolctl rocks install luatest
8-
tarantoolctl rocks install luacheck 0.25.0
9-
tarantoolctl rocks install luacov 0.13.0
18+
$TTCTL rocks install luatest
19+
$TTCTL rocks install luacheck 0.25.0
20+
$TTCTL rocks install luacov 0.13.0
1021

1122
# cluacov, luacov-coveralls and dependencies
12-
tarantoolctl rocks install https://raw.githubusercontent.com/mpeterv/cluacov/master/cluacov-scm-1.rockspec
13-
tarantoolctl rocks install https://raw.githubusercontent.com/LuaDist/dkjson/master/dkjson-2.5-2.rockspec
14-
tarantoolctl rocks install https://raw.githubusercontent.com/keplerproject/luafilesystem/master/luafilesystem-scm-1.rockspec
15-
tarantoolctl rocks install https://raw.githubusercontent.com/moteus/lua-path/master/rockspecs/lua-path-scm-0.rockspec
23+
$TTCTL rocks install https://raw.githubusercontent.com/mpeterv/cluacov/master/cluacov-scm-1.rockspec
24+
$TTCTL rocks install https://raw.githubusercontent.com/LuaDist/dkjson/master/dkjson-2.5-2.rockspec
25+
$TTCTL rocks install https://raw.githubusercontent.com/keplerproject/luafilesystem/master/luafilesystem-scm-1.rockspec
26+
$TTCTL rocks install https://raw.githubusercontent.com/moteus/lua-path/master/rockspecs/lua-path-scm-0.rockspec
1627

1728
# Most of this code is the workaround for
1829
# https://github.com/moteus/luacov-coveralls/pull/30
@@ -22,14 +33,19 @@ LUACOV_COVERALLS_ROCKSPEC_URL="https://raw.githubusercontent.com/moteus/luacov-c
2233
LUACOV_COVERALLS_ROCKSPEC_FILE="${TMPDIR}/luacov-coveralls-scm-0.rockspec"
2334
curl -fsSL "${LUACOV_COVERALLS_ROCKSPEC_URL}" > "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
2435
sed -i -e 's@git://@git+https://@' "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
25-
tarantoolctl rocks install "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
36+
$TTCTL rocks install "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
2637
rm "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
2738
rmdir "${TMPDIR}"
2839

29-
CARTRIDGE_VERSION="${CARTRIDGE_VERSION:-2.8.0}"
40+
if [[ -n "$CARTRIDGE_VERSION" ]]
41+
then
42+
$TTCTL rocks install cartridge "$CARTRIDGE_VERSION"
43+
$TTCTL rocks install migrations 0.4.2
44+
else
45+
VSHARD_VERSION="${VSHARD_VERSION:-0.1.24}"
46+
$TTCTL rocks install vshard "$VSHARD_VERSION"
47+
fi
3048

31-
tarantoolctl rocks install cartridge "$CARTRIDGE_VERSION"
32-
tarantoolctl rocks install ddl 1.6.2
33-
tarantoolctl rocks install migrations 0.4.2
49+
$TTCTL rocks install ddl 1.6.2
3450

35-
tarantoolctl rocks make
51+
$TTCTL rocks make

test/entrypoint/srv_batch_operations.lua

Lines changed: 0 additions & 79 deletions
This file was deleted.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env tarantool
2+
3+
require('strict').on()
4+
_G.is_initialized = function() return false end
5+
6+
local log = require('log')
7+
local errors = require('errors')
8+
local cartridge = require('cartridge')
9+
10+
if package.setsearchroot ~= nil then
11+
package.setsearchroot()
12+
else
13+
package.path = package.path .. debug.sourcedir() .. "/?.lua;"
14+
end
15+
16+
package.preload['customers-storage'] = function()
17+
return {
18+
role_name = 'customers-storage',
19+
init = require('storage_init'),
20+
}
21+
end
22+
23+
local ok, err = errors.pcall('CartridgeCfgError', cartridge.cfg, {
24+
advertise_uri = 'localhost:3301',
25+
http_port = 8081,
26+
bucket_count = 3000,
27+
roles = {
28+
'customers-storage',
29+
'cartridge.roles.crud-router',
30+
'cartridge.roles.crud-storage',
31+
},
32+
})
33+
34+
if not ok then
35+
log.error('%s', err)
36+
os.exit(1)
37+
end
38+
39+
_G.is_initialized = cartridge.is_healthy

0 commit comments

Comments
 (0)