From 927ef5b4ba92e4ff8ce64bdcd1dbb49b157df0d7 Mon Sep 17 00:00:00 2001 From: Thomas Farr Date: Thu, 19 Oct 2023 18:23:12 +1300 Subject: [PATCH] test keep-alive extend Signed-off-by: Thomas Farr --- .../PointInTimeIntegrationTests.cs | 33 ++++++++++++++++--- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/tests/Tests/Search/PointInTime/PointInTimeIntegrationTests.cs b/tests/Tests/Search/PointInTime/PointInTimeIntegrationTests.cs index d7b87a7612..0b4009386d 100644 --- a/tests/Tests/Search/PointInTime/PointInTimeIntegrationTests.cs +++ b/tests/Tests/Search/PointInTime/PointInTimeIntegrationTests.cs @@ -68,13 +68,13 @@ [I] public async Task PointInTimeQuery() var liveSearch = await client.SearchAsync(s => s .Index(index) - .Query(q => q.MatchAll()) + .MatchAll() .TrackTotalHits()); liveSearch.ShouldBeValid(); liveSearch.Total.Should().Be(20); var pitSearch = await client.SearchAsync(s => s - .Query(q => q.MatchAll()) + .MatchAll() .PointInTime(pitResp.PitId) .TrackTotalHits()); pitSearch.ShouldBeValid(); @@ -105,13 +105,11 @@ [I] public async Task PointInTimeGetAllDeleteAll() for (var i = 0; i < 5; ++i) { var createResp = await client.CreatePitAsync(index, c => c.KeepAlive("1h")); - Console.WriteLine(createResp.DebugInformation); createResp.ShouldBeValid(); pits.Add((createResp.PitId, createResp.CreationTime)); } var getAllResp = await client.GetAllPitsAsync(); - Console.WriteLine(getAllResp.DebugInformation); getAllResp.ShouldBeValid(); getAllResp.Pits.Should() .BeEquivalentTo(pits.Select(p => new PitDetail @@ -122,7 +120,6 @@ [I] public async Task PointInTimeGetAllDeleteAll() })); var deleteAllResp = await client.DeleteAllPitsAsync(); - Console.WriteLine(deleteAllResp.DebugInformation); deleteAllResp.ShouldBeValid(); deleteAllResp.Pits.Should() .BeEquivalentTo(pits.Select(p => new DeletedPit @@ -132,6 +129,32 @@ [I] public async Task PointInTimeGetAllDeleteAll() })); } + [I] public async Task PointInTimeSearchExtendKeepAlive() + { + var client = _cluster.Client; + var index = nameof(PointInTimeSearchExtendKeepAlive).ToLowerInvariant(); + + var createIndexResp = await client.Indices.CreateAsync(index); + createIndexResp.ShouldBeValid(); + + var createResp = await client.CreatePitAsync(index, c => c.KeepAlive("1h")); + createResp.ShouldBeValid(); + + var searchResp = await client.SearchAsync(s => s + .MatchAll() + .PointInTime(createResp.PitId, p => p.KeepAlive("4h"))); + searchResp.ShouldBeValid(); + + var getAllResp = await client.GetAllPitsAsync(); + Console.WriteLine(getAllResp.DebugInformation); + getAllResp.ShouldBeValid(); + var pit = getAllResp.Pits.FirstOrDefault(p => p.PitId == createResp.PitId); + + pit.Should().NotBeNull(); + pit.CreationTime.Should().Be(createResp.CreationTime); + pit.KeepAlive.Should().Be(4 * 60 * 60 * 1000); + } + private class Doc { public long Id { get; set; }