This is an automated email from the ASF dual-hosted git repository.

dcapwell pushed a commit to branch cassandra-2.2
in repository https://gitbox.apache.org/repos/asf/cassandra.git


The following commit(s) were added to refs/heads/cassandra-2.2 by this push:
     new 4d1d024  jvm dtest is strict on properties which causes upgrade tests 
to fail
4d1d024 is described below

commit 4d1d024136dd5f4b3775a0666b0c30a65641d57f
Author: David Capwell <[email protected]>
AuthorDate: Tue Nov 10 10:00:20 2020 -0800

    jvm dtest is strict on properties which causes upgrade tests to fail
    
    patch by David Capwell; reviewed by Caleb Rackliffe, Ekaterina Dimitrova, 
Jordan West, Yifan Cai for CASSANDRA-16256
---
 .../cassandra/config/YamlConfigurationLoader.java  | 10 +++++--
 .../apache/cassandra/distributed/Constants.java    | 34 ++++++++++++++++++++++
 .../cassandra/distributed/UpgradeableCluster.java  |  1 +
 .../distributed/impl/AbstractCluster.java          |  3 +-
 .../cassandra/distributed/impl/Instance.java       |  6 +++-
 5 files changed, 50 insertions(+), 4 deletions(-)

diff --git a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java 
b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java
index 2ca978f..49418ac 100644
--- a/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java
+++ b/src/java/org/apache/cassandra/config/YamlConfigurationLoader.java
@@ -127,9 +127,14 @@ public class YamlConfigurationLoader implements 
ConfigurationLoader
         }
     }
 
-    @SuppressWarnings("unchecked") //getSingleData returns Object, not T
     public static <T> T fromMap(Map<String,Object> map, Class<T> klass)
     {
+        return fromMap(map, true, klass);
+    }
+
+    @SuppressWarnings("unchecked") //getSingleData returns Object, not T
+    public static <T> T fromMap(Map<String,Object> map, boolean shouldCheck, 
Class<T> klass)
+    {
         Constructor constructor = new 
YamlConfigurationLoader.CustomConstructor(klass, klass.getClassLoader());
         YamlConfigurationLoader.MissingPropertiesChecker propertiesChecker = 
new YamlConfigurationLoader.MissingPropertiesChecker();
         constructor.setPropertyUtils(propertiesChecker);
@@ -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 0000000..b7d2d26
--- /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 bde5d4e..8653e47 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<IUpgradeableInstance> 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 5f2b624..094604c 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<I extends IInstance> 
implements ICluster<I
         NetworkTopology topology = NetworkTopology.build(ipPrefix, 
broadcastPort, nodeIdTopology);
 
         InstanceConfig config = InstanceConfig.generate(nodeNum, ipAddress, 
topology, root, String.valueOf(token), seedIp, datadirCount);
-        config.set("dtest.api.cluster_id", clusterId.toString());
+        config.set(Constants.KEY_DTEST_API_CLUSTER_ID, clusterId.toString());
         if (configUpdater != null)
             configUpdater.accept(config);
 
diff --git 
a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java 
b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
index 13179c0..82251d7 100644
--- a/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
+++ b/test/distributed/org/apache/cassandra/distributed/impl/Instance.java
@@ -67,6 +67,7 @@ import org.apache.cassandra.db.commitlog.CommitLog;
 import org.apache.cassandra.db.compaction.CompactionManager;
 import org.apache.cassandra.dht.IPartitioner;
 import org.apache.cassandra.dht.Token;
+import org.apache.cassandra.distributed.Constants;
 import org.apache.cassandra.distributed.api.ICluster;
 import org.apache.cassandra.distributed.api.ICoordinator;
 import org.apache.cassandra.distributed.api.IInstance;
@@ -625,7 +626,10 @@ public class Instance extends IsolatedExecutor implements 
IInvokableInstance
     private static Config loadConfig(IInstanceConfig overrides)
     {
         Map<String,Object> 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)


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to