Skip to content

Commit 9b0769f

Browse files
author
Michael Fero
committed
test: Correcting integration test category grouping
1 parent 5169071 commit 9b0769f

7 files changed

Lines changed: 49 additions & 27 deletions

File tree

cpp-driver/gtests/src/integration/integration.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,13 @@
3737

3838
// Macros for grouping tests together
3939
#define GROUP_TEST_F(group_name, test_case, test_name) TEST_F(test_case, group_name##_##test_name)
40+
#define GROUP_TEST(group_name, test_case, test_name) TEST(test_case, group_name##_##test_name)
4041
#define GROUP_TYPED_TEST_P(group_name, test_case, test_name) \
4142
TYPED_TEST_P(test_case, group_name##_##test_name)
4243

4344
// Macros to use for grouping integration tests together
44-
#define GROUP_INTEGRATION_TEST(server_type) GROUP_CONCAT(Integration, server_type)
45+
#define INTEGRATION_TEST(server_type, test_case, test_name) \
46+
GROUP_TEST(Integration##_##server_type, test_case, test_name)
4547
#define INTEGRATION_TEST_F(server_type, test_case, test_name) \
4648
GROUP_TEST_F(Integration##_##server_type, test_case, test_name)
4749
#define INTEGRATION_TYPED_TEST_P(server_type, test_case, test_name) \
@@ -52,7 +54,8 @@
5254
GROUP_TYPED_TEST_P(DISABLED##_##Integration##_##server_type, test_case, est_name)
5355

5456
// Macros to use for grouping Cassandra integration tests together
55-
#define CASSANDRA_TEST_NAME(test_name) Integration##_##Cassandra##_##test_name
57+
#define CASSANDRA_INTEGRATION_TEST(test_case, test_name) \
58+
INTEGRATION_TEST(Cassandra, test_case, test_name)
5659
#define CASSANDRA_INTEGRATION_TEST_F(test_case, test_name) \
5760
INTEGRATION_TEST_F(Cassandra, test_case, test_name)
5861
#define CASSANDRA_INTEGRATION_TYPED_TEST_P(test_case, test_name) \

cpp-driver/gtests/src/integration/simulacron/simulacron_integration.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,12 @@
2222
#include <uv.h>
2323

2424
// Macros to use for grouping Simulacron integration tests together
25-
#define SIMULACRON_TEST_NAME(test_name) Integration##_##simulacron##_##test_name
25+
#define SIMULACRON_INTEGRATION_TEST(test_case, test_name) \
26+
INTEGRATION_TEST(Simulacron, test_case, test_name)
2627
#define SIMULACRON_INTEGRATION_TEST_F(test_case, test_name) \
27-
INTEGRATION_TEST_F(simulacron, test_case, test_name)
28+
INTEGRATION_TEST_F(Simulacron, test_case, test_name)
2829
#define SIMULACRON_INTEGRATION_TYPED_TEST_P(test_case, test_name) \
29-
INTEGRATION_TYPED_TEST_P(simulacron, test_case, test_name)
30+
INTEGRATION_TYPED_TEST_P(Simulacron, test_case, test_name)
3031

3132
#define CHECK_SIMULACRON_AVAILABLE \
3233
if (!sc_) { \

cpp-driver/gtests/src/integration/test_category.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
const TestCategory TestCategory::CASSANDRA("CASSANDRA", 0, "Cassandra", "*_Cassandra_*");
2424
const TestCategory TestCategory::DSE("DSE", 1, "DataStax Enterprise", "*_DSE_*");
2525
const TestCategory TestCategory::SIMULACRON("SIMULACRON", SHRT_MAX, "Simulated DSE (and Cassandra)",
26-
"*_simulacron_*");
26+
"*_Simulacron_*");
2727

2828
// Static declarations for test type
2929
std::set<TestCategory> TestCategory::constants_;

cpp-driver/gtests/src/integration/tests/test_cluster.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@
1414
limitations under the License.
1515
*/
1616

17-
#include "objects/cluster.hpp"
17+
#include "integration.hpp"
18+
19+
class ClusterTests : public Integration {
20+
public:
21+
ClusterTests() {
22+
is_ccm_requested_ = false;
23+
}
24+
};
1825

1926
/**
2027
* Set local dc to null for dc-aware lbp
@@ -23,7 +30,7 @@
2330
* @test_category configuration
2431
* @expected_result Error out because it is illegal to specify a null local-dc.
2532
*/
26-
TEST(ClusterTest, SetLoadBalanceDcAwareNullLocalDc) {
33+
CASSANDRA_INTEGRATION_TEST_F(ClusterTests, SetLoadBalanceDcAwareNullLocalDc) {
2734
test::driver::Cluster cluster;
2835
EXPECT_EQ(CASS_ERROR_LIB_BAD_PARAMS,
2936
cass_cluster_set_load_balance_dc_aware(cluster.get(), NULL, 99, cass_false));
@@ -36,7 +43,7 @@ TEST(ClusterTest, SetLoadBalanceDcAwareNullLocalDc) {
3643
* @test_category configuration
3744
* @expected_result CASS_ERROR_LIB_BAD_PARAMS.
3845
*/
39-
TEST(ClusterTest, ExponentialReconnectionPolicyBadParameters) {
46+
CASSANDRA_INTEGRATION_TEST_F(ClusterTests, ExponentialReconnectionPolicyBadParameters) {
4047
test::driver::Cluster cluster;
4148

4249
// Base delay must be greater than 1
@@ -54,7 +61,7 @@ TEST(ClusterTest, ExponentialReconnectionPolicyBadParameters) {
5461
* @test_category configuration
5562
* @expected_result CASS_ERROR_LIB_BAD_PARAMS.
5663
*/
57-
TEST(ClusterTest, SecureConnectionBundleBadParameters) {
64+
CASSANDRA_INTEGRATION_TEST_F(ClusterTests, SecureConnectionBundleBadParameters) {
5865
test::driver::Cluster cluster;
5966

6067
EXPECT_EQ(CASS_ERROR_LIB_BAD_PARAMS, cass_cluster_set_cloud_secure_connection_bundle_n(

cpp-driver/gtests/src/integration/tests/test_config.cpp

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,31 @@
1414
limitations under the License.
1515
*/
1616

17-
#include <gtest/gtest.h>
17+
#include "integration.hpp"
1818

19-
#include "cassandra.h"
19+
class ConfigTests : public Integration {
20+
public:
21+
ConfigTests() {
22+
Integration::SetUp();
23+
}
24+
};
2025

21-
#include "driver_utils.hpp"
22-
#include "objects/cluster.hpp"
23-
24-
TEST(ConfigTest, Options) {
26+
CASSANDRA_INTEGRATION_TEST_F(ConfigTests, Options) {
2527
test::driver::Cluster cluster =
2628
test::driver::Cluster::build().with_connect_timeout(9999u).with_port(7000);
2729
EXPECT_EQ(9999u, test::driver::internals::Utils::connect_timeout(cluster.get()));
2830
EXPECT_EQ(7000, test::driver::internals::Utils::port(cluster.get()));
2931
}
3032

31-
TEST(ConfigTest, ContactPointsSimple) {
33+
CASSANDRA_INTEGRATION_TEST_F(ConfigTests, ContactPointsSimple) {
3234
std::string contact_points = "127.0.0.1,127.0.0.2,127.0.0.3";
3335
test::driver::Cluster cluster =
3436
test::driver::Cluster::build().with_contact_points(contact_points);
3537
EXPECT_STREQ(contact_points.c_str(),
3638
test::driver::internals::Utils::contact_points(cluster.get()).c_str());
3739
}
3840

39-
TEST(ConfigTest, ContactPointsClear) {
41+
CASSANDRA_INTEGRATION_TEST_F(ConfigTests, ContactPointsClear) {
4042
std::string contact_points = "127.0.0.1,127.0.0.2,127.0.0.3";
4143
test::driver::Cluster cluster =
4244
test::driver::Cluster::build().with_contact_points(contact_points);
@@ -46,15 +48,15 @@ TEST(ConfigTest, ContactPointsClear) {
4648
EXPECT_TRUE(test::driver::internals::Utils::contact_points(cluster.get()).empty());
4749
}
4850

49-
TEST(ConfigTest, ContactPointsExtraCommas) {
51+
CASSANDRA_INTEGRATION_TEST_F(ConfigTests, ContactPointsExtraCommas) {
5052
std::string contact_points = ",,,,127.0.0.1,,,,127.0.0.2,127.0.0.3,,,,";
5153
test::driver::Cluster cluster =
5254
test::driver::Cluster::build().with_contact_points(contact_points);
5355
EXPECT_STREQ("127.0.0.1,127.0.0.2,127.0.0.3",
5456
test::driver::internals::Utils::contact_points(cluster.get()).c_str());
5557
}
5658

57-
TEST(ConfigTest, ContactPointsExtraWhitespace) {
59+
CASSANDRA_INTEGRATION_TEST_F(ConfigTests, ContactPointsExtraWhitespace) {
5860
std::string contact_points =
5961
" ,\r\n, , , 127.0.0.1 ,,, ,\t127.0.0.2,127.0.0.3, \t\n, ,, ";
6062
test::driver::Cluster cluster =
@@ -63,7 +65,7 @@ TEST(ConfigTest, ContactPointsExtraWhitespace) {
6365
test::driver::internals::Utils::contact_points(cluster.get()).c_str());
6466
}
6567

66-
TEST(ConfigTest, ContactPointsAppend) {
68+
CASSANDRA_INTEGRATION_TEST_F(ConfigTests, ContactPointsAppend) {
6769
test::driver::Cluster cluster = test::driver::Cluster::build().with_contact_points("127.0.0.1");
6870
EXPECT_STREQ("127.0.0.1", test::driver::internals::Utils::contact_points(cluster.get()).c_str());
6971
cluster.with_contact_points("127.0.0.2");

cpp-driver/gtests/src/integration/tests/test_statement.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818

1919
class StatementTests : public Integration {
2020
public:
21-
StatementTests() { number_dc1_nodes_ = 2; }
21+
StatementTests() {
22+
number_dc1_nodes_ = 2;
23+
}
2224
};
2325

2426
/**
@@ -104,14 +106,21 @@ CASSANDRA_INTEGRATION_TEST_F(StatementTests, SetHostWhereHostIsDown) {
104106
EXPECT_EQ(result.error_code(), CASS_ERROR_LIB_NO_HOSTS_AVAILABLE);
105107
}
106108

109+
class StatementNoClusterTests : public StatementTests {
110+
public:
111+
StatementNoClusterTests() {
112+
is_ccm_requested_ = false;
113+
}
114+
};
115+
107116
/**
108117
* Set a host on a statement using valid host strings.
109118
*
110119
* @jira_ticket CPP-597
111120
* @test_category configuration
112121
* @expected_result Success
113122
*/
114-
TEST(StatementTest, SetHostWithValidHostString) {
123+
CASSANDRA_INTEGRATION_TEST_F(StatementNoClusterTests, SetHostWithValidHostString) {
115124
Statement statement("");
116125
EXPECT_EQ(cass_statement_set_host(statement.get(), "127.0.0.1", 9042), CASS_OK);
117126
EXPECT_EQ(cass_statement_set_host(statement.get(), "::1", 9042), CASS_OK);
@@ -127,7 +136,7 @@ TEST(StatementTest, SetHostWithValidHostString) {
127136
* @test_category configuration
128137
* @expected_result Failure with the bad parameters error.
129138
*/
130-
TEST(StatementTest, SetHostWithInvalidHostString) {
139+
CASSANDRA_INTEGRATION_TEST_F(StatementNoClusterTests, SetHostWithInvalidHostString) {
131140
Statement statement("");
132141
EXPECT_EQ(cass_statement_set_host(statement.get(), "notvalid", 9042), CASS_ERROR_LIB_BAD_PARAMS);
133142
EXPECT_EQ(cass_statement_set_host(statement.get(), "", 9042), CASS_ERROR_LIB_BAD_PARAMS);
@@ -141,7 +150,7 @@ TEST(StatementTest, SetHostWithInvalidHostString) {
141150
* @test_category configuration
142151
* @expected_result Success
143152
*/
144-
TEST(StatementTest, SetHostWithValidHostInet) {
153+
CASSANDRA_INTEGRATION_TEST_F(StatementNoClusterTests, SetHostWithValidHostInet) {
145154
Statement statement("");
146155
CassInet valid;
147156
ASSERT_EQ(cass_inet_from_string("127.0.0.1", &valid), CASS_OK);
@@ -162,7 +171,7 @@ TEST(StatementTest, SetHostWithValidHostInet) {
162171
* @test_category configuration
163172
* @expected_result Failure with the bad parameters error.
164173
*/
165-
TEST(StatementTest, SetHostWithInvalidHostInet) {
174+
CASSANDRA_INTEGRATION_TEST_F(StatementNoClusterTests, SetHostWithInvalidHostInet) {
166175
Statement statement("");
167176
CassInet invalid;
168177
invalid.address_length = 3; // Only 4 or 16 is valid (IPv4 and IPv6)

tests/src/integration/dse_integration.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
}
3636

3737
// Macros to use for grouping DSE integration tests together
38-
#define DSE_TEST_NAME(test_name) Integration##_##DSE##_##test_name
38+
#define DSE_INTEGRATION_TEST(test_case, test_name) INTEGRATION_TEST(DSE, test_case, test_name)
3939
#define DSE_INTEGRATION_TEST_F(test_case, test_name) INTEGRATION_TEST_F(DSE, test_case, test_name)
4040
#define DSE_INTEGRATION_TYPED_TEST_P(test_case, test_name) \
4141
INTEGRATION_TYPED_TEST_P(DSE, test_case, test_name)

0 commit comments

Comments
 (0)