Skip to content

Commit e3b0f55

Browse files
author
mikefero
committed
test: CPP-253 Ensure entire pool is not removed with partial connections
Removed old code and comment from outage test (fixed in CPP-140)
1 parent c9b630a commit e3b0f55

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

test/integration_tests/src/test_outage.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,6 @@ struct OutageTests : public test_utils::MultipleNodesTest {
6262
test_utils::CassLog::set_output_log_level(CASS_LOG_DISABLED);
6363
printf("Warning! This test is going to take %d minutes\n", TEST_DURATION_SECS / 60);
6464
std::fill(nodes_states, nodes_states + NUM_NODES, UP);
65-
// TODO(mpenick): This is a stopgap. To be fixed in CPP-140
66-
#if !defined(WIN32) && !defined(_WIN32)
67-
signal(SIGPIPE, SIG_IGN);
68-
#endif
6965
}
7066

7167
int random_int(int s, int e) {

test/integration_tests/src/test_pool.cpp

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
#include "test_utils.hpp"
2323
#include "cluster.hpp"
2424

25+
#include <uv.h>
26+
2527
#include <boost/scoped_ptr.hpp>
2628
#include <boost/test/unit_test.hpp>
2729

@@ -125,4 +127,53 @@ BOOST_AUTO_TEST_CASE(connection_spawn)
125127
}
126128
BOOST_CHECK_EQUAL(test_utils::CassLog::message_count(), 2u);
127129
}
130+
131+
/**
132+
* Create connection interruptions using CCM for four seconds on node 2
133+
*
134+
* @param ccm CCM bridge pointer
135+
*/
136+
static void connection_interruptions(void *ccm) {
137+
boost::posix_time::ptime start = boost::posix_time::second_clock::universal_time();
138+
while ((boost::posix_time::second_clock::universal_time() - start).total_seconds() < 4) {
139+
cql::cql_ccm_bridge_t* ccm_ptr = static_cast<cql::cql_ccm_bridge_t*>(ccm);
140+
ccm_ptr->pause(2);
141+
ccm_ptr->resume(2);
142+
}
143+
}
144+
145+
/**
146+
* Don't Recycle Pool On Connection Timeout
147+
*
148+
* This test ensures that a pool does not completely remove itself while
149+
* allowing partial connections to remain and reconnection attempts to use the
150+
* existing pool.
151+
*
152+
* @since 2.1.0
153+
* @test_category connection:connection_pool
154+
* @jira_ticket CPP-253 [https://datastax-oss.atlassian.net/browse/CPP-253]
155+
*/
156+
BOOST_AUTO_TEST_CASE(dont_recycle_pool_on_timeout) {
157+
ccm->bootstrap(2);
158+
test_utils::CassLog::reset("Host " + conf.ip_prefix() + "2 already present attempting to initiate immediate connection");
159+
160+
// Create session during "connection interruptions"
161+
cass_cluster_set_connect_timeout(cluster, 1000);
162+
cass_cluster_set_num_threads_io(cluster, 16);
163+
cass_cluster_set_core_connections_per_host(cluster, 2);
164+
cass_cluster_set_load_balance_round_robin(cluster);
165+
uv_thread_t connection_interruptions_thread;
166+
uv_thread_create(&connection_interruptions_thread, connection_interruptions, ccm.get());
167+
test_utils::CassSessionPtr session(test_utils::create_session(cluster));
168+
uv_thread_join(&connection_interruptions_thread);
169+
170+
boost::posix_time::ptime start = boost::posix_time::second_clock::universal_time();
171+
while ((boost::posix_time::second_clock::universal_time() - start).total_seconds() < 60) {
172+
test_utils::CassStatementPtr statement(cass_statement_new("SELECT * FROM system.local", 0));
173+
test_utils::CassFuturePtr(cass_session_execute(session.get(), statement.get()));
174+
}
175+
176+
BOOST_CHECK_GE(test_utils::CassLog::message_count(), 1);
177+
}
178+
128179
BOOST_AUTO_TEST_SUITE_END()

0 commit comments

Comments
 (0)