@@ -54,7 +54,7 @@ public void testGetFirstStep() {
54
54
String policyName = randomAlphaOfLengthBetween (2 , 10 );
55
55
Step expectedFirstStep = new MockStep (MOCK_STEP_KEY , null );
56
56
Map <String , Step > firstStepMap = Collections .singletonMap (policyName , expectedFirstStep );
57
- PolicyStepsRegistry registry = new PolicyStepsRegistry (null , firstStepMap , null , null , NamedXContentRegistry .EMPTY );
57
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (null , firstStepMap , null , null , NamedXContentRegistry .EMPTY , null );
58
58
Step actualFirstStep = registry .getFirstStep (policyName );
59
59
assertThat (actualFirstStep , sameInstance (expectedFirstStep ));
60
60
}
@@ -63,7 +63,7 @@ public void testGetFirstStepUnknownPolicy() {
63
63
String policyName = randomAlphaOfLengthBetween (2 , 10 );
64
64
Step expectedFirstStep = new MockStep (MOCK_STEP_KEY , null );
65
65
Map <String , Step > firstStepMap = Collections .singletonMap (policyName , expectedFirstStep );
66
- PolicyStepsRegistry registry = new PolicyStepsRegistry (null , firstStepMap , null , null , NamedXContentRegistry .EMPTY );
66
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (null , firstStepMap , null , null , NamedXContentRegistry .EMPTY , null );
67
67
Step actualFirstStep = registry .getFirstStep (policyName + "unknown" );
68
68
assertNull (actualFirstStep );
69
69
}
@@ -72,7 +72,7 @@ public void testGetStep() {
72
72
Step expectedStep = new MockStep (MOCK_STEP_KEY , null );
73
73
Index index = new Index ("test" , "uuid" );
74
74
Map <Index , List <Step >> indexSteps = Collections .singletonMap (index , Collections .singletonList (expectedStep ));
75
- PolicyStepsRegistry registry = new PolicyStepsRegistry (null , null , null , indexSteps , NamedXContentRegistry .EMPTY );
75
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (null , null , null , indexSteps , NamedXContentRegistry .EMPTY , null );
76
76
Step actualStep = registry .getStep (index , MOCK_STEP_KEY );
77
77
assertThat (actualStep , sameInstance (expectedStep ));
78
78
}
@@ -82,21 +82,21 @@ public void testGetStepErrorStep() {
82
82
Step expectedStep = new ErrorStep (errorStepKey );
83
83
Index index = new Index ("test" , "uuid" );
84
84
Map <Index , List <Step >> indexSteps = Collections .singletonMap (index , Collections .singletonList (expectedStep ));
85
- PolicyStepsRegistry registry = new PolicyStepsRegistry (null , null , null , indexSteps , NamedXContentRegistry .EMPTY );
85
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (null , null , null , indexSteps , NamedXContentRegistry .EMPTY , null );
86
86
Step actualStep = registry .getStep (index , errorStepKey );
87
87
assertThat (actualStep , equalTo (expectedStep ));
88
88
}
89
89
90
90
public void testGetStepUnknownPolicy () {
91
- PolicyStepsRegistry registry = new PolicyStepsRegistry (null , null , null , Collections .emptyMap (), NamedXContentRegistry .EMPTY );
91
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (null , null , null , Collections .emptyMap (), NamedXContentRegistry .EMPTY , null );
92
92
assertNull (registry .getStep (new Index ("test" , "uuid" ), MOCK_STEP_KEY ));
93
93
}
94
94
95
95
public void testGetStepUnknownStepKey () {
96
96
Step expectedStep = new MockStep (MOCK_STEP_KEY , null );
97
97
Index index = new Index ("test" , "uuid" );
98
98
Map <Index , List <Step >> indexSteps = Collections .singletonMap (index , Collections .singletonList (expectedStep ));
99
- PolicyStepsRegistry registry = new PolicyStepsRegistry (null , null , null , indexSteps , NamedXContentRegistry .EMPTY );
99
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (null , null , null , indexSteps , NamedXContentRegistry .EMPTY , null );
100
100
Step .StepKey unknownStepKey = new Step .StepKey (MOCK_STEP_KEY .getPhase (),
101
101
MOCK_STEP_KEY .getAction (),MOCK_STEP_KEY .getName () + "not" );
102
102
assertNull (registry .getStep (index , unknownStepKey ));
@@ -146,10 +146,10 @@ public void testUpdateFromNothingToSomethingToNothing() throws Exception {
146
146
.build ();
147
147
148
148
// start with empty registry
149
- PolicyStepsRegistry registry = new PolicyStepsRegistry (NamedXContentRegistry .EMPTY );
149
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (NamedXContentRegistry .EMPTY , client );
150
150
151
151
// add new policy
152
- registry .update (currentState , client );
152
+ registry .update (currentState );
153
153
154
154
assertThat (registry .getFirstStep (newPolicy .getName ()), equalTo (policySteps .get (0 )));
155
155
assertThat (registry .getLifecyclePolicyMap ().size (), equalTo (1 ));
@@ -167,15 +167,15 @@ public void testUpdateFromNothingToSomethingToNothing() throws Exception {
167
167
.put (LifecycleSettings .LIFECYCLE_PHASE , step .getKey ().getPhase ()))))
168
168
.nodes (DiscoveryNodes .builder ().localNodeId (nodeId ).masterNodeId (nodeId ).add (masterNode ).build ())
169
169
.build ();
170
- registry .update (currentState , client );
170
+ registry .update (currentState );
171
171
assertThat (registeredStepsForPolicy .get (step .getKey ()), equalTo (step ));
172
172
assertThat (registry .getStep (index , step .getKey ()), equalTo (step ));
173
173
}
174
174
175
175
Map <String , LifecyclePolicyMetadata > registryPolicyMap = registry .getLifecyclePolicyMap ();
176
176
Map <String , Step > registryFirstStepMap = registry .getFirstStepMap ();
177
177
Map <String , Map <Step .StepKey , Step >> registryStepMap = registry .getStepMap ();
178
- registry .update (currentState , client );
178
+ registry .update (currentState );
179
179
assertThat (registry .getLifecyclePolicyMap (), equalTo (registryPolicyMap ));
180
180
assertThat (registry .getFirstStepMap (), equalTo (registryFirstStepMap ));
181
181
assertThat (registry .getStepMap (), equalTo (registryStepMap ));
@@ -186,13 +186,13 @@ public void testUpdateFromNothingToSomethingToNothing() throws Exception {
186
186
.metaData (
187
187
MetaData .builder (metaData )
188
188
.putCustom (IndexLifecycleMetadata .TYPE , lifecycleMetadata )).build ();
189
- registry .update (currentState , client );
189
+ registry .update (currentState );
190
190
assertTrue (registry .getLifecyclePolicyMap ().isEmpty ());
191
191
assertTrue (registry .getFirstStepMap ().isEmpty ());
192
192
assertTrue (registry .getStepMap ().isEmpty ());
193
193
}
194
194
195
- public void testUpdateChangedPolicy () throws Exception {
195
+ public void testUpdateChangedPolicy () {
196
196
Client client = Mockito .mock (Client .class );
197
197
Mockito .when (client .settings ()).thenReturn (Settings .EMPTY );
198
198
String policyName = randomAlphaOfLengthBetween (5 , 10 );
@@ -217,9 +217,9 @@ public void testUpdateChangedPolicy() throws Exception {
217
217
.metaData (metaData )
218
218
.nodes (DiscoveryNodes .builder ().localNodeId (nodeId ).masterNodeId (nodeId ).add (masterNode ).build ())
219
219
.build ();
220
- PolicyStepsRegistry registry = new PolicyStepsRegistry (NamedXContentRegistry .EMPTY );
220
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (NamedXContentRegistry .EMPTY , client );
221
221
// add new policy
222
- registry .update (currentState , client );
222
+ registry .update (currentState );
223
223
224
224
// swap out policy
225
225
newPolicy = LifecyclePolicyTests .randomTestLifecyclePolicy (policyName );
@@ -228,7 +228,7 @@ public void testUpdateChangedPolicy() throws Exception {
228
228
randomNonNegativeLong (), randomNonNegativeLong ())), OperationMode .RUNNING );
229
229
currentState = ClusterState .builder (currentState )
230
230
.metaData (MetaData .builder (metaData ).putCustom (IndexLifecycleMetadata .TYPE , lifecycleMetadata )).build ();
231
- registry .update (currentState , client );
231
+ registry .update (currentState );
232
232
// TODO(talevy): assert changes... right now we do not support updates to policies. will require internal cleanup
233
233
}
234
234
@@ -287,10 +287,10 @@ public void testUpdatePolicyButNoPhaseChangeIndexStepsDontChange() throws Except
287
287
.build ();
288
288
289
289
// start with empty registry
290
- PolicyStepsRegistry registry = new PolicyStepsRegistry (NamedXContentRegistry .EMPTY );
290
+ PolicyStepsRegistry registry = new PolicyStepsRegistry (NamedXContentRegistry .EMPTY , client );
291
291
292
292
// add new policy
293
- registry .update (currentState , client );
293
+ registry .update (currentState );
294
294
295
295
Map <Step .StepKey , Step > registeredStepsForPolicy = registry .getStepMap ().get (newPolicy .getName ());
296
296
Step shrinkStep = registeredStepsForPolicy .entrySet ().stream ()
@@ -316,7 +316,7 @@ public void testUpdatePolicyButNoPhaseChangeIndexStepsDontChange() throws Except
316
316
currentState = ClusterState .builder (ClusterName .DEFAULT ).metaData (metaData ).build ();
317
317
318
318
// Update the policies
319
- registry .update (currentState , client );
319
+ registry .update (currentState );
320
320
321
321
registeredStepsForPolicy = registry .getStepMap ().get (newPolicy .getName ());
322
322
shrinkStep = registeredStepsForPolicy .entrySet ().stream ()
0 commit comments