diff --git a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java index 2ca978f078..49418ac9f2 100644 --- a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java +++ b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java @@ -127,8 +127,13 @@ public class YamlConfigurationLoader implements ConfigurationLoader } } - @SuppressWarnings("unchecked") //getSingleData returns Object, not T public static T fromMap(Map map, Class klass) + { + return fromMap(map, true, klass); + } + + @SuppressWarnings("unchecked") //getSingleData returns Object, not T + public static T fromMap(Map map, boolean shouldCheck, Class klass) { Constructor constructor = new YamlConfigurationLoader.CustomConstructor(klass, klass.getClassLoader()); YamlConfigurationLoader.MissingPropertiesChecker propertiesChecker = new YamlConfigurationLoader.MissingPropertiesChecker(); @@ -144,7 +149,8 @@ public class YamlConfigurationLoader implements ConfigurationLoader } }); T value = (T) constructor.getSingleData(klass); - propertiesChecker.check(); + if (shouldCheck) + propertiesChecker.check(); return value; } diff --git a/test/distributed/org/apache/cassandra/distributed/Constants.java b/test/distributed/org/apache/cassandra/distributed/Constants.java new file mode 100644 index 0000000000..b7d2d26104 --- /dev/null +++ b/test/distributed/org/apache/cassandra/distributed/Constants.java @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.cassandra.distributed; + +public final class Constants +{ + /** + * Property defined in {@link org.apache.cassandra.distributed.api.IInstanceConfig} which references the ID of the + * {@link org.apache.cassandra.distributed.api.ICluster}. + */ + public static final String KEY_DTEST_API_CLUSTER_ID = "dtest.api.cluster_id"; + + /** + * Property used by Instances to determine if checking YAML configuration is required; set to false if validation + * of the YAML is not desired. + */ + public static final String KEY_DTEST_API_CONFIG_CHECK = "dtest.api.config.check"; +} diff --git a/test/distributed/org/apache/cassandra/distributed/UpgradeableCluster.java b/test/distributed/org/apache/cassandra/distributed/UpgradeableCluster.java index bde5d4ea83..8653e47ee0 100644 --- a/test/distributed/org/apache/cassandra/distributed/UpgradeableCluster.java +++ b/test/distributed/org/apache/cassandra/distributed/UpgradeableCluster.java @@ -43,6 +43,7 @@ public class UpgradeableCluster extends AbstractCluster im protected IUpgradeableInstance newInstanceWrapper(int generation, Versions.Version version, IInstanceConfig config) { + config.set(Constants.KEY_DTEST_API_CONFIG_CHECK, false); return new Wrapper(generation, version, config); } diff --git a/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java b/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java index 5f2b6248c8..094604c84e 100644 --- a/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java +++ b/test/distributed/org/apache/cassandra/distributed/impl/AbstractCluster.java @@ -47,6 +47,7 @@ import org.apache.cassandra.db.ColumnFamilyStore; import org.apache.cassandra.db.Keyspace; import org.apache.cassandra.dht.IPartitioner; import org.apache.cassandra.dht.Token; +import org.apache.cassandra.distributed.Constants; import org.apache.cassandra.distributed.api.ConsistencyLevel; import org.apache.cassandra.distributed.api.Feature; import org.apache.cassandra.distributed.api.ICluster; @@ -330,7 +331,7 @@ public abstract class AbstractCluster implements ICluster params = ((InstanceConfig) overrides).getParams(); - return YamlConfigurationLoader.fromMap(params, Config.class); + boolean check = true; + if (overrides.get(Constants.KEY_DTEST_API_CONFIG_CHECK) != null) + check = (boolean) overrides.get(Constants.KEY_DTEST_API_CONFIG_CHECK); + return YamlConfigurationLoader.fromMap(params, check, Config.class); } private void initializeRing(ICluster cluster)