@@ -20,42 +20,73 @@ public class SearchableSnapshotActionTests extends AbstractActionTestCase<Search
2020 @ Override
2121 public void testToSteps () {
2222 String phase = randomAlphaOfLengthBetween (1 , 10 );
23- StepKey expectedFirstStep = new StepKey (phase , NAME , CheckNotDataStreamWriteIndexStep .NAME );
24- StepKey expectedSecondStep = new StepKey (phase , NAME , WaitForNoFollowersStep .NAME );
25- StepKey expectedThirdStep = new StepKey (phase , NAME , GenerateSnapshotNameStep .NAME );
26- StepKey expectedFourthStep = new StepKey (phase , NAME , CleanupSnapshotStep .NAME );
27- StepKey expectedFifthStep = new StepKey (phase , NAME , CreateSnapshotStep .NAME );
28- StepKey expectedSixthStep = new StepKey (phase , NAME , MountSnapshotStep .NAME );
29- StepKey expectedSeventhStep = new StepKey (phase , NAME , WaitForIndexColorStep .NAME );
30- StepKey expectedEighthStep = new StepKey (phase , NAME , CopyExecutionStateStep .NAME );
31- StepKey expectedNinthStep = new StepKey (phase , NAME , CopySettingsStep .NAME );
32- StepKey expectedTenthStep = new StepKey (phase , NAME , SearchableSnapshotAction .CONDITIONAL_DATASTREAM_CHECK_KEY );
33- StepKey expectedElevenStep = new StepKey (phase , NAME , ReplaceDataStreamBackingIndexStep .NAME );
34- StepKey expectedTwelveStep = new StepKey (phase , NAME , DeleteStep .NAME );
35- StepKey expectedThirteenStep = new StepKey (phase , NAME , SwapAliasesAndDeleteSourceIndexStep .NAME );
36-
3723 SearchableSnapshotAction action = createTestInstance ();
3824 StepKey nextStepKey = new StepKey (phase , randomAlphaOfLengthBetween (1 , 5 ), randomAlphaOfLengthBetween (1 , 5 ));
3925
4026 List <Step > steps = action .toSteps (null , phase , nextStepKey );
41- assertThat (steps .size (), is (13 ));
42-
43- assertThat (steps .get (0 ).getKey (), is (expectedFirstStep ));
44- assertThat (steps .get (1 ).getKey (), is (expectedSecondStep ));
45- assertThat (steps .get (2 ).getKey (), is (expectedThirdStep ));
46- assertThat (steps .get (3 ).getKey (), is (expectedFourthStep ));
47- assertThat (steps .get (4 ).getKey (), is (expectedFifthStep ));
48- assertThat (steps .get (5 ).getKey (), is (expectedSixthStep ));
49- assertThat (steps .get (6 ).getKey (), is (expectedSeventhStep ));
50- assertThat (steps .get (7 ).getKey (), is (expectedEighthStep ));
51- assertThat (steps .get (8 ).getKey (), is (expectedNinthStep ));
52- assertThat (steps .get (9 ).getKey (), is (expectedTenthStep ));
53- assertThat (steps .get (10 ).getKey (), is (expectedElevenStep ));
54- assertThat (steps .get (11 ).getKey (), is (expectedTwelveStep ));
55- assertThat (steps .get (12 ).getKey (), is (expectedThirteenStep ));
56-
57- AsyncActionBranchingStep branchStep = (AsyncActionBranchingStep ) steps .get (4 );
58- assertThat (branchStep .getNextKeyOnIncompleteResponse (), is (expectedFourthStep ));
27+ assertThat (steps .size (), is (action .isForceMergeIndex () ? 15 : 13 ));
28+
29+ List <StepKey > expectedSteps = action .isForceMergeIndex () ? expectedStepKeysWithForceMerge (phase ) :
30+ expectedStepKeysNoForceMerge (phase );
31+
32+ assertThat (steps .get (0 ).getKey (), is (expectedSteps .get (0 )));
33+ assertThat (steps .get (1 ).getKey (), is (expectedSteps .get (1 )));
34+ assertThat (steps .get (2 ).getKey (), is (expectedSteps .get (2 )));
35+ assertThat (steps .get (3 ).getKey (), is (expectedSteps .get (3 )));
36+ assertThat (steps .get (4 ).getKey (), is (expectedSteps .get (4 )));
37+ assertThat (steps .get (5 ).getKey (), is (expectedSteps .get (5 )));
38+ assertThat (steps .get (6 ).getKey (), is (expectedSteps .get (6 )));
39+ assertThat (steps .get (7 ).getKey (), is (expectedSteps .get (7 )));
40+ assertThat (steps .get (8 ).getKey (), is (expectedSteps .get (8 )));
41+ assertThat (steps .get (9 ).getKey (), is (expectedSteps .get (9 )));
42+ assertThat (steps .get (10 ).getKey (), is (expectedSteps .get (10 )));
43+ assertThat (steps .get (11 ).getKey (), is (expectedSteps .get (11 )));
44+ assertThat (steps .get (12 ).getKey (), is (expectedSteps .get (12 )));
45+
46+ if (action .isForceMergeIndex ()) {
47+ assertThat (steps .get (13 ).getKey (), is (expectedSteps .get (13 )));
48+ AsyncActionBranchingStep branchStep = (AsyncActionBranchingStep ) steps .get (6 );
49+ assertThat (branchStep .getNextKeyOnIncompleteResponse (), is (expectedSteps .get (5 )));
50+ } else {
51+ AsyncActionBranchingStep branchStep = (AsyncActionBranchingStep ) steps .get (4 );
52+ assertThat (branchStep .getNextKeyOnIncompleteResponse (), is (expectedSteps .get (3 )));
53+ }
54+ }
55+
56+ private List <StepKey > expectedStepKeysWithForceMerge (String phase ) {
57+ return org .elasticsearch .common .collect .List .of (
58+ new StepKey (phase , NAME , CheckNotDataStreamWriteIndexStep .NAME ),
59+ new StepKey (phase , NAME , WaitForNoFollowersStep .NAME ),
60+ new StepKey (phase , NAME , ForceMergeStep .NAME ),
61+ new StepKey (phase , NAME , SegmentCountStep .NAME ),
62+ new StepKey (phase , NAME , GenerateSnapshotNameStep .NAME ),
63+ new StepKey (phase , NAME , CleanupSnapshotStep .NAME ),
64+ new StepKey (phase , NAME , CreateSnapshotStep .NAME ),
65+ new StepKey (phase , NAME , MountSnapshotStep .NAME ),
66+ new StepKey (phase , NAME , WaitForIndexColorStep .NAME ),
67+ new StepKey (phase , NAME , CopyExecutionStateStep .NAME ),
68+ new StepKey (phase , NAME , CopySettingsStep .NAME ),
69+ new StepKey (phase , NAME , SearchableSnapshotAction .CONDITIONAL_DATASTREAM_CHECK_KEY ),
70+ new StepKey (phase , NAME , ReplaceDataStreamBackingIndexStep .NAME ),
71+ new StepKey (phase , NAME , DeleteStep .NAME ),
72+ new StepKey (phase , NAME , SwapAliasesAndDeleteSourceIndexStep .NAME ));
73+ }
74+
75+ private List <StepKey > expectedStepKeysNoForceMerge (String phase ) {
76+ return org .elasticsearch .common .collect .List .of (
77+ new StepKey (phase , NAME , CheckNotDataStreamWriteIndexStep .NAME ),
78+ new StepKey (phase , NAME , WaitForNoFollowersStep .NAME ),
79+ new StepKey (phase , NAME , GenerateSnapshotNameStep .NAME ),
80+ new StepKey (phase , NAME , CleanupSnapshotStep .NAME ),
81+ new StepKey (phase , NAME , CreateSnapshotStep .NAME ),
82+ new StepKey (phase , NAME , MountSnapshotStep .NAME ),
83+ new StepKey (phase , NAME , WaitForIndexColorStep .NAME ),
84+ new StepKey (phase , NAME , CopyExecutionStateStep .NAME ),
85+ new StepKey (phase , NAME , CopySettingsStep .NAME ),
86+ new StepKey (phase , NAME , SearchableSnapshotAction .CONDITIONAL_DATASTREAM_CHECK_KEY ),
87+ new StepKey (phase , NAME , ReplaceDataStreamBackingIndexStep .NAME ),
88+ new StepKey (phase , NAME , DeleteStep .NAME ),
89+ new StepKey (phase , NAME , SwapAliasesAndDeleteSourceIndexStep .NAME ));
5990 }
6091
6192 @ Override
@@ -79,6 +110,6 @@ protected SearchableSnapshotAction mutateInstance(SearchableSnapshotAction insta
79110 }
80111
81112 static SearchableSnapshotAction randomInstance () {
82- return new SearchableSnapshotAction (randomAlphaOfLengthBetween (5 , 10 ));
113+ return new SearchableSnapshotAction (randomAlphaOfLengthBetween (5 , 10 ), randomBoolean () );
83114 }
84115}
0 commit comments