Skip to content
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

Merged
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Copy link
Member

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

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,
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand All @@ -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
Expand All @@ -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();
Copy link
Member

Choose a reason for hiding this comment

The 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 get_snapshot_lifecycle_policy.asciidoc for the callout usages

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);
Expand Down