Skip to content

Commit bbc9b39

Browse files
committed
Added minio uploader + tests for 1_6/1_7/1_8
1 parent ff32f24 commit bbc9b39

File tree

5 files changed

+148
-23
lines changed

5 files changed

+148
-23
lines changed

.travis.yml

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,32 @@ env:
1111
global:
1212
- PRODUCT=tarantool-expirationd
1313
matrix:
14+
- TARGET=test VERSION=1_6
15+
- TARGET=test VERSION=1_7
16+
- TARGET=test VERSION=1_8
1417
- OS=el DIST=6
1518
- OS=el DIST=7
16-
- OS=fedora DIST=24
1719
- OS=fedora DIST=25
20+
- OS=fedora DIST=26
1821
- OS=ubuntu DIST=precise
1922
- OS=ubuntu DIST=trusty
2023
- OS=ubuntu DIST=xenial
2124
- OS=ubuntu DIST=yakkety
25+
- OS=ubuntu DIST=zesty
26+
- OS=ubuntu DIST=artful
2227
- OS=debian DIST=wheezy
2328
- OS=debian DIST=jessie
2429
- OS=debian DIST=stretch
2530

26-
2731
script:
2832
- git describe --long
29-
- git clone https://github.com/packpack/packpack.git packpack
30-
- packpack/packpack
33+
- |
34+
if [ "${TARGET}" = "test" ]; then
35+
./test.sh;
36+
else
37+
git clone https://github.com/packpack/packpack.git packpack;
38+
packpack/packpack;
39+
fi;
3140
3241
before_deploy:
3342
- ls -l build/
@@ -43,7 +52,7 @@ deploy:
4352
skip_cleanup: true
4453
on:
4554
branch: master
46-
condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}"
55+
condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" && "${TRAVIS_EVENT_TYPE}" != 'cron'
4756
- provider: packagecloud
4857
username: tarantool
4958
repository: "1_7"
@@ -53,7 +62,7 @@ deploy:
5362
skip_cleanup: true
5463
on:
5564
branch: master
56-
condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}"
65+
condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" && "${TRAVIS_EVENT_TYPE}" != 'cron'
5766
- provider: packagecloud
5867
username: tarantool
5968
repository: "1_8"
@@ -63,7 +72,13 @@ deploy:
6372
skip_cleanup: true
6473
on:
6574
branch: master
66-
condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}"
75+
condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" && "${TRAVIS_EVENT_TYPE}" != 'cron'
76+
# Archive packages
77+
# - provider: script
78+
# script: ./travis-archive.sh modules
79+
# on:
80+
# branch: master
81+
# condition: -n "${OS}" && -n "${DIST}" && -n "${PACKAGECLOUD_TOKEN}" && "${TRAVIS_EVENT_TYPE}" != 'cron'
6782

6883
notifications:
6984
email:

expirationd.lua

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,9 +451,16 @@ end
451451
-- * restart all tasks
452452
local function expirationd_update()
453453
local expd_prev = require('expirationd')
454+
table.clear(expd_prev)
455+
setmetatable(expd_prev, {
456+
__index = function(name)
457+
error("Wait until update is done before using expirationd", 2)
458+
end
459+
})
454460
package.loaded['expirationd'] = nil
455461
local expd_new = require('expirationd')
456-
for name, task in pairs(task_list) do
462+
local tmp_task_list = task_list; task_list = {}
463+
for name, task in pairs(tmp_task_list) do
457464
task:kill()
458465
expd_new.start(
459466
task.name, task.space_id,
@@ -464,6 +471,12 @@ local function expirationd_update()
464471
}
465472
)
466473
end
474+
-- update old function table to represent new reloaded expirationd
475+
-- some kind of dirty hack if user forgot to require new expirationd
476+
setmetatable(expd_prev, nil)
477+
for name, func in pairs(expd_new) do
478+
expd_prev[name] = func
479+
end
467480
end
468481

