Skip to content

Commit 129bf50

Browse files
CASSANDRA-19635: Run integration tests with C* 5.x
patch by Lukasz Antoniak; reviewed by Andy Tolbert, and Bret McGuire for CASSANDRA-19635
1 parent 4bc3468 commit 129bf50

28 files changed

+455
-258
lines changed

integration-tests/pom.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,8 @@
242242
<threadCountClasses>8</threadCountClasses>
243243
<summaryFile>${project.build.directory}/failsafe-reports/failsafe-summary-parallelized.xml</summaryFile>
244244
<skipITs>${skipParallelizableITs}</skipITs>
245+
<argLine>${blockhound.argline}</argLine>
246+
<jvm>${testing.jvm}/bin/java</jvm>
245247
</configuration>
246248
</execution>
247249
<execution>
@@ -253,6 +255,7 @@
253255
<excludedGroups>com.datastax.oss.driver.categories.ParallelizableTests, com.datastax.oss.driver.categories.IsolatedTests</excludedGroups>
254256
<summaryFile>${project.build.directory}/failsafe-reports/failsafe-summary-serial.xml</summaryFile>
255257
<skipITs>${skipSerialITs}</skipITs>
258+
<argLine>${blockhound.argline}</argLine>
256259
<jvm>${testing.jvm}/bin/java</jvm>
257260
</configuration>
258261
</execution>

