34
34
35
35
import org .opensearch .OpenSearchException ;
36
36
import org .opensearch .Version ;
37
+ import org .opensearch .action .admin .cluster .settings .ClusterGetSettingsRequest ;
38
+ import org .opensearch .action .admin .cluster .settings .ClusterGetSettingsResponse ;
37
39
import org .opensearch .action .admin .cluster .settings .ClusterUpdateSettingsResponse ;
40
+ import org .opensearch .action .admin .indices .settings .get .GetSettingsAction ;
41
+ import org .opensearch .action .admin .indices .settings .get .GetSettingsRequest ;
42
+ import org .opensearch .action .admin .indices .settings .get .GetSettingsResponse ;
43
+ import org .opensearch .client .RequestOptions ;
38
44
import org .opensearch .cluster .ClusterName ;
39
45
import org .opensearch .cluster .coordination .LeaderChecker .LeaderCheckRequest ;
40
46
import org .opensearch .cluster .node .DiscoveryNode ;
64
70
import java .util .concurrent .atomic .AtomicLong ;
65
71
import java .util .concurrent .atomic .AtomicReference ;
66
72
73
+ import static java .util .Collections .checkedList ;
67
74
import static java .util .Collections .emptySet ;
68
75
import static org .opensearch .cluster .coordination .LeaderChecker .LEADER_CHECK_ACTION_NAME ;
69
76
import static org .opensearch .cluster .coordination .LeaderChecker .LEADER_CHECK_INTERVAL_SETTING ;
@@ -568,18 +575,16 @@ public void testLeaderCheckRequestEqualsHashcodeSerialization() {
568
575
);
569
576
}
570
577
571
- public void testLeaderCheckTimeoutValue () {
578
+ public void testLeaderCheckTimeoutValueUpdate () {
572
579
Setting <TimeValue > setting1 = LEADER_CHECK_TIMEOUT_SETTING ;
573
580
Settings timeSettings1 = Settings .builder ().put (setting1 .getKey (), "60s" ).build ();
574
-
575
581
try {
576
582
ClusterUpdateSettingsResponse response = client ().admin ()
577
583
.cluster ()
578
584
.prepareUpdateSettings ()
579
585
.setPersistentSettings (timeSettings1 )
580
586
.execute ()
581
587
.actionGet ();
582
-
583
588
assertAcked (response );
584
589
assertEquals (timeValueSeconds (60 ), setting1 .get (response .getPersistentSettings ()));
585
590
} finally {
@@ -593,21 +598,17 @@ public void testLeaderCheckTimeoutMaxValue() {
593
598
Setting <TimeValue > setting1 = LEADER_CHECK_TIMEOUT_SETTING ;
594
599
Settings timeSettings1 = Settings .builder ().put (setting1 .getKey (), "61s" ).build ();
595
600
596
- try {
601
+ assertThrows ( "failed to parse value [61s] for setting [" + setting1 . getKey () + "], must be <= [60000ms]" , IllegalArgumentException . class , () -> {
597
602
client ().admin ().cluster ().prepareUpdateSettings ().setPersistentSettings (timeSettings1 ).execute ().actionGet ();
598
- } catch (IllegalArgumentException ex ) {
599
- assertEquals (ex .getMessage (), "failed to parse value [61s] for setting [" + setting1 .getKey () + "], must be <= [60000ms]" );
600
- }
603
+ });
601
604
}
602
605
603
606
public void testLeaderCheckTimeoutMinValue () {
604
607
Setting <TimeValue > setting1 = LEADER_CHECK_TIMEOUT_SETTING ;
605
608
Settings timeSettings1 = Settings .builder ().put (setting1 .getKey (), "0s" ).build ();
606
609
607
- try {
610
+ assertThrows ( "failed to parse value [0s] for setting [" + setting1 . getKey () + "], must be >= [1ms]" , IllegalArgumentException . class , () -> {
608
611
client ().admin ().cluster ().prepareUpdateSettings ().setPersistentSettings (timeSettings1 ).execute ().actionGet ();
609
- } catch (IllegalArgumentException ex ) {
610
- assertEquals (ex .getMessage (), "failed to parse value [0s] for setting [" + setting1 .getKey () + "], must be >= [1ms]" );
611
- }
612
+ });
612
613
}
613
614
}
0 commit comments