469482
return {

test.lua

Lines changed: 42 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
local fun = require('fun')
44
local log = require('log')
55
local tap = require('tap')
6+
local yaml = require('yaml')
67
local fiber = require('fiber')
78
local strict = require('strict')
89
local expirationd = require('expirationd')
@@ -50,6 +51,14 @@ end
5051
-- Expiration handlers examples
5152
-- ========================================================================= --
5253

54+
local function len(arg)
55+
local len = 0
56+
for k, v in pairs(arg) do
57+
len = len + 1
58+
end
59+
return len
60+
end
61+
5362
-- check tuple's expiration by timestamp (stored in last field)
5463
local function check_tuple_expire_by_timestamp(args, tuple)
5564
local tuple_expire_time = get_field(tuple, args.field_no)
@@ -443,26 +452,40 @@ test:test("default drop function test", function(test)
443452
end)
444453

445454
test:test("restart test", function(test)
446-
test:plan(3)
455+
test:plan(5)
447456
local tuples_count = 10
448457
local space_name = 'restart_test'
449458
local space = box.space[space_name]
450459

451-
local task = expirationd.run_task(
452-
"test",
453-
space_name,
454-
check_tuple_expire_by_timestamp,
455-
nil,
456-
{
457-
field_no = 3,
458-
archive_space_id = archive_space_id
459-
},
460-
10,
461-
1
460+
local task1 = expirationd.run_task(
461+
"test1", space_name, check_tuple_expire_by_timestamp,
462+
nil, { field_no = 3, archive_space_id = archive_space_id }, 10, 1
463+
)
464+
local task2 = expirationd.run_task(
465+
"test2", space_name, check_tuple_expire_by_timestamp,
466+
nil, { field_no = 3, archive_space_id = archive_space_id }, 10, 1
467+
)
468+
local task3 = expirationd.run_task(
469+
"test3", space_name, check_tuple_expire_by_timestamp,
470+
nil, { field_no = 3, archive_space_id = archive_space_id }, 10, 1
471+
)
472+
local task4 = expirationd.run_task(
473+
"test4", space_name, check_tuple_expire_by_timestamp,
474+
nil, { field_no = 3, archive_space_id = archive_space_id }, 10, 1
462475
)
463476

477+
local fiber_cnt = len(fiber.info())
464478
local old_expd = expirationd
465-
expirationd.update()
479+
480+
local chan = fiber.channel(1)
481+
local fiber_update = fiber.create(function()
482+
expirationd.update()
483+
chan:put(1)
484+
end)
485+
local ok, err = pcall(function() expirationd.start() end)
486+
test:like(err, ".*Wait until update is done.*", "error while reloading")
487+
chan:get()
488+
466489
for i = 1, tuples_count do
467490
space:insert{i, 'test_data', fiber.time() + 1}
468491
end
@@ -476,9 +499,13 @@ test:test("restart test", function(test)
476499
fiber.sleep(4)
477500
test:is(space:count{}, 0, 'all tuples are expired')
478501

479-
task:statistics()
502+
task1:statistics()
503+
test:is(fiber_cnt, len(fiber.info()), "check for absence of ghost fibers")
480504

481-
expirationd.kill_task("test")
505+
expirationd.kill_task("test1")
506+
expirationd.kill_task("test2")
507+
expirationd.kill_task("test3")
508+
expirationd.kill_task("test4")
482509
end)
483510

484511
test:test("complex key test", function(test)

test.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
VERSION=${VERSION:-1_6}
2+
3+
curl https://packagecloud.io/tarantool/${VERSION}/gpgkey | sudo apt-key add -
4+
release=`lsb_release -c -s`
5+
6+
sudo apt-get install -y apt-transport-https
7+
8+
sudo tee /etc/apt/sources.list.d/tarantool_${VERSION}.list <<- EOF
9+
deb https://packagecloud.io/tarantool/${VERSION}/ubuntu/ $release main
10+
deb-src https://packagecloud.io/tarantool/${VERSION}/ubuntu/ $release main
11+
EOF
12+
13+
sudo apt-get update > /dev/null
14+
sudo apt-get -q -y install tarantool --force-yes
15+
make test

travis-archive.bash

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
BIN_DIR="${HOME}/.cache/bin"
2+
MINIO_CLIENT="${BIN_DIR}/mc"
3+
4+
START_TIME=`date +%s`
5+
6+
if [[ -n "${OS}" && -n "${DIST}" ]]; then
7+
echo "Uploader: build data isn't found, skipping"
8+
exit 0
9+
fi
10+
11+
if [[ ! -x "${MINIO_CLIENT}" ]]; then
12+
echo "Uploader: couldn't find minio client - downloading"
13+
mkdir -p "${BIN_DIR}"
14+
rm -rf "${MINIO_CLIENT}"
15+
wget https://dl.minio.io/server/minio/release/linux-amd64/minio -O ${MINIO_CLIENT}
16+
chmod +x ${MINIO_CLIENT}
17+
fi
18+
19+
${MINIO_CLIENT} config host add tarantool-s3 http://s3.tarantool.org ${S3_ACCESS_KEY} ${S3_SECRET_KEY}
20+
21+
DEB_DST="tarantool-s3/archive/${OS}/${DIST}/os/x86_64/"
22+
RPM_DST="tarantool-s3/archive/${OS}/pool/main/${PROJECT}"
23+
24+
COUNT=0
25+
26+
for fullname in "$@"; do
27+
PACKAGE_NAME=`basename "$fullname"`
28+
PACKAGE_EXTENSION="${filename##*.}"
29+
echo -n "Uploader: uploading file $fullname "
30+
31+
case "${OS}" in
32+
"el") ;;
33+
"fedora")
34+
echo "to ${DEB_DST}"
35+
${MINIO_CLIENT} mb ${DEB_DST}
36+
${MINIO_CLIENT} cp $fullname ${DEB_DST}
37+
;&
38+
"ubuntu") ;;
39+
"debian")
40+
echo "to ${RPM_DST}"
41+
${MINIO_CLIENT} mb ${RPM_DST}
42+
${MINIO_CLIENT} cp $fullname ${RPM_DST}
43+
;&
44+
*)
45+
echo
46+
echo "Uploader: unknown OS '${OS}'"
47+
exit 1
48+
;;
49+
esac
50+
COUNT=$((COUNT+1))
51+
done
52+
53+
RUN_TIME=$((START_TIME-`date +%s`))
54+
55+
echo "Finished uploading $COUNT in ${RUN_TIME} sec"

0 commit comments

Comments
 (0)