Elffuss BraidHub

kikocis/java-driver public

Suppress enable_user_defined_functions for < 2.2, use for exception test.
Changeset7447708e99578660681cba370874b4aa20bef30b215f14a59464050a4a03d113
AuthorAndrew Tolbert <andrew.tolbert@datastax.com> · 2016-01-14 23:54 -06:00
CommitterAlexandre Dutra <alexandre.dutra@datastax.com> · 2016-01-16 18:51 +01:00
Parentsa09129ebe89a

Browse the files at this changeset

2 files changed

modified driver-core/src/test/java/com/datastax/driver/core/CCMTestsSupport.java +21 −0
@@ -18,6 +18,7 @@
1818 import com.datastax.driver.core.CreateCCM.TestMode;
1919 import com.google.common.base.Throwables;
2020 import com.google.common.cache.*;
21+import com.google.common.collect.ImmutableMap;
2122 import com.google.common.collect.Lists;
2223 import com.google.common.io.Closer;
2324 import com.google.common.util.concurrent.MoreExecutors;
@@ -54,6 +55,13 @@
5455
5556 private static final List<String> TEST_GROUPS = Lists.newArrayList("isolated", "short", "long", "stress", "duration");
5657
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+
5765
5866 private static class ReadOnlyCCMBridge implements CCMAccess {
5967
@@ -290,12 +298,25 @@
290298 }
291299
292300 private void addConfigOptions(String[] conf, Map<String, Object> config) {
301+ String versionStr = version();
302+ VersionNumber version = VersionNumber.parse(versionStr != null ?
303+ versionStr : CCMBridge.getCassandraVersion());
293304 for (String aConf : conf) {
294305 String[] tokens = aConf.split(":");
295306 if (tokens.length != 2)
296307 fail("Wrong configuration option: " + aConf);
297308 String key = tokens[0];
298309 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+ }
299320 config.put(key, value);
300321 }
301322 }
modified driver-core/src/test/java/com/datastax/driver/core/exceptions/FunctionExecutionExceptionTest.java +2 −0
@@ -15,6 +15,7 @@
1515 */
1616 package com.datastax.driver.core.exceptions;
1717
18+import com.datastax.driver.core.CCMConfig;
1819 import com.datastax.driver.core.CCMTestsSupport;
1920 import com.datastax.driver.core.utils.CassandraVersion;
2021 import com.google.common.collect.Lists;
@@ -23,6 +24,7 @@
2324 import java.util.Collection;
2425
2526 @CassandraVersion(major = 2.2)
27+@CCMConfig(config = "enable_user_defined_functions:true")
2628 public class FunctionExecutionExceptionTest extends CCMTestsSupport {
2729
2830 @Override