Commit ae481d43 authored by Felix Hamann's avatar Felix Hamann

added `make test` target

parent 34b082e1
......@@ -88,3 +88,33 @@ sam_selftest_SOURCES = \
sam_selftest_LDADD = src/libsam.la
sam_selftest_LDFLAGS = -static -lcheck
sam_selftest_CFLAGS = -D__SAM_TEST $(AM_CFLAGS)
#
# custom targets
#
.PHONY: test
nodename = "sam-test@$$HOSTNAME"
test: sam_selftest
rm -rf db/test # remove if existent for some reason
mkdir -p db/test
sudo env RABBITMQ_NODE_PORT=15672 RABBITMQ_NODENAME=${nodename} rabbitmq-server -detached
n=3; \
ret=2; \
while [ $$ret -ne 0 -a $$n -gt 0 ]; do \
echo "waiting for rabbitmq, $$n tries left"; \
sleep 1; \
n=$$(expr $$n - 1); \
ret=$$(sudo rabbitmqctl status -n ${nodename} >/dev/null 2>&1; echo $$?); \
done; \
true
./sam_selftest
rm -rf db/test
sudo rabbitmqctl -n ${nodename} stop
......@@ -3,7 +3,7 @@ backend
broker-1
host = localhost
port = 5672
port = 15672
user = guest
pass = guest
heartbeat = 3
......@@ -12,7 +12,7 @@ backend
broker-2
host = localhost
port = 5673
port = 15672
user = guest
pass = guest
heartbeat = 3
......
......@@ -24,21 +24,27 @@ backend
broker-1
host = localhost
port = 5672
port = 15672
user = guest
pass = guest
heartbeat = 3
tries = -1
interval = 1m
broker-2
host = localhost
port = 5673
port = 15672
user = guest
pass = guest
heartbeat = 3
tries = -1
interval = 1m
broker-3
host = localhost
port = 5672
port = 15672
user = guest
pass = guest
heartbeat = 3
tries = -1
interval = 1m
......@@ -35,7 +35,7 @@ setup_connection ()
sam_be_rmq_opts_t opts = {
.host = "localhost",
.port = 5672,
.port = 15672,
.user = "guest",
.pass = "guest",
.heartbeat = 1
......
......@@ -98,9 +98,6 @@ static int
save (const char *payload, int count)
{
zmsg_t *zmsg = zmsg_new ();
zmsg_addstr (zmsg, "test-x");
zmsg_addstr (zmsg, "");
zmsg_addstr (zmsg, payload);
sam_msg_t *msg = sam_msg_new (&zmsg);
......@@ -251,7 +248,7 @@ START_TEST(test_buf_save_redundant_race)
// save
int key = save_redundant ("redundant race", 2);
ck_assert_int_eq (key, 1);
ck_assert_int_eq (key, 4); // TODO global state is bad!
zclock_sleep (10);
// ack 2
......@@ -378,13 +375,13 @@ sam_buf_test ()
Suite *s = suite_create ("sam_buf");
TCase *tc = tcase_create ("save round robin");
tcase_add_checked_fixture (tc, setup, destroy);
tcase_add_unchecked_fixture (tc, setup, destroy);
tcase_add_test (tc, test_buf_save_roundrobin);
tcase_add_test (tc, test_buf_save_roundrobin_race);
suite_add_tcase (s, tc);
tc = tcase_create ("save redundant");
tcase_add_checked_fixture (tc, setup, destroy);
tcase_add_unchecked_fixture (tc, setup, destroy);
tcase_add_test (tc, test_buf_save_redundant);
tcase_add_test (tc, test_buf_save_redundant_race);
tcase_add_test (tc, test_buf_save_redundant_idempotency);
......@@ -398,7 +395,7 @@ sam_buf_test ()
suite_add_tcase (s, tc);
tc = tcase_create ("restore state");
tcase_add_checked_fixture (tc, setup, destroy);
tcase_add_unchecked_fixture (tc, setup, destroy);
tcase_add_test (tc, test_buf_restore);
suite_add_tcase (s, tc);
......
......@@ -544,7 +544,7 @@ START_TEST(test_cfg_be_backends_rmq)
// broker-1
ck_assert_str_eq (*names, "broker-1");
ck_assert_str_eq (opts->host, "localhost");
ck_assert_int_eq (opts->port, 5672);
ck_assert_int_eq (opts->port, 15672);
ck_assert_str_eq (opts->user, "guest");
ck_assert_str_eq (opts->pass, "guest");
ck_assert_int_eq (opts->heartbeat, 3);
......@@ -558,7 +558,7 @@ START_TEST(test_cfg_be_backends_rmq)
// broker-2
ck_assert_str_eq (*names, "broker-2");
ck_assert_str_eq (opts->host, "localhost");
ck_assert_int_eq (opts->port, 5673);
ck_assert_int_eq (opts->port, 15672);
ck_assert_str_eq (opts->user, "guest");
ck_assert_str_eq (opts->pass, "guest");
ck_assert_int_eq (opts->heartbeat, 3);
......
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