Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: tests

on:
push:
pull_request:
workflow_dispatch:

jobs:
linux:
# We want to run on external PRs, but not on our own internal
# PRs as they'll be run by the push to the branch.
#
# The main trick is described here:
# https://github.com/Dart-Code/Dart-Code/pull/2375
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository

strategy:
fail-fast: false
matrix:
tarantool:
- '1.10'
- '2.8'
coveralls: [false]
include:
- tarantool: '2.11'
coveralls: true

runs-on: ubuntu-20.04
steps:
- name: Install tarantool ${{ matrix.tarantool }}
uses: tarantool/setup-tarantool@v2
with:
tarantool-version: ${{ matrix.tarantool }}

- name: Clone the module
uses: actions/checkout@v3

- name: Install requirements
run: make deps

- name: Run linter
run: make lint

- name: Run tests
run: make test

- name: Run tests with coverage
run: make coverage
if: ${{ matrix.coveralls }}

- name: Send code coverage to coveralls.io
run: .rocks/bin/luacov-coveralls -i sharded_queue
if: ${{ matrix.coveralls }}
env:
COVERALLS_REPO_TOKEN: ${{ github.token }}
57 changes: 0 additions & 57 deletions .gitlab-ci.yml

This file was deleted.

63 changes: 50 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,25 +1,62 @@
#! /bin/bash
# This way everything works as expected ever for
# `make -C /path/to/project` or
# `make -f /path/to/project/Makefile`.
MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
PROJECT_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
LUACOV_REPORT := $(PROJECT_DIR)/luacov.report.out

.PHONY: all doc
all: doc
mkdir -p doc
# Look for .rocks/bin directories upward starting from the project
# directory.
#
# It is useful for luacheck, luatest and LDoc.
#
# Note: The PROJECT_DIR holds a real path.
define ENABLE_ROCKS_BIN
$(if $(wildcard $1/.rocks/bin),
$(eval ROCKS_PATH := $(if $(ROCKS_PATH),$(ROCKS_PATH):,)$1/.rocks/bin)
)
$(if $1,
$(eval $(call ENABLE_ROCKS_BIN,$(patsubst %/,%,$(dir $1))))
)
endef
$(eval $(call ENABLE_ROCKS_BIN,$(PROJECT_DIR)))

.PHONY: bootstrap
bootstrap:
tarantoolctl rocks install luacheck 0.25.0
tarantoolctl rocks install luatest 0.5.0
tarantoolctl rocks install luacov 0.13.0
# Add found .rocks/bin to PATH.
PATH := $(if $(ROCKS_PATH),$(ROCKS_PATH):$(PATH),$(PATH))

TTCTL := tt
ifeq (,$(shell which tt 2>/dev/null))
TTCTL := tarantoolctl
endif

.PHONY: default
default:
false

.PHONY: build
build:
cartridge build

.PHONY: deps
deps:
$(TTCTL) rocks install luacheck 0.26.0
$(TTCTL) rocks install luacov 0.13.0
$(TTCTL) rocks install luacov-coveralls 0.2.3-1 --server=http://luarocks.org
$(TTCTL) rocks install luatest 0.5.7
$(TTCTL) rocks install cartridge 2.7.9

.PHONY: lint
lint:
.rocks/bin/luacheck .
luacheck .

.PHONY: test
test: lint
test:
luatest -v --shuffle all

.PHONY: coverage
coverage:
rm -f luacov*
.rocks/bin/luatest -v --shuffle all --coverage
.rocks/bin/luacov . && grep -A999 '^Summary' luacov.report.out
luatest -v --shuffle all --coverage
sed "s|$(PROJECT_DIR)/||" -i luacov.stats.out
luacov sharded_queue
grep -A999 '^Summary' $(LUACOV_REPORT)
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ rm -rf ./tmp
Say:

```
make bootstrap
make deps
make test
```

Expand All @@ -116,7 +116,7 @@ make test
Examples:

```lua
conn:call('queue.create_tube', { mytube, {
conn:call('queue.create_tube', { mytube, {
log_request = true, -- log all operations
}})

Expand Down
8 changes: 0 additions & 8 deletions deps.sh

This file was deleted.

14 changes: 14 additions & 0 deletions test/entrypoint/init.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env tarantool

local cartridge = require('cartridge')

local ok, err = cartridge.cfg({
bucket_count = 3000,
roles = {
'sharded_queue.storage',
'sharded_queue.api'
},
}, {
})

assert(ok, tostring(err))
20 changes: 13 additions & 7 deletions test/helper/config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ config.unitdir = fio.pathjoin(config.datadir, 'unit')

config.cluster = cartridge_helpers.Cluster:new({
datadir = config.datadir,
server_command = fio.pathjoin(config.root, 'init.lua'),
server_command = fio.pathjoin(config.root, 'test', 'entrypoint', 'init.lua'),
use_vshard = true,
replicasets = {
{
Expand All @@ -24,13 +24,15 @@ config.cluster = cartridge_helpers.Cluster:new({
{
instance_uuid = 'aaaaaaaa-aaaa-4000-b000-000000000001',
alias = 'queue-router',
advertise_port = 3301,
advertise_port = 3311,
http_port = 9081,
cluster_cookie = 'sharded-queue-cookie',
},
{
instance_uuid = 'aaaaaaaa-aaaa-4000-b000-000000000002',
alias = 'queue-router-1',
advertise_port = 3302,
advertise_port = 3312,
http_port = 9082,
cluster_cookie = 'sharded-queue-cookie',
}
},
Expand All @@ -44,13 +46,15 @@ config.cluster = cartridge_helpers.Cluster:new({
{
instance_uuid = 'bbbbbbbb-bbbb-4000-b000-000000000001',
alias = 'queue-storage-1-0',
advertise_port = 3303,
advertise_port = 3313,
http_port = 9083,
cluster_cookie = 'sharded-queue-cookie',
},
{
instance_uuid = 'bbbbbbbb-bbbb-4000-b000-000000000002',
alias = 'queue-storage-1-1',
advertise_port = 3304,
advertise_port = 3314,
http_port = 9084,
cluster_cookie = 'sharded-queue-cookie',
},
}
Expand All @@ -62,13 +66,15 @@ config.cluster = cartridge_helpers.Cluster:new({
{
instance_uuid = 'cccccccc-cccc-4000-b000-000000000001',
alias = 'queue-storage-2-0',
advertise_port = 3305,
advertise_port = 3315,
http_port = 9085,
cluster_cookie = 'sharded-queue-cookie',
},
{
instance_uuid = 'cccccccc-cccc-4000-b000-000000000002',
alias = 'queue-storage-2-1',
advertise_port = 3306,
advertise_port = 3316,
http_port = 9086,
cluster_cookie = 'sharded-queue-cookie',
},
},
Expand Down
2 changes: 1 addition & 1 deletion test/statistics_test.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ function g.test_statistics()
t.assert_equals(cur_stat.tasks.delayed, task_count)
t.assert_equals(cur_stat.calls.put, task_count)

fiber.sleep(3.01)
fiber.sleep(3.5)

-- after delay
cur_stat = g.queue_conn:call('queue.statistics', { tube_name })
Expand Down
Loading