-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Thomas Farr <[email protected]>
- Loading branch information
Showing
2 changed files
with
90 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using System; | ||
using FluentAssertions; | ||
using OpenSearch.Client; | ||
using OpenSearch.Net; | ||
using Tests.Core.ManagedOpenSearch.Clusters; | ||
using Tests.Framework.EndpointTests; | ||
using Tests.Framework.EndpointTests.TestState; | ||
|
||
namespace Tests.Search.PointInTime; | ||
|
||
public class CreatePitApiTests | ||
: ApiIntegrationTestBase<WritableCluster, CreatePitResponse, ICreatePitRequest, CreatePitDescriptor, CreatePitRequest> | ||
{ | ||
public CreatePitApiTests(WritableCluster cluster, EndpointUsage usage) : base(cluster, usage) { } | ||
|
||
protected override bool ExpectIsValid => true; | ||
|
||
protected override object ExpectJson => null; | ||
|
||
protected override int ExpectStatusCode => 200; | ||
|
||
protected override Func<CreatePitDescriptor, ICreatePitRequest> Fluent => e => e | ||
.KeepAlive("1h"); | ||
|
||
protected override HttpMethod HttpMethod => HttpMethod.POST; | ||
|
||
protected override CreatePitRequest Initializer => new(CallIsolatedValue) | ||
{ | ||
KeepAlive = "1h" | ||
}; | ||
|
||
protected override bool SupportsDeserialization => false; | ||
|
||
protected override string UrlPath => | ||
$"/{CallIsolatedValue}/_search/point_in_time?keep_alive=1h"; | ||
|
||
protected override LazyResponses ClientUsage() => Calls( | ||
(c, f) => c.CreatePit(CallIsolatedValue, f), | ||
(c, f) => c.CreatePitAsync(CallIsolatedValue, f), | ||
(c, r) => c.CreatePit(r), | ||
(c, r) => c.CreatePitAsync(r) | ||
); | ||
|
||
protected override CreatePitDescriptor NewDescriptor() => new(CallIsolatedValue); | ||
|
||
protected override void ExpectResponse(CreatePitResponse response) | ||
{ | ||
response.IsValid.Should().BeTrue(); | ||
response.PitId.Should().NotBeNullOrEmpty(); | ||
response.CreationTime.Should().BeCloseTo(DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(), 10000); | ||
response.Shards.Should().NotBeNull(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* SPDX-License-Identifier: Apache-2.0 | ||
* | ||
* The OpenSearch Contributors require contributions made to | ||
* this file be licensed under the Apache-2.0 license or a | ||
* compatible open source license. | ||
*/ | ||
|
||
using System.Threading.Tasks; | ||
using OpenSearch.Client; | ||
using OpenSearch.OpenSearch.Xunit.XunitPlumbing; | ||
using Tests.Framework.EndpointTests; | ||
using static Tests.Framework.EndpointTests.UrlTester; | ||
|
||
namespace Tests.Search.PointInTime; | ||
|
||
public class CreatePitUrlTests | ||
{ | ||
[U] public async Task Urls() | ||
{ | ||
const string index = "temp"; | ||
const string keepAlive = "1h"; | ||
|
||
await POST($"/{index}/_search/point_in_time?keep_alive={keepAlive}") | ||
.Fluent(c => c.CreatePit(index, c => c.KeepAlive(keepAlive))) | ||
.Request(c => c.CreatePit(new CreatePitRequest(index) { KeepAlive = keepAlive })) | ||
.FluentAsync(c => c.CreatePitAsync(index, c => c.KeepAlive(keepAlive))) | ||
.RequestAsync(c => c.CreatePitAsync(new CreatePitRequest(index) { KeepAlive = keepAlive })) | ||
; | ||
} | ||
} |