Skip to content
This repository was archived by the owner on Apr 5, 2022. It is now read-only.

Commit 5abfa9f

Browse files
committed
SHDP-533 Fix MR minicluster test dirs
- Change cluster creation so that identifiers are properly handled to separate working directories which should allow logs to stay in place after test failures.
1 parent 011bc03 commit 5abfa9f

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

spring-hadoop-test/src/main/java/org/springframework/data/hadoop/test/support/HadoopClusterManager.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public HadoopCluster getCluster(ClusterInfo clusterInfo) {
9191
log.info("Building new cluster for ClusterInfo=" + clusterInfo);
9292
try {
9393
HadoopClusterFactoryBean fb = new HadoopClusterFactoryBean();
94-
fb.setClusterId("hadoop-" + clusterInfo.hashCode());
94+
fb.setClusterId("hadoop-" + clusterInfo.getId() + "-" + clusterInfo.hashCode());
9595
fb.setAutoStart(true);
9696
fb.afterPropertiesSet();
9797
cluster = fb.getObject();

spring-hadoop-test/src/main/java/org/springframework/data/hadoop/test/support/StandaloneHadoopCluster.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void start() throws IOException {
140140
log.info("Dfs cluster uri= " + fs.getUri());
141141

142142
mrClusterObject = MiniMRClusterCompat.instantiateCluster(this.getClass(),
143-
nodes, config, fs, this.getClass().getClassLoader());
143+
clusterName, nodes, config, fs, this.getClass().getClassLoader());
144144

145145
configuration = MiniMRClusterCompat.getConfiguration(mrClusterObject);
146146

spring-hadoop-test/src/main/java/org/springframework/data/hadoop/test/support/compat/MiniMRClusterCompat.java

+5-3
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,14 @@ public abstract class MiniMRClusterCompat {
5656
* Instantiates a minimrcluster.
5757
*
5858
* @param caller the one who called this method
59+
* @param identifier the cluster identifier
5960
* @param nodes number of nodes
6061
* @param configuration passed configuration
6162
* @param fileSystem hdfs filesystem
6263
* @param classLoader the class loader
6364
* @return the cluster object
6465
*/
65-
public static Object instantiateCluster(Class<?> caller, int nodes,
66+
public static Object instantiateCluster(Class<?> caller, String identifier, int nodes,
6667
Configuration configuration, FileSystem fileSystem,
6768
ClassLoader classLoader) {
6869

@@ -78,8 +79,9 @@ public static Object instantiateCluster(Class<?> caller, int nodes,
7879
log.info("Cluster classes resolved, factory=" + factoryClass + " legacy=" + legacyClass);
7980

8081
if (factoryClass != null) {
81-
Method method = ReflectionUtils.findMethod(factoryClass, "create", Class.class, int.class, Configuration.class);
82-
cluster = ReflectionUtils.invokeMethod(method, null, caller, nodes, configuration);
82+
Method method = ReflectionUtils.findMethod(factoryClass, "create", Class.class, String.class, int.class,
83+
Configuration.class);
84+
cluster = ReflectionUtils.invokeMethod(method, null, caller, identifier, nodes, configuration);
8385
} else if (legacyClass != null) {
8486
Constructor<?> constructor = ClassUtils.getConstructorIfAvailable(legacyClass, int.class, String.class, int.class);
8587
cluster = BeanUtils.instantiateClass(constructor, nodes, fileSystem.getUri().toString(), 1);

0 commit comments

Comments
 (0)