@@ -124,6 +124,7 @@ public class ElasticsearchNode implements TestClusterConfiguration {
124
124
private final LazyPropertyMap <String , CharSequence > settings = new LazyPropertyMap <>("Settings" , this );
125
125
private final LazyPropertyMap <String , CharSequence > keystoreSettings = new LazyPropertyMap <>("Keystore" , this );
126
126
private final LazyPropertyMap <String , File > keystoreFiles = new LazyPropertyMap <>("Keystore files" , this , FileEntry ::new );
127
+ private final LazyPropertyList <CliEntry > cliSetup = new LazyPropertyList <>("CLI setup commands" , this );
127
128
private final LazyPropertyMap <String , CharSequence > systemProperties = new LazyPropertyMap <>("System properties" , this );
128
129
private final LazyPropertyMap <String , CharSequence > environment = new LazyPropertyMap <>("Environment" , this );
129
130
private final LazyPropertyList <CharSequence > jvmArgs = new LazyPropertyList <>("JVM arguments" , this );
@@ -301,6 +302,11 @@ public void keystore(String key, FileSupplier valueSupplier) {
301
302
keystoreFiles .put (key , valueSupplier );
302
303
}
303
304
305
+ @ Override
306
+ public void cliSetup (String binTool , CharSequence ... args ) {
307
+ cliSetup .add (new CliEntry (binTool , args ));
308
+ }
309
+
304
310
@ Override
305
311
public void setting (String key , String value ) {
306
312
settings .put (key , value );
@@ -475,6 +481,14 @@ public synchronized void start() {
475
481
));
476
482
}
477
483
484
+ if (cliSetup .isEmpty () == false ) {
485
+ logToProcessStdout ("Running " + cliSetup .size () + " setup commands" );
486
+
487
+ for (CliEntry entry : cliSetup ) {
488
+ runElasticsearchBinScript (entry .executable , entry .args );
489
+ }
490
+ }
491
+
478
492
logToProcessStdout ("Starting Elasticsearch process" );
479
493
startElasticsearchProcess ();
480
494
}
@@ -623,7 +637,7 @@ public void user(Map<String, String> userSpec) {
623
637
credentials .add (cred );
624
638
}
625
639
626
- private void runElasticsearchBinScriptWithInput (String input , String tool , String ... args ) {
640
+ private void runElasticsearchBinScriptWithInput (String input , String tool , CharSequence ... args ) {
627
641
if (
628
642
Files .exists (getDistroDir ().resolve ("bin" ).resolve (tool )) == false &&
629
643
Files .exists (getDistroDir ().resolve ("bin" ).resolve (tool + ".bat" )) == false
@@ -642,12 +656,12 @@ private void runElasticsearchBinScriptWithInput(String input, String tool, Strin
642
656
.supply ()
643
657
);
644
658
spec .args (
645
- OS .<List <String >>conditional ()
659
+ OS .<List <CharSequence >>conditional ()
646
660
.onWindows (() -> {
647
- ArrayList <String > result = new ArrayList <>();
661
+ ArrayList <CharSequence > result = new ArrayList <>();
648
662
result .add ("/c" );
649
663
result .add ("bin\\ " + tool + ".bat" );
650
- for (String arg : args ) {
664
+ for (CharSequence arg : args ) {
651
665
result .add (arg );
652
666
}
653
667
return result ;
@@ -663,7 +677,7 @@ private void runElasticsearchBinScriptWithInput(String input, String tool, Strin
663
677
}
664
678
}
665
679
666
- private void runElasticsearchBinScript (String tool , String ... args ) {
680
+ private void runElasticsearchBinScript (String tool , CharSequence ... args ) {
667
681
runElasticsearchBinScriptWithInput ("" , tool , args );
668
682
}
669
683
@@ -1205,6 +1219,11 @@ public List<?> getKeystoreFiles() {
1205
1219
return keystoreFiles .getNormalizedCollection ();
1206
1220
}
1207
1221
1222
+ @ Nested
1223
+ public List <?> getCliSetup () {
1224
+ return cliSetup .getNormalizedCollection ();
1225
+ }
1226
+
1208
1227
@ Nested
1209
1228
public List <?> getSettings () {
1210
1229
return settings .getNormalizedCollection ();
@@ -1376,4 +1395,24 @@ public File getFile() {
1376
1395
return file ;
1377
1396
}
1378
1397
}
1398
+
1399
+ private static class CliEntry {
1400
+ private String executable ;
1401
+ private CharSequence [] args ;
1402
+
1403
+ CliEntry (String executable , CharSequence [] args ) {
1404
+ this .executable = executable ;
1405
+ this .args = args ;
1406
+ }
1407
+
1408
+ @ Input
1409
+ public String getExecutable () {
1410
+ return executable ;
1411
+ }
1412
+
1413
+ @ Input
1414
+ public CharSequence [] getArgs () {
1415
+ return args ;
1416
+ }
1417
+ }
1379
1418
}
0 commit comments