integration-tests/src/test/java/com/datastax/dse/driver/api/core/auth/DseProxyAuthenticationIT.java

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.datastax.oss.driver.api.core.cql.ResultSet;
3030
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
3131
import com.datastax.oss.driver.api.core.servererrors.UnauthorizedException;
32+
import com.datastax.oss.driver.api.testinfra.ccm.SchemaChangeSynchronizer;
3233
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
3334
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
3435
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
@@ -57,33 +58,38 @@ public static void addUsers() {
5758
@Before
5859
public void setupRoles() {
5960

60-
try (CqlSession session = ads.newKeyTabSession()) {
61-
session.execute(
62-
"CREATE ROLE IF NOT EXISTS alice WITH PASSWORD = 'fakePasswordForAlice' AND LOGIN = FALSE");
63-
session.execute(
64-
"CREATE ROLE IF NOT EXISTS ben WITH PASSWORD = 'fakePasswordForBen' AND LOGIN = TRUE");
65-
session.execute("CREATE ROLE IF NOT EXISTS 'bob@DATASTAX.COM' WITH LOGIN = TRUE");
66-
session.execute(
67-
"CREATE ROLE IF NOT EXISTS 'charlie@DATASTAX.COM' WITH PASSWORD = 'fakePasswordForCharlie' AND LOGIN = TRUE");
68-
session.execute(
69-
"CREATE ROLE IF NOT EXISTS steve WITH PASSWORD = 'fakePasswordForSteve' AND LOGIN = TRUE");
70-
session.execute(
71-
"CREATE KEYSPACE IF NOT EXISTS aliceks WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':'1'}");
72-
session.execute(
73-
"CREATE TABLE IF NOT EXISTS aliceks.alicetable (key text PRIMARY KEY, value text)");
74-
session.execute("INSERT INTO aliceks.alicetable (key, value) VALUES ('hello', 'world')");
75-
session.execute("GRANT ALL ON KEYSPACE aliceks TO alice");
76-
session.execute("GRANT EXECUTE ON ALL AUTHENTICATION SCHEMES TO 'ben'");
77-
session.execute("GRANT EXECUTE ON ALL AUTHENTICATION SCHEMES TO 'bob@DATASTAX.COM'");
78-
session.execute("GRANT EXECUTE ON ALL AUTHENTICATION SCHEMES TO 'steve'");
79-
session.execute("GRANT EXECUTE ON ALL AUTHENTICATION SCHEMES TO 'charlie@DATASTAX.COM'");
80-
session.execute("GRANT PROXY.LOGIN ON ROLE 'alice' TO 'ben'");
81-
session.execute("GRANT PROXY.LOGIN ON ROLE 'alice' TO 'bob@DATASTAX.COM'");
82-
session.execute("GRANT PROXY.EXECUTE ON ROLE 'alice' TO 'steve'");
83-
session.execute("GRANT PROXY.EXECUTE ON ROLE 'alice' TO 'charlie@DATASTAX.COM'");
84-
// ben and bob are allowed to login as alice, but not execute as alice.
85-
// charlie and steve are allowed to execute as alice, but not login as alice.
86-
}
61+
SchemaChangeSynchronizer.withLock(
62+
() -> {
63+
try (CqlSession session = ads.newKeyTabSession()) {
64+
session.execute(
65+
"CREATE ROLE IF NOT EXISTS alice WITH PASSWORD = 'fakePasswordForAlice' AND LOGIN = FALSE");
66+
session.execute(
67+
"CREATE ROLE IF NOT EXISTS ben WITH PASSWORD = 'fakePasswordForBen' AND LOGIN = TRUE");
68+
session.execute("CREATE ROLE IF NOT EXISTS 'bob@DATASTAX.COM' WITH LOGIN = TRUE");
69+
session.execute(
70+
"CREATE ROLE IF NOT EXISTS 'charlie@DATASTAX.COM' WITH PASSWORD = 'fakePasswordForCharlie' AND LOGIN = TRUE");
71+
session.execute(
72+
"CREATE ROLE IF NOT EXISTS steve WITH PASSWORD = 'fakePasswordForSteve' AND LOGIN = TRUE");
73+
session.execute(
74+
"CREATE KEYSPACE IF NOT EXISTS aliceks WITH REPLICATION = {'class':'SimpleStrategy', 'replication_factor':'1'}");
75+
session.execute(
76+
"CREATE TABLE IF NOT EXISTS aliceks.alicetable (key text PRIMARY KEY, value text)");
77+
session.execute(
78+
"INSERT INTO aliceks.alicetable (key, value) VALUES ('hello', 'world')");
79+
session.execute("GRANT ALL ON KEYSPACE aliceks TO alice");
80+
session.execute("GRANT EXECUTE ON ALL AUTHENTICATION SCHEMES TO 'ben'");
81+
session.execute("GRANT EXECUTE ON ALL AUTHENTICATION SCHEMES TO 'bob@DATASTAX.COM'");
82+
session.execute("GRANT EXECUTE ON ALL AUTHENTICATION SCHEMES TO 'steve'");
83+
session.execute(
84+
"GRANT EXECUTE ON ALL AUTHENTICATION SCHEMES TO 'charlie@DATASTAX.COM'");
85+
session.execute("GRANT PROXY.LOGIN ON ROLE 'alice' TO 'ben'");
86+
session.execute("GRANT PROXY.LOGIN ON ROLE 'alice' TO 'bob@DATASTAX.COM'");
87+
session.execute("GRANT PROXY.EXECUTE ON ROLE 'alice' TO 'steve'");
88+
session.execute("GRANT PROXY.EXECUTE ON ROLE 'alice' TO 'charlie@DATASTAX.COM'");
89+
// ben and bob are allowed to login as alice, but not execute as alice.
90+
// charlie and steve are allowed to execute as alice, but not login as alice.
91+
}
92+
});
8793
}
8894
/**
8995
* Validates that a connection may be successfully made as user 'alice' using the credentials of a

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/AsyncResultSetIT.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import com.datastax.oss.driver.api.core.cql.Row;
3030
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
3131
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
32+
import com.datastax.oss.driver.api.testinfra.ccm.SchemaChangeSynchronizer;
3233
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
3334
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
3435
import com.datastax.oss.driver.categories.ParallelizableTests;
@@ -67,13 +68,16 @@ public class AsyncResultSetIT {
6768
@BeforeClass
6869
public static void setupSchema() {
6970
// create table and load data across two partitions so we can test paging across tokens.
70-
SESSION_RULE
71-
.session()
72-
.execute(
73-
SimpleStatement.builder(
74-
"CREATE TABLE IF NOT EXISTS test (k0 text, k1 int, v int, PRIMARY KEY(k0, k1))")
75-
.setExecutionProfile(SESSION_RULE.slowProfile())
76-
.build());
71+
SchemaChangeSynchronizer.withLock(
72+
() -> {
73+
SESSION_RULE
74+
.session()
75+
.execute(
76+
SimpleStatement.builder(
77+
"CREATE TABLE IF NOT EXISTS test (k0 text, k1 int, v int, PRIMARY KEY(k0, k1))")
78+
.setExecutionProfile(SESSION_RULE.slowProfile())
79+
.build());
80+
});
7781

7882
PreparedStatement prepared =
7983
SESSION_RULE.session().prepare("INSERT INTO test (k0, k1, v) VALUES (?, ?, ?)");

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/BatchStatementIT.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import com.datastax.oss.driver.api.core.cql.Statement;
3535
import com.datastax.oss.driver.api.core.servererrors.InvalidQueryException;
3636
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
37+
import com.datastax.oss.driver.api.testinfra.ccm.SchemaChangeSynchronizer;
3738
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
3839
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
3940
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
@@ -72,13 +73,16 @@ public void createTable() {
7273
"CREATE TABLE counter3 (k0 text PRIMARY KEY, c counter)",
7374
};
7475

75-
for (String schemaStatement : schemaStatements) {
76-
sessionRule
77-
.session()
78-
.execute(
79-
SimpleStatement.newInstance(schemaStatement)
80-
.setExecutionProfile(sessionRule.slowProfile()));
81-
}
76+
SchemaChangeSynchronizer.withLock(
77+
() -> {
78+
for (String schemaStatement : schemaStatements) {
79+
sessionRule
80+
.session()
81+
.execute(
82+
SimpleStatement.newInstance(schemaStatement)
83+
.setExecutionProfile(sessionRule.slowProfile()));
84+
}
85+
});
8286
}
8387

8488
@Test

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/BoundStatementCcmIT.java

Lines changed: 39 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.datastax.oss.driver.api.core.metadata.token.Token;
4141
import com.datastax.oss.driver.api.core.type.codec.TypeCodecs;
4242
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
43+
import com.datastax.oss.driver.api.testinfra.ccm.SchemaChangeSynchronizer;
4344
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
4445
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
4546
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
@@ -94,40 +95,44 @@ public class BoundStatementCcmIT {
9495
@Before
9596
public void setupSchema() {
9697
// table where every column forms the primary key.
97-
sessionRule
98-
.session()
99-
.execute(
100-
SimpleStatement.builder(
101-
"CREATE TABLE IF NOT EXISTS test (k text, v int, PRIMARY KEY(k, v))")
102-
.setExecutionProfile(sessionRule.slowProfile())
103-
.build());
104-
for (int i = 0; i < 100; i++) {
105-
sessionRule
106-
.session()
107-
.execute(
108-
SimpleStatement.builder("INSERT INTO test (k, v) VALUES (?, ?)")
109-
.addPositionalValues(KEY, i)
110-
.build());
111-
}
112-
113-
// table with simple primary key, single cell.
114-
sessionRule
115-
.session()
116-
.execute(
117-
SimpleStatement.builder("CREATE TABLE IF NOT EXISTS test2 (k text primary key, v0 int)")
118-
.setExecutionProfile(sessionRule.slowProfile())
119-
.build());
120-
121-
// table with composite partition key
122-
sessionRule
123-
.session()
124-
.execute(
125-
SimpleStatement.builder(
126-
"CREATE TABLE IF NOT EXISTS test3 "
127-
+ "(pk1 int, pk2 int, v int, "
128-
+ "PRIMARY KEY ((pk1, pk2)))")
129-
.setExecutionProfile(sessionRule.slowProfile())
130-
.build());
98+
SchemaChangeSynchronizer.withLock(
99+
() -> {
100+
sessionRule
101+
.session()
102+
.execute(
103+
SimpleStatement.builder(
104+
"CREATE TABLE IF NOT EXISTS test (k text, v int, PRIMARY KEY(k, v))")
105+
.setExecutionProfile(sessionRule.slowProfile())
106+
.build());
107+
for (int i = 0; i < 100; i++) {
108+
sessionRule
109+
.session()
110+
.execute(
111+
SimpleStatement.builder("INSERT INTO test (k, v) VALUES (?, ?)")
112+
.addPositionalValues(KEY, i)
113+
.build());
114+
}
115+
116+
// table with simple primary key, single cell.
117+
sessionRule
118+
.session()
119+
.execute(
120+
SimpleStatement.builder(
121+
"CREATE TABLE IF NOT EXISTS test2 (k text primary key, v0 int)")
122+
.setExecutionProfile(sessionRule.slowProfile())
123+
.build());
124+
125+
// table with composite partition key
126+
sessionRule
127+
.session()
128+
.execute(
129+
SimpleStatement.builder(
130+
"CREATE TABLE IF NOT EXISTS test3 "
131+
+ "(pk1 int, pk2 int, v int, "
132+
+ "PRIMARY KEY ((pk1, pk2)))")
133+
.setExecutionProfile(sessionRule.slowProfile())
134+
.build());
135+
});
131136
}
132137

133138
@Test

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/ExecutionInfoWarningsIT.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
3434
import com.datastax.oss.driver.api.core.cql.Statement;
3535
import com.datastax.oss.driver.api.testinfra.ccm.CustomCcmRule;
36+
import com.datastax.oss.driver.api.testinfra.ccm.SchemaChangeSynchronizer;
3637
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
3738
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
3839
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
@@ -88,12 +89,16 @@ public class ExecutionInfoWarningsIT {
8889
@Before
8990
public void createSchema() {
9091
// table with simple primary key, single cell.
91-
sessionRule
92-
.session()
93-
.execute(
94-
SimpleStatement.builder("CREATE TABLE IF NOT EXISTS test (k int primary key, v text)")
95-
.setExecutionProfile(sessionRule.slowProfile())
96-
.build());
92+
SchemaChangeSynchronizer.withLock(
93+
() -> {
94+
sessionRule
95+
.session()
96+
.execute(
97+
SimpleStatement.builder(
98+
"CREATE TABLE IF NOT EXISTS test (k int primary key, v text)")
99+
.setExecutionProfile(sessionRule.slowProfile())
100+
.build());
101+
});
97102
for (int i = 0; i < 100; i++) {
98103
sessionRule
99104
.session()

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PagingStateIT.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.datastax.oss.driver.api.core.type.codec.MappingCodec;
3131
import com.datastax.oss.driver.api.core.type.reflect.GenericType;
3232
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
33+
import com.datastax.oss.driver.api.testinfra.ccm.SchemaChangeSynchronizer;
3334
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
3435
import com.datastax.oss.driver.api.testinfra.session.SessionUtils;
3536
import com.datastax.oss.driver.categories.ParallelizableTests;
@@ -55,11 +56,14 @@ public class PagingStateIT {
5556
@Before
5657
public void setupSchema() {
5758
CqlSession session = SESSION_RULE.session();
58-
session.execute(
59-
SimpleStatement.builder(
60-
"CREATE TABLE IF NOT EXISTS foo (k int, cc int, v int, PRIMARY KEY(k, cc))")
61-
.setExecutionProfile(SESSION_RULE.slowProfile())
62-
.build());
59+
SchemaChangeSynchronizer.withLock(
60+
() -> {
61+
session.execute(
62+
SimpleStatement.builder(
63+
"CREATE TABLE IF NOT EXISTS foo (k int, cc int, v int, PRIMARY KEY(k, cc))")
64+
.setExecutionProfile(SESSION_RULE.slowProfile())
65+
.build());
66+
});
6367
for (int i = 0; i < 20; i++) {
6468
session.execute(
6569
SimpleStatement.newInstance("INSERT INTO foo (k, cc, v) VALUES (1, ?, ?)", i, i));

integration-tests/src/test/java/com/datastax/oss/driver/core/cql/PerRequestKeyspaceIT.java

Lines changed: 34 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import com.datastax.oss.driver.api.core.cql.SimpleStatement;
3232
import com.datastax.oss.driver.api.core.cql.Statement;
3333
import com.datastax.oss.driver.api.testinfra.ccm.CcmRule;
34+
import com.datastax.oss.driver.api.testinfra.ccm.SchemaChangeSynchronizer;
3435
import com.datastax.oss.driver.api.testinfra.requirement.BackendRequirement;
3536
import com.datastax.oss.driver.api.testinfra.requirement.BackendType;
3637
import com.datastax.oss.driver.api.testinfra.session.SessionRule;
@@ -67,13 +68,16 @@ public class PerRequestKeyspaceIT {
6768

6869
@Before
6970
public void setupSchema() {
70-
sessionRule
71-
.session()
72-
.execute(
73-
SimpleStatement.builder(
74-
"CREATE TABLE IF NOT EXISTS foo (k text, cc int, v int, PRIMARY KEY(k, cc))")
75-
.setExecutionProfile(sessionRule.slowProfile())
76-
.build());
71+
SchemaChangeSynchronizer.withLock(
72+
() -> {
73+
sessionRule
74+
.session()
75+
.execute(
76+
SimpleStatement.builder(
77+
"CREATE TABLE IF NOT EXISTS foo (k text, cc int, v int, PRIMARY KEY(k, cc))")
78+
.setExecutionProfile(sessionRule.slowProfile())
79+
.build());
80+
});
7781
}
7882

7983
@Test
@@ -220,27 +224,31 @@ public void should_prepare_statement_with_keyspace() {
220224
@BackendRequirement(type = BackendType.CASSANDRA, minInclusive = "4.0")
221225
public void should_reprepare_statement_with_keyspace_on_the_fly() {
222226
// Create a separate session because we don't want it to have a default keyspace
223-
try (CqlSession session = SessionUtils.newSession(ccmRule)) {
224-
executeDdl(
225-
session,
226-
String.format(
227-
"CREATE TABLE IF NOT EXISTS %s.bar (k int primary key)", sessionRule.keyspace()));
228-
PreparedStatement pst =
229-
session.prepare(
230-
SimpleStatement.newInstance("SELECT * FROM bar WHERE k=?")
231-
.setKeyspace(sessionRule.keyspace()));
227+
SchemaChangeSynchronizer.withLock(
228+
() -> {
229+
try (CqlSession session = SessionUtils.newSession(ccmRule)) {
230+
executeDdl(
231+
session,
232+
String.format(
233+
"CREATE TABLE IF NOT EXISTS %s.bar (k int primary key)",
234+
sessionRule.keyspace()));
235+
PreparedStatement pst =
236+
session.prepare(
237+
SimpleStatement.newInstance("SELECT * FROM bar WHERE k=?")
238+
.setKeyspace(sessionRule.keyspace()));
232239

233-
// Drop and re-create the table to invalidate the prepared statement server side
234-
executeDdl(session, String.format("DROP TABLE %s.bar", sessionRule.keyspace()));
235-
executeDdl(
236-
session,
237-
String.format("CREATE TABLE %s.bar (k int primary key)", sessionRule.keyspace()));
238-
assertThat(preparedStatementExistsOnServer(session, pst.getId())).isFalse();
240+
// Drop and re-create the table to invalidate the prepared statement server side
241+
executeDdl(session, String.format("DROP TABLE %s.bar", sessionRule.keyspace()));
242+
executeDdl(
243+
session,
244+
String.format("CREATE TABLE %s.bar (k int primary key)", sessionRule.keyspace()));
245+
assertThat(preparedStatementExistsOnServer(session, pst.getId())).isFalse();
239246

240-
// This will re-prepare on the fly
241-
session.execute(pst.bind(0));
242-
assertThat(preparedStatementExistsOnServer(session, pst.getId())).isTrue();
243-
}
247+
// This will re-prepare on the fly
248+
session.execute(pst.bind(0));
249+
assertThat(preparedStatementExistsOnServer(session, pst.getId())).isTrue();
250+
}
251+
});
244252
}
245253

246254
private void executeDdl(CqlSession session, String query) {

0 commit comments

Comments
 (0)