Skip to content

Commit

Permalink
Added test for check hotreload.
Browse files Browse the repository at this point in the history
Also, also added some comments and removed duplicate code
  • Loading branch information
ArtDu committed May 14, 2021
1 parent 29d1a25 commit 9087d91
Show file tree
Hide file tree
Showing 20 changed files with 232 additions and 371 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/test_on_push.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Run tests

on:
push:
pull_request:

jobs:
run-tests-ce:
if: |
github.event_name == 'push' ||
github.event_name == 'pull_request' && github.event.pull_request.head.repo.owner.login != 'tarantool'
strategy:
matrix:
tarantool-version: ["1.10", "2.2", "2.3", "2.4", "2.5", "2.6", "2.7"]
fail-fast: false
runs-on: [ubuntu-latest]
steps:
- uses: actions/checkout@master

- name: Install requirements for community
run: |
curl -L https://tarantool.io/installer.sh | sudo VER=${{ matrix.tarantool-version }} bash
sudo apt install -y tarantool-dev
tarantool --version
./deps.sh
# 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

# - name: Run linter
# run: .rocks/bin/luacheck .

- name: Run luatest tests
run: .rocks/bin/luatest -v

- name: Run tap tests
run: make test

175 changes: 0 additions & 175 deletions .travis.yml

This file was deleted.

8 changes: 0 additions & 8 deletions Jenkinsfile

This file was deleted.

5 changes: 0 additions & 5 deletions debian/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions debian/changelog

This file was deleted.

1 change: 0 additions & 1 deletion debian/compat

This file was deleted.

25 changes: 0 additions & 25 deletions debian/control

This file was deleted.

29 changes: 0 additions & 29 deletions debian/copyright

This file was deleted.

1 change: 0 additions & 1 deletion debian/docs

This file was deleted.

4 changes: 0 additions & 4 deletions debian/rules

This file was deleted.

1 change: 0 additions & 1 deletion debian/source/format

This file was deleted.

1 change: 0 additions & 1 deletion debian/tarantool-expirationd.install

This file was deleted.

10 changes: 10 additions & 0 deletions deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/sh
# Call this script to install test dependencies

set -e

# Test dependencies:
tarantoolctl rocks install luatest 0.5.0
tarantoolctl rocks install luacheck 0.25.0

tarantoolctl rocks install cartridge 2.5.1
14 changes: 9 additions & 5 deletions expirationd.lua
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ local constants = {
-- Task fibers
-- ------------------------------------------------------------------------- --

-- get all fields in primary key(composite possible) from tuple
local function construct_key(space_id, tuple)
return fun.map(
function(x) return tuple[x.fieldno] end,
box.space[space_id].index[0].parts
):totable()
end

-- do expiration process on tuple
local function expiration_process(task, tuple)
task.checked_tuples_count = task.checked_tuples_count + 1
if task.is_tuple_expired(task.args, tuple) then
Expand All @@ -71,19 +73,22 @@ local function expiration_process(task, tuple)
end
end

-- stop for some time
local function suspend_basic(scan_space, task, len)
local delay = (task.tuples_per_iteration * task.full_scan_time)
delay = math.min(delay / len, task.iteration_delay)
fiber.sleep(delay)
end

local function suspend(scan_space, task)
-- Return the number of tuples in the space
local space_len = scan_space:len()
if space_len > 0 then
suspend_basic(scan_space, task, space_len)
end
end

-- delete with some suspend and some tuples limit
local function tree_index_iter(scan_space, task)
-- iteration with GT iterator
local params = {iterator = 'GT', limit = task.tuples_per_iteration}
Expand All @@ -96,6 +101,7 @@ local function tree_index_iter(scan_space, task)
end
suspend(scan_space, task)
local key = construct_key(scan_space.id, last_id)
-- select all greater then last key
tuples = scan_space.index[0]:select(key, params)
end

Expand Down Expand Up @@ -186,6 +192,7 @@ local function guardian_loop(task)
fiber.name(string.format("guardian of %q", task.name), { truncate = true })

while true do
-- if fiber doesn't exist
if get_fiber_id(task.worker_fiber) == 0 then
-- create worker fiber
task.worker_fiber = fiber.create(worker_loop, task)
Expand All @@ -205,7 +212,7 @@ end
-- * task:start() -- start task
-- * task:stop() -- stop task
-- * task:restart() -- restart task
-- * task:kill() -- delete task and restart
-- * task:kill() -- stop task and delete
-- * task:statistics() -- return table with statistics
local Task_methods = {
start = function (self)
Expand Down Expand Up @@ -502,10 +509,7 @@ local function expirationd_task_stats(name)
return retval
end

-- kill task
local function expirationd_kill_task(name)
return get_task(name):kill()
end


-- get task by name
local function expirationd_get_task(name)
Expand Down
Loading

0 comments on commit 9087d91

Please sign in to comment.