-
Notifications
You must be signed in to change notification settings - Fork 24.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix flaky test addSnapshotLifecyclePolicy #46881
Changes from 2 commits
32fa9d7
af42449
19b6dbd
004b126
f07f8a0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -797,32 +797,11 @@ public void testAddSnapshotLifecyclePolicy() throws Exception { | |
// end::slm-put-snapshot-lifecycle-policy-response | ||
assertTrue(putAcknowledged); | ||
|
||
// tag::slm-put-snapshot-lifecycle-policy-execute-listener | ||
ActionListener<AcknowledgedResponse> putListener = | ||
new ActionListener<>() { | ||
@Override | ||
public void onResponse(AcknowledgedResponse resp) { | ||
boolean acknowledged = resp.isAcknowledged(); // <1> | ||
} | ||
|
||
@Override | ||
public void onFailure(Exception e) { | ||
// <2> | ||
} | ||
}; | ||
// end::slm-put-snapshot-lifecycle-policy-execute-listener | ||
|
||
// tag::slm-put-snapshot-lifecycle-policy-execute-async | ||
client.indexLifecycle().putSnapshotLifecyclePolicyAsync(request, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think rather than remove this (which we need for documentation), we should relax or remove the assertion to not trip on the policy version. |
||
RequestOptions.DEFAULT, putListener); | ||
// end::slm-put-snapshot-lifecycle-policy-execute-async | ||
|
||
//////// GET | ||
// tag::slm-get-snapshot-lifecycle-policy | ||
GetSnapshotLifecyclePolicyRequest getAllRequest = | ||
new GetSnapshotLifecyclePolicyRequest(); // <1> | ||
GetSnapshotLifecyclePolicyRequest getRequest = | ||
new GetSnapshotLifecyclePolicyRequest("policy_id"); // <2> | ||
new GetSnapshotLifecyclePolicyRequest("policy_id"); | ||
// end::slm-get-snapshot-lifecycle-policy | ||
|
||
// tag::slm-get-snapshot-lifecycle-policy-execute | ||
|
@@ -839,6 +818,7 @@ public void onFailure(Exception e) { | |
public void onResponse(GetSnapshotLifecyclePolicyResponse resp) { | ||
Map<String, SnapshotLifecyclePolicyMetadata> policies = | ||
resp.getPolicies(); // <1> | ||
assertThat(policies.size(), equalTo(1)); | ||
} | ||
|
||
@Override | ||
|
@@ -858,18 +838,7 @@ public void onFailure(Exception e) { | |
SnapshotLifecyclePolicyMetadata policyMeta = | ||
getResponse.getPolicies().get("policy_id"); // <1> | ||
long policyVersion = policyMeta.getVersion(); | ||
long policyModificationDate = policyMeta.getModifiedDate(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Even though these appear unused, they are documenting how to retrieve things from the policy metadata, so we should leave them. See |
||
long nextPolicyExecutionDate = policyMeta.getNextExecution(); | ||
SnapshotInvocationRecord lastSuccess = policyMeta.getLastSuccess(); | ||
SnapshotInvocationRecord lastFailure = policyMeta.getLastFailure(); | ||
SnapshotLifecyclePolicyMetadata.SnapshotInProgress inProgress = | ||
policyMeta.getSnapshotInProgress(); | ||
SnapshotLifecyclePolicy retrievedPolicy = policyMeta.getPolicy(); // <2> | ||
String id = retrievedPolicy.getId(); | ||
String snapshotNameFormat = retrievedPolicy.getName(); | ||
String repositoryName = retrievedPolicy.getRepository(); | ||
String schedule = retrievedPolicy.getSchedule(); | ||
Map<String, Object> snapshotConfiguration = retrievedPolicy.getConfig(); | ||
// end::slm-get-snapshot-lifecycle-policy-response | ||
|
||
assertNotNull(policyMeta); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are here because they are used as snippets to generate the high level rest client documentation (that's what the surrounding
// tag::etcetc
and// end::etcetc
are for, so I don't think we should remove these