Compare commits
5
Commits
mm-psync
...
alpine_fixes
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4a676ba7d | ||
|
|
fd3f7f44dc | ||
|
|
4e12f26bf6 | ||
|
|
365a0076c0 | ||
|
|
1f0a08b7be |
No files matched your search
+11
@@ -0,0 +1,11 @@
|
||||
FROM alpine
|
||||
|
||||
WORKDIR /repo
|
||||
|
||||
RUN apk add --no-cache coreutils gcc linux-headers make musl-dev util-linux-dev openssl-dev curl-dev g++ bash git perl tcl
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN make distclean && make -j
|
||||
|
||||
CMD ["./runtest"]
|
||||
@@ -6,6 +6,9 @@ version=$(grep KEYDB_REAL_VERSION $DIR/../../src/version.h | awk '{ printf $3 }'
|
||||
release=1 # by default this will always be 1 for keydb version structure. If build release version needs to be update you can modify here
|
||||
arch=$(uname -m)
|
||||
dist=el$(rpm -q --queryformat '%{VERSION}' centos-release | cut -d. -f1)
|
||||
if [[ "$dist" == "elpackage centos-release is not installed" ]]; then
|
||||
dist=el$(rpm -q --queryformat '%{VERSION}' centos-linux-release | cut -d. -f1)
|
||||
fi
|
||||
|
||||
if [[ "$arch" != "aarch64" ]] && [[ "$arch" != "x86_64" ]]; then
|
||||
echo "This script is only valid and tested for aarch64 and x86_64 architectures. You are trying to use: $arch"
|
||||
|
||||
@@ -29,4 +29,6 @@ $TCLSH tests/test_helper.tcl \
|
||||
--single unit/moduleapi/blockedclient \
|
||||
--single unit/moduleapi/moduleloadsave \
|
||||
--single unit/moduleapi/getkeys \
|
||||
--single unit/moduleapi/timers \
|
||||
--config server-threads 3 \
|
||||
"${@}"
|
||||
@@ -1,7 +1,8 @@
|
||||
set server_path [tmpdir server.log]
|
||||
set system_name [string tolower [exec uname -s]]
|
||||
set is_musl [catch {exec ldd --version}]
|
||||
|
||||
if {$system_name eq {linux} || $system_name eq {darwin}} {
|
||||
if {$system_name eq {linux} && $is_musl eq 0 || $system_name eq {darwin}} {
|
||||
start_server [list overrides [list dir $server_path]] {
|
||||
test "Server is able to generate a stack trace on selected systems" {
|
||||
r config set watchdog-period 200
|
||||
|
||||
@@ -25,7 +25,7 @@ TEST_MODULES = \
|
||||
auth.so \
|
||||
keyspace_events.so \
|
||||
blockedclient.so \
|
||||
getkeys.so
|
||||
timers.so
|
||||
|
||||
|
||||
.PHONY: all
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
#define REDISMODULE_EXPERIMENTAL_API
|
||||
#include "redismodule.h"
|
||||
#include <pthread.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sched.h>
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
static long current_timer_count = 0;
|
||||
static long total_timer_count;
|
||||
|
||||
void timerHandler(RedisModuleCtx *ctx, void *data) {
|
||||
REDISMODULE_NOT_USED(data);
|
||||
current_timer_count++;
|
||||
RedisModule_Log(ctx, "notice", "Timer %ld went off", current_timer_count);
|
||||
if (current_timer_count == total_timer_count){
|
||||
RedisModule_Log(ctx, "notice", "All timers fired successfully");
|
||||
}
|
||||
}
|
||||
|
||||
int elapsed(RedisModuleCtx *ctx, RedisModuleString **argv, int argc){
|
||||
REDISMODULE_NOT_USED(argc);
|
||||
REDISMODULE_NOT_USED(argv);
|
||||
RedisModule_ReplyWithLongLong(ctx, (long long)current_timer_count);
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
|
||||
enum TimerOrder {
|
||||
TIMERS_ASCENDING,
|
||||
TIMERS_DESCENDING,
|
||||
TIMERS_SAME
|
||||
};
|
||||
|
||||
int RedisModule_OnLoad(RedisModuleCtx *ctx, RedisModuleString **argv, int argc) {
|
||||
if (RedisModule_Init(ctx,"timer-spawn",1,REDISMODULE_APIVER_1)
|
||||
== REDISMODULE_ERR) return REDISMODULE_ERR;
|
||||
|
||||
enum TimerOrder mode;
|
||||
if (argc >= 1){
|
||||
const char * modeString = RedisModule_StringPtrLen(argv[0], NULL);
|
||||
if (strcmp(modeString, "ascending") == 0){
|
||||
mode = TIMERS_ASCENDING;
|
||||
} else if (strcmp(modeString, "descending") == 0){
|
||||
mode = TIMERS_DESCENDING;
|
||||
} else if (strcmp(modeString, "same") == 0){
|
||||
mode = TIMERS_SAME;
|
||||
} else {
|
||||
RedisModule_Log(ctx, "warning", "Invalid mode specified as first argument. Valid modes are: ascending, descending, and same");
|
||||
return REDISMODULE_ERR;
|
||||
}
|
||||
} else {
|
||||
mode = TIMERS_DESCENDING;
|
||||
}
|
||||
|
||||
long long user_timer_count;
|
||||
total_timer_count = (argc >= 2 && RedisModule_StringToLongLong(argv[1], &user_timer_count) == REDISMODULE_OK) ?
|
||||
(long)user_timer_count : 2500;
|
||||
|
||||
if (RedisModule_CreateCommand(ctx,"timer.elapsed", elapsed,"",0,0,0) == REDISMODULE_ERR)
|
||||
return REDISMODULE_ERR;
|
||||
|
||||
for (long i = 0; i < total_timer_count; i++){
|
||||
mstime_t period;
|
||||
if (mode == TIMERS_ASCENDING){
|
||||
period = i;
|
||||
} else if (mode == TIMERS_DESCENDING){
|
||||
period = total_timer_count - i;
|
||||
} else if (mode == TIMERS_SAME){
|
||||
period = total_timer_count;
|
||||
}
|
||||
RedisModule_CreateTimer(ctx, period, timerHandler, NULL);
|
||||
}
|
||||
|
||||
return REDISMODULE_OK;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
set testmodule [file normalize tests/modules/timers.so]
|
||||
set timercount 4000
|
||||
|
||||
|
||||
tags "modules" {
|
||||
test {Ascending module timers can load in correctly} {
|
||||
start_server [list overrides [list loadmodule "$testmodule ascending $timercount"]] {
|
||||
wait_for_condition [expr round($timercount/10)] 20 {
|
||||
[r timer.elapsed] == $timercount
|
||||
} else {
|
||||
fail "Server failed to load in timers with ascending periods"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test {Descending module timers can load in correctly} {
|
||||
start_server [list overrides [list loadmodule "$testmodule descending $timercount"]] {
|
||||
wait_for_condition [expr round($timercount/10)] 20 {
|
||||
[r timer.elapsed] == $timercount
|
||||
} else {
|
||||
fail "Server failed to load in timers with descending periods"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
test {Module timers with the same period can load in correctly} {
|
||||
start_server [list overrides [list loadmodule "$testmodule same $timercount"]] {
|
||||
wait_for_condition [expr round($timercount/10)] 20 {
|
||||
[r timer.elapsed] == $timercount
|
||||
} else {
|
||||
fail "Server failed to load in timers with the same period"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user