Skip to content

Commit

Permalink
test keep-alive extend
Browse files Browse the repository at this point in the history
Signed-off-by: Thomas Farr <[email protected]>
  • Loading branch information
Xtansia committed Oct 19, 2023
1 parent e6e9812 commit 927ef5b
Showing 1 changed file with 28 additions and 5 deletions.
33 changes: 28 additions & 5 deletions tests/Tests/Search/PointInTime/PointInTimeIntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,13 @@ [I] public async Task PointInTimeQuery()

var liveSearch = await client.SearchAsync<Doc>(s => s
.Index(index)
.Query(q => q.MatchAll())
.MatchAll()
.TrackTotalHits());
liveSearch.ShouldBeValid();
liveSearch.Total.Should().Be(20);

var pitSearch = await client.SearchAsync<Doc>(s => s
.Query(q => q.MatchAll())
.MatchAll()
.PointInTime(pitResp.PitId)
.TrackTotalHits());
pitSearch.ShouldBeValid();
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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<Doc>(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; }
Expand Down

0 comments on commit 927ef5b

Please sign in to comment.