Skip to content

Commit

Permalink
Redis sentinel tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
luca3m committed Sep 27, 2014
1 parent 1046e55 commit 9c7f91d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 11 deletions.
12 changes: 9 additions & 3 deletions run-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,19 @@ redis-server --port 6379 --save "" &> /dev/null &
for x in 6380 6381 6382; do
redis-server --port $x --save "" &> /dev/null &
done
sleep 0.1
sleep 0.5
for x in 6381 6382; do
redis-cli -p $x slaveof 127.0.0.1 6380
done
redis-server tests/redis-sentinel.conf --sentinel &> /dev/null &
sleep 0.5
for x in 6380 6381 6382; do
redis-cli -p $x role
done
for x in 26379 26380 26381; do
redis-server tests/redis-sentinel-$x.conf --sentinel --port $x &> /dev/null &
done
sleep 1

sleep 0.3
redis-cli -p 26379 info sentinel
redis-cli -p 26379 sentinel get-master-addr-by-name test

Expand Down
9 changes: 5 additions & 4 deletions tests/connection_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,24 @@ void consumer_f(connection_pool::ptr_t pool, const std::string& queue_name)

BOOST_AUTO_TEST_CASE( test_pool)
{
connection_pool::ptr_t pool = connection_pool::create(getenv("REDIS_HOST"), "test");
connection_pool::ptr_t pool = connection_pool::create(std::string(getenv("REDIS_HOST")), "test");

connection::ptr_t c = pool->get(connection::MASTER);
connection::ptr_t c;
BOOST_CHECK_NO_THROW(c = pool->get(connection::MASTER));

c->run(command("SET")("foo")("bar"));

pool->put(c);

c = pool->get(connection::SLAVE);
BOOST_CHECK_NO_THROW(c = pool->get(connection::SLAVE));

BOOST_CHECK_EQUAL(c->run(command("GET")("foo")).str(), "bar");
BOOST_CHECK_THROW(c->run(command("SET")("foo")("bar")), slave_read_only);
}

BOOST_AUTO_TEST_CASE (crash_test)
{
connection_pool::ptr_t pool = connection_pool::create(getenv("REDIS_HOST"), "test");
connection_pool::ptr_t pool = connection_pool::create(std::string(getenv("REDIS_HOST")), "test");

boost::thread_group producers;
boost::thread_group consumers;
Expand Down
14 changes: 14 additions & 0 deletions tests/redis-sentinel-26379.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
sentinel monitor test 127.0.0.1 6381 2
sentinel down-after-milliseconds test 60000
sentinel config-epoch test 1

# Generated by CONFIG REWRITE
port 26379
dir "/Users/luca/src/redis3m"
sentinel leader-epoch test 1
sentinel known-slave test 127.0.0.1 6380
sentinel known-slave test 127.0.0.1 6382
sentinel known-sentinel test 127.0.0.1 26380 932e08e1e849da9815f6689cf0029d196f34c9bb
sentinel known-sentinel test 127.0.0.1 26381 aea88eeb6a9384f36602745a7ae526b8b52a8a96

sentinel current-epoch 1
11 changes: 11 additions & 0 deletions tests/redis-sentinel-26380.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
sentinel monitor test 127.0.0.1 6381 2
sentinel down-after-milliseconds test 60000
sentinel config-epoch test 1

# Generated by CONFIG REWRITE
port 26380
dir "/Users/luca/src/redis3m"
sentinel leader-epoch test 0
sentinel known-sentinel test 127.0.0.1 26379 013ebecd75ecc838ac68a335f8ead88b12cf45e0
sentinel known-sentinel test 127.0.0.1 26381 aea88eeb6a9384f36602745a7ae526b8b52a8a96
sentinel current-epoch 1
12 changes: 12 additions & 0 deletions tests/redis-sentinel-26381.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
sentinel monitor test 127.0.0.1 6381 2
sentinel down-after-milliseconds test 60000
sentinel config-epoch test 1

# Generated by CONFIG REWRITE
port 26381
dir "/Users/luca/src/redis3m"
sentinel leader-epoch test 0
sentinel known-slave test 127.0.0.1 6382
sentinel known-sentinel test 127.0.0.1 26380 932e08e1e849da9815f6689cf0029d196f34c9bb
sentinel known-sentinel test 127.0.0.1 26379 013ebecd75ecc838ac68a335f8ead88b12cf45e0
sentinel current-epoch 1
4 changes: 0 additions & 4 deletions tests/redis-sentinel.conf

This file was deleted.

0 comments on commit 9c7f91d

Please sign in to comment.