Skip to content

Add GetSnapshotsIT#testAllFeatures#111786

Merged
elasticsearchmachine merged 9 commits intoelastic:mainfrom
DaveCTurner:2024/08/11/GetSnapshotsIT-testAllFeatures
Aug 13, 2024
Merged

Add GetSnapshotsIT#testAllFeatures#111786
elasticsearchmachine merged 9 commits intoelastic:mainfrom
DaveCTurner:2024/08/11/GetSnapshotsIT-testAllFeatures

Conversation

@DaveCTurner
Copy link
Copy Markdown
Member

The features of get-snapshots API are all tested in isolation or small
combinations, but there's no one test which pins down exactly how they
all interact. This commit adds such a test, to verify that any future
optimization work preserves the observable behaviour.

Relates #95345
Relates #104607

The features of get-snapshots API are all tested in isolation or small
combinations, but there's no one test which pins down exactly how they
all interact. This commit adds such a test, to verify that any future
optimization work preserves the observable behaviour.

Relates elastic#95345
Relates elastic#104607
@DaveCTurner DaveCTurner added >test Issues or PRs that are addressing/adding tests :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs v8.16.0 labels Aug 11, 2024
@DaveCTurner DaveCTurner requested a review from ywangd August 11, 2024 20:13
@elasticsearchmachine
Copy link
Copy Markdown
Collaborator

Pinging @elastic/es-distributed (Team:Distributed)

@elasticsearchmachine elasticsearchmachine added the Team:Distributed Meta label for distributed team. label Aug 11, 2024
Copy link
Copy Markdown
Member

@ywangd ywangd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

There is also slm_policy_filter. But I guess it is not something of interest in the context of this work?

.map(si -> si.snapshotId().getName())
.collect(Collectors.toSet());
filterByNamePredicate = filterByNamePredicate.and(si -> selectedSnapshots.contains(si.snapshotId().getName()));
requestedSnapshots = selectedSnapshots.stream().map(n -> n + "*").toArray(String[]::new);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we randomize the * suffix?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can do a bit yeah but not always, see comment added in d5d520e.

case NAME -> startingSnapshot.snapshotId().getName();
case DURATION -> Long.toString(startingSnapshot.endTime() - startingSnapshot.startTime());
case INDICES, SHARDS -> Integer.toString(startingSnapshot.indices().size());
case FAILED_SHARDS -> "0";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There should be no failed shards. So we effectively do not test it. Should we add a comment?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

++ see 2f2e485.

nextResponse.getSnapshots().stream().map(SnapshotInfo::snapshotId).toList()
);
assertEquals(nextSize, nextResponse.getSnapshots().size());
assertEquals(selectedSnapshots.size(), nextResponse.totalCount());
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not

Suggested change
assertEquals(selectedSnapshots.size(), nextResponse.totalCount());
assertEquals(selectedSnapshots.size() - skippedByFromSortValue, nextResponse.totalCount());

?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct. We're not even specifying ?from_sort_value in this request, so we're seeing every matching snapshot in the total. I think we probably should not subtract these skipped items from the original total either, it seems fairly inconsistent to do what we do today, but this behaviour dates back quite some time so we'd need to discuss any changes. It's noted in this comment:

// sometimes use ?from_sort_value to skip some items; note that snapshots skipped in this way are subtracted from
// GetSnapshotsResponse.totalCount whereas snapshots skipped by ?after and ?offset are not

nextRequestAfter = nextResponse.next();
nextExpectedOffset += nextSize;
remaining -= nextSize;
}
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we assert remaining == 0 here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can, see 58ff48c.

@DaveCTurner
Copy link
Copy Markdown
Member Author

There is also slm_policy_filter

Ah good point, yeah we should cover that in these tests too. I tried a few quick fixes without success, will come back to this in a follow-up.

@DaveCTurner DaveCTurner added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Aug 12, 2024
@DaveCTurner
Copy link
Copy Markdown
Member Author

I tried a few quick fixes without success, will come back to this in a follow-up.

Spotted the problem, added coverage in c6de0b4.

@elasticsearchmachine elasticsearchmachine merged commit d2bd374 into elastic:main Aug 13, 2024
@DaveCTurner DaveCTurner deleted the 2024/08/11/GetSnapshotsIT-testAllFeatures branch August 13, 2024 08:27
DaveCTurner added a commit to DaveCTurner/elasticsearch that referenced this pull request Aug 14, 2024
Extends the test added in elastic#111786 to check that the API still works
correctly even in the BwC case that the details needed are not in the
`RepositoryData` and must be read from the individual `SnapshotInfo`
blobs.
DaveCTurner added a commit that referenced this pull request Aug 19, 2024
Extends the test added in #111786 to check that the API still works
correctly even in the BwC case that the details needed are not in the
`RepositoryData` and must be read from the individual `SnapshotInfo`
blobs.
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Sep 4, 2024
The features of get-snapshots API are all tested in isolation or small
combinations, but there's no one test which pins down exactly how they
all interact. This commit adds such a test, to verify that any future
optimization work preserves the observable behaviour.

Relates elastic#95345 Relates elastic#104607
cbuescher pushed a commit to cbuescher/elasticsearch that referenced this pull request Sep 4, 2024
Extends the test added in elastic#111786 to check that the API still works
correctly even in the BwC case that the details needed are not in the
`RepositoryData` and must be read from the individual `SnapshotInfo`
blobs.
davidkyle pushed a commit to davidkyle/elasticsearch that referenced this pull request Sep 5, 2024
The features of get-snapshots API are all tested in isolation or small
combinations, but there's no one test which pins down exactly how they
all interact. This commit adds such a test, to verify that any future
optimization work preserves the observable behaviour.

Relates elastic#95345 Relates elastic#104607
davidkyle pushed a commit to davidkyle/elasticsearch that referenced this pull request Sep 5, 2024
Extends the test added in elastic#111786 to check that the API still works
correctly even in the BwC case that the details needed are not in the
`RepositoryData` and must be read from the individual `SnapshotInfo`
blobs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) :Distributed/Snapshot/Restore Anything directly related to the `_snapshot/*` APIs Team:Distributed Meta label for distributed team. >test Issues or PRs that are addressing/adding tests v8.16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants