-
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
91 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,63 @@ | ||
/* 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 OpenSearch.Client; | ||
using OpenSearch.Net; | ||
using Tests.Core.ManagedOpenSearch.Clusters; | ||
using Tests.Domain; | ||
using Tests.Framework.EndpointTests; | ||
using Tests.Framework.EndpointTests.TestState; | ||
|
||
namespace Tests.Search.PointInTime; | ||
|
||
// ReadOnlyCluster because eventhough its technically a write action it does not hinder | ||
// on going reads | ||
public class DeletePitApiTests | ||
: ApiIntegrationTestBase<ReadOnlyCluster, DeletePitResponse, IDeletePitRequest, DeletePitDescriptor, DeletePitRequest> | ||
{ | ||
private string _pitId = "default-for-unit-tests"; | ||
|
||
public DeletePitApiTests(ReadOnlyCluster cluster, EndpointUsage usage) : base(cluster, usage) { } | ||
|
||
protected override bool ExpectIsValid => true; | ||
|
||
protected override object ExpectJson => new | ||
{ | ||
pit_ids = new[] | ||
{ | ||
_pitId | ||
} | ||
}; | ||
|
||
protected override int ExpectStatusCode => 200; | ||
|
||
protected override Func<DeletePitDescriptor, IDeletePitRequest> Fluent => d => d.PitIds(_pitId); | ||
protected override HttpMethod HttpMethod => HttpMethod.DELETE; | ||
|
||
protected override DeletePitRequest Initializer => new(_pitId); | ||
protected override bool SupportsDeserialization => false; | ||
protected override string UrlPath => "/_search/point_in_time"; | ||
|
||
protected override LazyResponses ClientUsage() => Calls( | ||
(c, f) => c.DeletePit(f), | ||
(c, f) => c.DeletePitAsync(f), | ||
(c, r) => c.DeletePit(r), | ||
(c, r) => c.DeletePitAsync(r) | ||
); | ||
|
||
protected override DeletePitDescriptor NewDescriptor() => new(); | ||
|
||
protected override void OnBeforeCall(IOpenSearchClient client) | ||
{ | ||
var pit = Client.CreatePit(OpenSearch.Client.Indices.Index<Project>(), c => c.KeepAlive("1h")); | ||
if (!pit.IsValid) | ||
throw new Exception("Setup: Initial PIT failed."); | ||
|
||
_pitId = pit.PitId ?? _pitId; | ||
} | ||
} |
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,28 @@ | ||
/* 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 DeletePitUrlTests | ||
{ | ||
[U] public async Task Urls() | ||
{ | ||
var pitIds = new[] { "pitid1", "pitid2" }; | ||
|
||
await DELETE("/_search/point_in_time") | ||
.Fluent(c => c.DeletePit(d => d.PitIds(pitIds))) | ||
.Request(c => c.DeletePit(new DeletePitRequest(pitIds))) | ||
.FluentAsync(c => c.DeletePitAsync(d => d.PitIds(pitIds))) | ||
.RequestAsync(c => c.DeletePitAsync(new DeletePitRequest(pitIds))); | ||
} | ||
} |