@@ -66,16 +66,21 @@ public class LocalClusterFactory implements ClusterFactory<LocalClusterSpec, Loc
66
66
private static final String ENABLE_DEBUG_JVM_ARGS = "-agentlib:jdwp=transport=dt_socket,server=n,suspend=y,address=" ;
67
67
private static final int DEFAULT_DEBUG_PORT = 5007 ;
68
68
69
- private final Path baseWorkingDir ;
70
69
private final DistributionResolver distributionResolver ;
70
+ private Path baseWorkingDir ;
71
71
72
- public LocalClusterFactory (Path baseWorkingDir , DistributionResolver distributionResolver ) {
73
- this .baseWorkingDir = baseWorkingDir ;
72
+ public LocalClusterFactory (DistributionResolver distributionResolver ) {
74
73
this .distributionResolver = distributionResolver ;
75
74
}
76
75
77
76
@ Override
78
77
public LocalClusterHandle create (LocalClusterSpec spec ) {
78
+ try {
79
+ this .baseWorkingDir = Files .createTempDirectory (spec .getName ());
80
+ } catch (IOException e ) {
81
+ throw new UncheckedIOException (e );
82
+ }
83
+
79
84
return new LocalClusterHandle (spec .getName (), spec .getNodes ().stream ().map (Node ::new ).toList ());
80
85
}
81
86
@@ -95,7 +100,7 @@ public class Node {
95
100
96
101
public Node (LocalNodeSpec spec ) {
97
102
this .spec = spec ;
98
- this .workingDir = baseWorkingDir .resolve (spec .getCluster (). getName ()). resolve ( spec . getName ());
103
+ this .workingDir = baseWorkingDir .resolve (spec .getName ());
99
104
this .repoDir = baseWorkingDir .resolve ("repo" );
100
105
this .dataDir = workingDir .resolve ("data" );
101
106
this .logsDir = workingDir .resolve ("logs" );
@@ -127,6 +132,7 @@ public synchronized void start(Version version) {
127
132
copyExtraConfigFiles ();
128
133
}
129
134
135
+ deleteGcLogs ();
130
136
writeConfiguration ();
131
137
createKeystore ();
132
138
addKeystoreSettings ();
@@ -209,6 +215,20 @@ public void waitUntilReady() {
209
215
}
210
216
}
211
217
218
+ private void deleteGcLogs () {
219
+ try (Stream <Path > logs = Files .list (logsDir )) {
220
+ logs .filter (l -> l .getFileName ().toString ().startsWith ("gc.log" )).forEach (path -> {
221
+ try {
222
+ IOUtils .deleteWithRetry (path );
223
+ } catch (IOException e ) {
224
+ throw new UncheckedIOException (e );
225
+ }
226
+ });
227
+ } catch (IOException e ) {
228
+ throw new UncheckedIOException (e );
229
+ }
230
+ }
231
+
212
232
private void createConfigDirectory () {
213
233
try {
214
234
IOUtils .deleteWithRetry (configDir );
@@ -271,7 +291,8 @@ private void initializeWorkingDirectory(boolean preserveWorkingDirectory) {
271
291
private boolean canUseSharedDistribution () {
272
292
return OS .current () != WINDOWS // Issues with long file paths on Windows in CI
273
293
&& System .getProperty (TESTS_CLUSTER_FIPS_JAR_PATH_SYSPROP ) == null
274
- && (distributionDescriptor .getType () == DEFAULT || (getSpec ().getPlugins ().isEmpty () && getSpec ().getModules ().isEmpty ()));
294
+ && getSpec ().getPlugins ().isEmpty ()
295
+ && (distributionDescriptor .getType () == DEFAULT || getSpec ().getModules ().isEmpty ());
275
296
}
276
297
277
298
private void copyExtraJarFiles () {
@@ -607,7 +628,7 @@ private Map<String, String> getJvmOptionsReplacements() {
607
628
608
629
private void runToolScript (String tool , String input , String ... args ) {
609
630
try {
610
- ProcessUtils .exec (
631
+ int exit = ProcessUtils .exec (
611
632
input ,
612
633
distributionDir ,
613
634
distributionDir .resolve ("bin" )
@@ -616,13 +637,17 @@ private void runToolScript(String tool, String input, String... args) {
616
637
false ,
617
638
args
618
639
).waitFor ();
640
+
641
+ if (exit != 0 ) {
642
+ throw new RuntimeException ("Execution of " + tool + " failed with exit code " + exit );
643
+ }
619
644
} catch (InterruptedException e ) {
620
645
throw new RuntimeException (e );
621
646
}
622
647
}
623
648
624
649
private String getServiceName () {
625
- return baseWorkingDir .getFileName () + "-" + spec .getCluster (). getName () + "-" + spec . getName ();
650
+ return baseWorkingDir .getFileName () + "-" + spec .getName ();
626
651
}
627
652
628
653
@ Override
0 commit comments