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
This commit is contained in:
David Capwell 2020-11-10 10:00:20 -08:00
parent f293376aa8
commit 4d1d024136
5 changed files with 50 additions and 4 deletions

View File

@ -127,8 +127,13 @@ 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();
@ -144,7 +149,8 @@ public class YamlConfigurationLoader implements ConfigurationLoader
}
});
T value = (T) constructor.getSingleData(klass);
propertiesChecker.check();
if (shouldCheck)
propertiesChecker.check();
return value;
}

View File

@ -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";
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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)