|
| 1 | +/* |
| 2 | + Copyright (c) DataStax, Inc. |
| 3 | +
|
| 4 | + Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + you may not use this file except in compliance with the License. |
| 6 | + You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | + Unless required by applicable law or agreed to in writing, software |
| 11 | + distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + See the License for the specific language governing permissions and |
| 14 | + limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +#include "cassandra.h" |
| 18 | +#include "integration.hpp" |
| 19 | + |
| 20 | +#include <algorithm> |
| 21 | +#include <iterator> |
| 22 | + |
| 23 | +class LatencyAwarePolicyTest : public Integration { |
| 24 | +public: |
| 25 | + void SetUp() { |
| 26 | + number_dc1_nodes_ = 3; |
| 27 | + is_session_requested_ = false; |
| 28 | + Integration::SetUp(); |
| 29 | + } |
| 30 | +}; |
| 31 | + |
| 32 | +/** |
| 33 | + * Validates that latency-aware policy is enabled and updating the minimum average latency. |
| 34 | + * |
| 35 | + * @since 2.16.1 |
| 36 | + * @jira_ticket CPP-935 |
| 37 | + * @test_category load_balancing_policy:latency_aware |
| 38 | + */ |
| 39 | +CASSANDRA_INTEGRATION_TEST_F(LatencyAwarePolicyTest, IsEnabled) { |
| 40 | + CHECK_FAILURE |
| 41 | + cluster_ = default_cluster(); |
| 42 | + cluster_.with_load_balance_round_robin(); |
| 43 | + cass_cluster_set_token_aware_routing(cluster_.get(), cass_false); |
| 44 | + cass_cluster_set_latency_aware_routing(cluster_.get(), cass_true); |
| 45 | + cass_cluster_set_latency_aware_routing_settings(cluster_.get(), 2.0, 100LL * 1000LL * 1000LL, |
| 46 | + 10LL * 1000LL * 1000LL * 1000LL, 100, 1); |
| 47 | + connect(cluster_); |
| 48 | + |
| 49 | + logger_.reset(); |
| 50 | + logger_.add_critera("Calculated new minimum:"); |
| 51 | + |
| 52 | + for (int i = 0; i < 9; ++i) { // Greater than min measured |
| 53 | + session_.execute("SELECT release_version FROM system.local"); |
| 54 | + } |
| 55 | + |
| 56 | + msleep(250); |
| 57 | + |
| 58 | + EXPECT_GT(logger_.count(), 0u); |
| 59 | +} |
0 commit comments