Skip to content

Commit 69b5862

Browse files
committed
test: support tests with vshard
The patch updates all tests to work with `vshard` and `cartridge` in 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 dd79bf2 commit 69b5862

File tree

75 files changed

+3680
-1900
lines changed

Some content is hidden

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

75 files changed

+3680
-1900
lines changed

.github/workflows/test_on_push.yaml

Lines changed: 98 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ jobs:
3434
coveralls: true
3535
metrics-version: "1.0.0"
3636
cartridge-version: "2.8.0"
37+
- tarantool-version: "2.11"
38+
metrics-version: "1.0.0"
39+
vshard-version: "0.1.24"
40+
- tarantool-version: "master"
41+
metrics-version: "1.0.0"
42+
vshard-version: "0.1.24"
3743
fail-fast: false
3844
# Can't install older versions on 22.04,
3945
# see https://github.com/tarantool/setup-tarantool/issues/36
@@ -42,10 +48,42 @@ jobs:
4248
- uses: actions/checkout@master
4349

4450
- name: Setup Tarantool CE
51+
if: matrix.tarantool-version != 'master'
4552
uses: tarantool/setup-tarantool@v2
4653
with:
4754
tarantool-version: ${{ matrix.tarantool-version }}
4855

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

61-
- name: Install metrics
62-
if: matrix.metrics-version != ''
100+
# There is unable to install metrics with tt for Tarantool 2.11
101+
- name: Install metrics with tarantoolctl
102+
if: matrix.metrics-version != '' && matrix.tarantool-version == '2.11'
63103
run: tarantoolctl rocks install metrics ${{ matrix.metrics-version }}
64104

105+
- name: Install metrics with tt
106+
if: matrix.metrics-version != '' && matrix.tarantool-version != '2.11'
107+
run: tt rocks install metrics ${{ matrix.metrics-version }}
108+
65109
- name: Remove external merger if needed
66110
if: ${{ matrix.remove-merger }}
67111
run: rm .rocks/lib/tarantool/tuple/merger.so
@@ -90,24 +134,70 @@ jobs:
90134
matrix:
91135
tarantool-version: ["1.10", "2.11"]
92136
metrics-version: ["1.0.0"]
137+
cartridge-version: ["2.8.0"]
138+
include:
139+
- tarantool-version: "master"
140+
metrics-version: "1.0.0"
141+
vshard-version: "0.1.24"
93142
fail-fast: false
94143
runs-on: ubuntu-20.04
95144
steps:
96145
- uses: actions/checkout@master
97146

98147
- name: Setup Tarantool CE
148+
if: matrix.tarantool-version != 'master'
99149
uses: tarantool/setup-tarantool@v2
100150
with:
101151
tarantool-version: ${{ matrix.tarantool-version }}
102152

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

108-
- name: Install metrics
192+
# There is unable to install metrics with tt for Tarantool 2.11
193+
- name: Install metrics with tarantoolctl
194+
if: matrix.metrics-version != '' && matrix.tarantool-version == '2.11'
109195
run: tarantoolctl rocks install metrics ${{ matrix.metrics-version }}
110196

197+
- name: Install metrics with tt
198+
if: matrix.metrics-version != '' && matrix.tarantool-version != '2.11'
199+
run: tt rocks install metrics ${{ matrix.metrics-version }}
200+
111201
# This server starts and listen on 8084 port that is used for tests
112202
- name: Stop Mono server
113203
run: sudo kill -9 $(sudo lsof -t -i tcp:8084) || true
@@ -127,6 +217,7 @@ jobs:
127217
- folder: "2.11"
128218
bundle: "tarantool-enterprise-sdk-nogc64-2.11.0-0-r563.linux.x86_64"
129219
metrics-version: ["", "1.0.0"]
220+
cartridge-version: ["2.8.0"]
130221
fail-fast: false
131222
runs-on: ubuntu-20.04
132223
steps:
@@ -138,9 +229,13 @@ jobs:
138229
tar -xzf ${{ matrix.tarantool-version.bundle }}.tar.gz
139230
rm -f ${{ matrix.tarantool-version.bundle }}.tar.gz
140231
sudo cp tarantool-enterprise/tarantool /usr/bin/tarantool
232+
sudo rm tarantool-enterprise/tt
141233
source tarantool-enterprise/env.sh
142234
tarantool --version
143235
./deps.sh
236+
env:
237+
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
238+
VSHARD_VERSION: ${{ matrix.vshard-version }}
144239

