Skip to content

Commit

Permalink
Merge pull request #710 from shaitan/test
Browse files Browse the repository at this point in the history
tests: fix race in reconnect test
  • Loading branch information
bioothod authored Jul 5, 2016
2 parents 76fb5fc + ada740e commit 77acf46
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions tests/reconnect_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,27 @@ static void test_failed_connection_restore(session &sess)

test_sess.toggle_all_command_send(false);

for (int i = 0; i < stall_count; ++i)
// using stall_count + 1 here to guarantee that state will actually
// be reset before this loop ends
for (int i = 0; i < stall_count + 1; ++i)
{
ELLIPTICS_REQUIRE_ERROR(async_lookup_result, sess.lookup(id), -ETIMEDOUT);
}
auto async = sess.lookup(id);
async.wait();

// state reset could happen a bit earlier (as a result of route list update processing in dnet_check)
// if so we should just stop the loop
if (async.error().code() == -ENXIO) {
break;
}

ELLIPTICS_REQUIRE_ERROR(async_status_result, sess.request_backends_status(node.remote()), -ETIMEDOUT);
BOOST_REQUIRE(async.error().code() == -ETIMEDOUT);
}

BOOST_REQUIRE_EQUAL(sess.state_num(), 0);

test_sess.toggle_all_command_send(true);

// wait until background thread will restore connection with server node
::sleep(check_timeout + 1);

ELLIPTICS_REQUIRE_ERROR(async_lookup_result2, sess.lookup(id), -ENOENT);
Expand Down

0 comments on commit 77acf46

Please sign in to comment.