kikocis/java-driver public
Changesets · Branches · Tags · Compare
| Changeset | 7447708e99578660681cba370874b4aa20bef30b215f14a59464050a4a03d113 |
|---|---|
| Author | Andrew Tolbert <andrew.tolbert@datastax.com> · 2016-01-14 23:54 -06:00 |
| Committer | Alexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-16 18:51 +01:00 |
| Parents | a09129ebe89a |
2 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/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 |