145240
- name: Install metrics
146241
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: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,30 @@
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+
echo $TTCTL
17+
618
# Test dependencies:
7-
tarantoolctl rocks install luatest
8-
tarantoolctl rocks install luacheck 0.25.0
9-
tarantoolctl rocks install luacov 0.13.0
19+
$TTCTL rocks install luatest
20+
$TTCTL rocks install luacheck 0.25.0
21+
$TTCTL rocks install luacov 0.13.0
1022

1123
# 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
24+
$TTCTL rocks install https://raw.githubusercontent.com/mpeterv/cluacov/master/cluacov-scm-1.rockspec
25+
$TTCTL rocks install https://raw.githubusercontent.com/LuaDist/dkjson/master/dkjson-2.5-2.rockspec
26+
$TTCTL rocks install https://raw.githubusercontent.com/keplerproject/luafilesystem/master/luafilesystem-scm-1.rockspec
27+
$TTCTL rocks install https://raw.githubusercontent.com/moteus/lua-path/master/rockspecs/lua-path-scm-0.rockspec
1628

1729
# Most of this code is the workaround for
1830
# https://github.com/moteus/luacov-coveralls/pull/30
@@ -22,14 +34,19 @@ LUACOV_COVERALLS_ROCKSPEC_URL="https://raw.githubusercontent.com/moteus/luacov-c
2234
LUACOV_COVERALLS_ROCKSPEC_FILE="${TMPDIR}/luacov-coveralls-scm-0.rockspec"
2335
curl -fsSL "${LUACOV_COVERALLS_ROCKSPEC_URL}" > "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
2436
sed -i -e 's@git://@git+https://@' "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
25-
tarantoolctl rocks install "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
37+
$TTCTL rocks install "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
2638
rm "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
2739
rmdir "${TMPDIR}"
2840

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

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

35-
tarantoolctl rocks make
52+
$TTCTL rocks make
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
return function()
2+
if box.info.ro == true then
3+
return
4+
end
5+
6+
local engine = os.getenv('ENGINE') or 'memtx'
7+
local customers_space = box.schema.space.create('customers', {
8+
format = {
9+
{name = 'id', type = 'unsigned'},
10+
{name = 'bucket_id', type = 'unsigned'},
11+
{name = 'name', type = 'string'},
12+
{name = 'age', type = 'number'},
13+
},
14+
if_not_exists = true,
15+
engine = engine,
16+
})
17+
customers_space:create_index('id', {
18+
parts = { {field = 'id'} },
19+
if_not_exists = true,
20+
})
21+
customers_space:create_index('bucket_id', {
22+
parts = { {field = 'bucket_id'} },
23+
unique = false,
24+
if_not_exists = true,
25+
})
26+
27+
local developers_space = box.schema.space.create('developers', {
28+
format = {
29+
{name = 'id', type = 'unsigned'},
30+
{name = 'bucket_id', type = 'unsigned'},
31+
{name = 'name', type = 'string'},
32+
{name = 'login', type = 'string'},
33+
},
34+
if_not_exists = true,
35+
engine = engine,
36+
})
37+
developers_space:create_index('id', {
38+
parts = { {field = 'id'} },
39+
if_not_exists = true,
40+
})
41+
developers_space:create_index('bucket_id', {
42+
parts = { {field = 'bucket_id'} },
43+
unique = false,
44+
if_not_exists = true,
45+
})
46+
developers_space:create_index('login', {
47+
parts = { {field = 'login'} },
48+
unique = true,
49+
if_not_exists = true,
50+
})
51+
end

0 commit comments

Comments
 (0)