Commit 6eaac54e authored by Geoff Simmons's avatar Geoff Simmons

all unit tests succeed, including the regression test

parent 6577db8d
...@@ -72,7 +72,7 @@ ...@@ -72,7 +72,7 @@
#define TRACKLOG_PREFIX "track " #define TRACKLOG_PREFIX "track "
#define TRACKLOG_PREFIX_LEN (sizeof(TRACKLOG_PREFIX)-1) #define TRACKLOG_PREFIX_LEN (sizeof(TRACKLOG_PREFIX)-1)
#define REQEND_T_VAR "req_endt" #define REQEND_T_VAR "req_endt"
#define REQEND_T_LEN (sizeof(REQEND_T_VAR "=1430176881.682097")-1) #define REQEND_T_LEN (sizeof(REQEND_T_VAR "=1430176881.682097"))
#define DISPATCH_EOL 0 #define DISPATCH_EOL 0
#define DISPATCH_RETURN_OK 0 #define DISPATCH_RETURN_OK 0
...@@ -312,7 +312,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) ...@@ -312,7 +312,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
assert(t->type == VSL_t_req); assert(t->type == VSL_t_req);
assert(VSL_CLIENT(t->c->rec.ptr)); assert(VSL_CLIENT(t->c->rec.ptr));
if (t == pt[0]) { if (de->end == 0) {
de->xid = t->vxid; de->xid = t->vxid;
snprintf(de->data, config.maxdata, "XID=%u", t->vxid); snprintf(de->data, config.maxdata, "XID=%u", t->vxid);
de->end = strlen(de->data); de->end = strlen(de->data);
...@@ -320,7 +320,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) ...@@ -320,7 +320,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
len_hi = de->end; len_hi = de->end;
} }
len = VSL_LEN(t->c->rec.ptr); len = VSL_LEN(t->c->rec.ptr) - 1;
payload = VSL_CDATA(t->c->rec.ptr); payload = VSL_CDATA(t->c->rec.ptr);
xid = VSL_ID(t->c->rec.ptr); xid = VSL_ID(t->c->rec.ptr);
tag = VSL_TAG(t->c->rec.ptr); tag = VSL_TAG(t->c->rec.ptr);
...@@ -392,7 +392,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv) ...@@ -392,7 +392,7 @@ dispatch(struct VSL_data *vsl, struct VSL_transaction * const pt[], void *priv)
snprintf(reqend_str, REQEND_T_LEN, "%s=%u.%06lu", REQEND_T_VAR, snprintf(reqend_str, REQEND_T_LEN, "%s=%u.%06lu", REQEND_T_VAR,
(unsigned) de->reqend_t.tv_sec, de->reqend_t.tv_usec); (unsigned) de->reqend_t.tv_sec, de->reqend_t.tv_usec);
append(de, SLT_Timestamp, de->xid, reqend_str, REQEND_T_LEN); append(de, SLT_Timestamp, de->xid, reqend_str, REQEND_T_LEN - 1);
de->occupied = 1; de->occupied = 1;
MON_StatsUpdate(STATS_OCCUPANCY); MON_StatsUpdate(STATS_OCCUPANCY);
data_submit(de); data_submit(de);
...@@ -420,6 +420,7 @@ CHILD_Main(int readconfig) ...@@ -420,6 +420,7 @@ CHILD_Main(int readconfig)
struct VSL_cursor *cursor; struct VSL_cursor *cursor;
MON_StatsInit(); MON_StatsInit();
debug = (LOG_GetLevel() == LOG_DEBUG);
LOG_Log0(LOG_NOTICE, "Worker process starting"); LOG_Log0(LOG_NOTICE, "Worker process starting");
......
...@@ -44,6 +44,7 @@ static const char *level2name[LOG_DEBUG+1]; ...@@ -44,6 +44,7 @@ static const char *level2name[LOG_DEBUG+1];
static void static void
syslog_setlevel(int level) syslog_setlevel(int level)
{ {
logconf.level = level;
setlogmask(LOG_UPTO(level)); setlogmask(LOG_UPTO(level));
} }
...@@ -68,11 +69,13 @@ stdio_log(int level, const char *msg, ...) ...@@ -68,11 +69,13 @@ stdio_log(int level, const char *msg, ...)
if (level > logconf.level) if (level > logconf.level)
return; return;
flockfile(logconf.out);
fprintf(logconf.out, "%s: ", level2name[level]); fprintf(logconf.out, "%s: ", level2name[level]);
va_start(ap, msg); va_start(ap, msg);
(void) vfprintf(logconf.out, msg, ap); (void) vfprintf(logconf.out, msg, ap);
va_end(ap); va_end(ap);
fprintf(logconf.out, "\n"); fprintf(logconf.out, "\n");
funlockfile(logconf.out);
fflush(logconf.out); fflush(logconf.out);
} }
...@@ -97,6 +100,7 @@ int LOG_Open(const char *progname) ...@@ -97,6 +100,7 @@ int LOG_Open(const char *progname)
logconf.close = closelog; logconf.close = closelog;
openlog(progname, LOG_PID | LOG_CONS | LOG_NDELAY | LOG_NOWAIT, openlog(progname, LOG_PID | LOG_CONS | LOG_NDELAY | LOG_NOWAIT,
config.syslog_facility); config.syslog_facility);
logconf.level = LOG_INFO;
setlogmask(LOG_UPTO(LOG_INFO)); setlogmask(LOG_UPTO(LOG_INFO));
atexit(closelog); atexit(closelog);
return(0); return(0);
...@@ -119,3 +123,9 @@ int LOG_Open(const char *progname) ...@@ -119,3 +123,9 @@ int LOG_Open(const char *progname)
return(0); return(0);
} }
int
LOG_GetLevel(void)
{
return logconf.level;
}
AM_CPPFLAGS = @VARNISH_CFLAGS@ -I$(top_srcdir)/include AM_CPPFLAGS = @VARNISH_CFLAGS@ -I$(top_srcdir)/include
TESTS = test_parse test_data test_append test_mq test_spmcq \ TESTS = test_parse test_data test_append test_mq test_spmcq \
test_config test_spmcq_loop.sh test_worker # regress.sh test_config test_spmcq_loop.sh test_worker regress.sh
check_PROGRAMS = test_parse test_data test_append test_mq \ check_PROGRAMS = test_parse test_data test_append test_mq \
test_spmcq test_config test_worker test_spmcq test_config test_worker
......
...@@ -3,13 +3,12 @@ ...@@ -3,13 +3,12 @@
# The regression test reads from a binary dump of the Varnish SHM log # The regression test reads from a binary dump of the Varnish SHM log
# obtained from: # obtained from:
# #
# $ varnishlog -w varnish.binlog # $ varnishlog -B -w varnish.binlog
#
# Load was created from JMeter running 50 request in 100 threads.
# #
# The regression runs trackrdrd, reading from the binary dump and # The regression runs trackrdrd, reading from the binary dump and
# logging to stdout in debug mode, and obtains a cksum from # logging to stdout in debug mode, and obtains a cksum from stdout. It
# stdout. The cksum must match an expected value. # uses the file MQ implementation to write an output file. The cksums
# from the log and the output file must match expected values.
echo echo
echo "TEST: $0" echo "TEST: $0"
...@@ -22,8 +21,14 @@ CMD="../trackrdrd -D -f varnish.binlog -l - -d -c test.conf" ...@@ -22,8 +21,14 @@ CMD="../trackrdrd -D -f varnish.binlog -l - -d -c test.conf"
# the user running it # the user running it
CKSUM=$( $CMD | sed -e 's/\(initializing\) \(.*\)/\1/' | sed -e 's/\(Running as\) \([a-zA-Z0-9]*\)$/\1/' | grep -v 'Not running as root' | cksum) CKSUM=$( $CMD | sed -e 's/\(initializing\) \(.*\)/\1/' | sed -e 's/\(Running as\) \([a-zA-Z0-9]*\)$/\1/' | grep -v 'Not running as root' | cksum)
if [ "$CKSUM" != '422255173 234182' ]; then if [ "$CKSUM" != '3547423616 248886' ]; then
echo "ERROR: Regression test incorrect cksum: $CKSUM" echo "ERROR: Regression test incorrect log cksum: $CKSUM"
exit 1
fi
CKSUM=$(cksum mq_test.log)
if [ "$CKSUM" != '3675018591 29491 mq_test.log' ]; then
echo "ERROR: Regression test incorrect output cksum: $CKSUM"
exit 1 exit 1
fi fi
......
...@@ -4,6 +4,6 @@ pid.file = trackrdrd.pid ...@@ -4,6 +4,6 @@ pid.file = trackrdrd.pid
maxdata = 4096 maxdata = 4096
maxdone = 1024 maxdone = 1024
monitor.interval = 0 monitor.interval = 0
nworkers = 0 nworkers = 1
mq.module = ../mq/file/.libs/libtrackrdr-file.so mq.module = ../mq/file/.libs/libtrackrdr-file.so
mq.config_file = file_mq.conf mq.config_file = file_mq.conf
...@@ -289,6 +289,7 @@ struct logconf { ...@@ -289,6 +289,7 @@ struct logconf {
} logconf; } logconf;
int LOG_Open(const char *progname); int LOG_Open(const char *progname);
int LOG_GetLevel(void);
/* XXX: __VA_ARGS__ can't be empty ... */ /* XXX: __VA_ARGS__ can't be empty ... */
#define LOG_Log0(level, msg) logconf.log(level, msg) #define LOG_Log0(level, msg) logconf.log(level, msg)
#define LOG_Log(level, msg, ...) logconf.log(level, msg, __VA_ARGS__) #define LOG_Log(level, msg, ...) logconf.log(level, msg, __VA_ARGS__)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment