kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | a33a06b447d738bc66f3ea15ba5243e89e83a71e4356f6833e2bfbb95f0847b4 |
|---|---|
| Author | Alexandre Dutra <adutra@users.noreply.github.com> · 2016-01-16 20:02 +01:00 |
| Committer | Alexandre Dutra <adutra@users.noreply.github.com> · 2016-01-16 20:02 +01:00 |
| Parents | a09129ebe89a, e7dd5f832671 |
3 files changed
modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +21 −0
| @@ -18,6 +18,7 @@ | ||
| 18 | 18 | import com.datastax.driver.core.CreateCCM.TestMode; |
| 19 | 19 | import com.google.common.base.Throwables; |
| 20 | 20 | import com.google.common.cache.*; |
| 21 | +import com.google.common.collect.ImmutableMap; | |
| 21 | 22 | import com.google.common.collect.Lists; |
| 22 | 23 | import com.google.common.io.Closer; |
| 23 | 24 | import com.google.common.util.concurrent.MoreExecutors; |
| @@ -54,6 +55,13 @@ | ||
| 54 | 55 | |
| 55 | 56 | private static final List<String> TEST_GROUPS = Lists.newArrayList("isolated", "short", "long", "stress", "duration"); |
| 56 | 57 | |
| 58 | + // A mapping of cassandra.yaml config options to their version requirements. | |
| 59 | + // If a config is passed containing one of these options and the version requirement cannot be met | |
| 60 | + // the option is simply filtered. | |
| 61 | + private static final Map<String, VersionNumber> configVersionRequirements = ImmutableMap.<String, VersionNumber>builder() | |
| 62 | + .put("enable_user_defined_functions", VersionNumber.parse("2.2.0")) | |
| 63 | + .build(); | |
| 64 | + | |
| 57 | 65 | |
| 58 | 66 | private static class ReadOnlyCCMBridge implements CCMAccess { |
| 59 | 67 | |
| @@ -290,12 +298,25 @@ | ||
| 290 | 298 | } |
| 291 | 299 | |
| 292 | 300 | private void addConfigOptions(String[] conf, Map<String, Object> config) { |
| 301 | + String versionStr = version(); | |
| 302 | + VersionNumber version = VersionNumber.parse(versionStr != null ? | |
| 303 | + versionStr : CCMBridge.getCassandraVersion()); | |
| 293 | 304 | for (String aConf : conf) { |
| 294 | 305 | String[] tokens = aConf.split(":"); |
| 295 | 306 | if (tokens.length != 2) |
| 296 | 307 | fail("Wrong configuration option: " + aConf); |
| 297 | 308 | String key = tokens[0]; |
| 298 | 309 | String value = tokens[1]; |
| 310 | + // If we've detected a property with a version requirement, skip it if the version requirement | |
| 311 | + // cannot be met. | |
| 312 | + if (configVersionRequirements.containsKey(key)) { | |
| 313 | + VersionNumber requirement = configVersionRequirements.get(key); | |
| 314 | + if (version.compareTo(requirement) < 0) { | |
| 315 | + LOGGER.debug("Skipping inclusion of '{}' in cassandra.yaml since it requires >= C* {} and {} " + | |
| 316 | + "was detected.", aConf, requirement, version); | |
| 317 | + continue; | |
| 318 | + } | |
| 319 | + } | |
| 299 | 320 | config.put(key, value); |
| 300 | 321 | } |
| 301 | 322 | } |
modified driver-core/src/test/java/com/datastax/driver/core/PreparedStatementTest.java +5 −1
| @@ -18,10 +18,12 @@ | ||
| 18 | 18 | import com.datastax.driver.core.exceptions.InvalidQueryException; |
| 19 | 19 | import com.datastax.driver.core.exceptions.UnsupportedFeatureException; |
| 20 | 20 | import com.datastax.driver.core.utils.CassandraVersion; |
| 21 | +import com.google.common.util.concurrent.Uninterruptibles; | |
| 21 | 22 | import org.testng.annotations.Test; |
| 22 | 23 | |
| 23 | 24 | import java.net.InetAddress; |
| 24 | 25 | import java.util.*; |
| 26 | +import java.util.concurrent.TimeUnit; | |
| 25 | 27 | |
| 26 | 28 | import static com.datastax.driver.core.TestUtils.*; |
| 27 | 29 | import static org.assertj.core.api.Assertions.assertThat; |
| @@ -609,7 +611,7 @@ | ||
| 609 | 611 | * @jira_ticket JAVA-777 |
| 610 | 612 | * @since 2.2.0 |
| 611 | 613 | */ |
| 612 | - @Test(groups = "short") | |
| 614 | + @Test(groups = "long") | |
| 613 | 615 | public void should_create_tombstone_when_null_value_on_bound_statement() { |
| 614 | 616 | PreparedStatement prepared = session.prepare("INSERT INTO " + SIMPLE_TABLE + " (k, i) VALUES (?, ?)"); |
| 615 | 617 | BoundStatement st1 = prepared.bind(); |
| @@ -620,6 +622,8 @@ | ||
| 620 | 622 | st2.enableTracing(); |
| 621 | 623 | ResultSet rows = session.execute(st2); |
| 622 | 624 | assertThat(rows.one().isNull(0)).isTrue(); |
| 625 | + // sleep 1 minute to make sure the trace will be complete | |
| 626 | + Uninterruptibles.sleepUninterruptibly(1, TimeUnit.MINUTES); | |
| 623 | 627 | QueryTrace queryTrace = rows.getExecutionInfo().getQueryTrace(); |
| 624 | 628 | assertEventsContain(queryTrace, "1 tombstone"); |
| 625 | 629 | } |
modified driver-core/src/test/java/com/datastax/driver/core/exceptions/FunctionExecutionExceptionTest.java +2 −0
| @@ -15,6 +15,7 @@ | ||
| 15 | 15 | */ |
| 16 | 16 | package com.datastax.driver.core.exceptions; |
| 17 | 17 | |
| 18 | +import com.datastax.driver.core.CCMConfig; | |
| 18 | 19 | import com.datastax.driver.core.CCMTestsSupport; |
| 19 | 20 | import com.datastax.driver.core.utils.CassandraVersion; |
| 20 | 21 | import com.google.common.collect.Lists; |
| @@ -23,6 +24,7 @@ | ||
| 23 | 24 | import java.util.Collection; |
| 24 | 25 | |
| 25 | 26 | @CassandraVersion(major = 2.2) |
| 27 | +@CCMConfig(config = "enable_user_defined_functions:true") | |
| 26 | 28 | public class FunctionExecutionExceptionTest extends CCMTestsSupport { |
| 27 | 29 | |
| 28 | 30 | @Override |