|
| 1 | +/* |
| 2 | + * Licensed to Elasticsearch B.V. under one or more contributor |
| 3 | + * license agreements. See the NOTICE file distributed with |
| 4 | + * this work for additional information regarding copyright |
| 5 | + * ownership. Elasticsearch B.V. licenses this file to you under |
| 6 | + * the Apache License, Version 2.0 (the "License"); you may |
| 7 | + * not use this file except in compliance with the License. |
| 8 | + * You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +using System.Threading.Tasks; |
| 21 | +using Elastic.Elasticsearch.Xunit.XunitPlumbing; |
| 22 | +using FluentAssertions; |
| 23 | +using Nest; |
| 24 | +using Tests.Core.Extensions; |
| 25 | +using Tests.Core.ManagedElasticsearch.Clusters; |
| 26 | +using Tests.Domain; |
| 27 | +using Tests.Framework.EndpointTests; |
| 28 | +using Tests.Framework.EndpointTests.TestState; |
| 29 | + |
| 30 | +namespace Tests.XPack.Eql |
| 31 | +{ |
| 32 | + [SkipVersion("<7.11.0", "GA in 7.11.0")] |
| 33 | + public class EqlSearchApiCoordinatedTests : CoordinatedIntegrationTestBase<TimeSeriesCluster> |
| 34 | + { |
| 35 | + private const string SubmitStep = nameof(SubmitStep); |
| 36 | + private const string StatusStep = nameof(StatusStep); |
| 37 | + |
| 38 | + public EqlSearchApiCoordinatedTests(TimeSeriesCluster cluster, EndpointUsage usage) : base(new CoordinatedUsage(cluster, usage, testOnlyOne: true) |
| 39 | + { |
| 40 | + {SubmitStep, u => |
| 41 | + u.Calls<EqlSearchDescriptor<Log>, EqlSearchRequest<Log>, IEqlSearchRequest, EqlSearchResponse<Log>>( |
| 42 | + v => new EqlSearchRequest<Log> |
| 43 | + { |
| 44 | + Query = "any where true", |
| 45 | + KeepOnCompletion = true, |
| 46 | + TimestampField = Infer.Field<Log>(f => f.Timestamp), |
| 47 | + WaitForCompletionTimeout = "1nanos" |
| 48 | + }, |
| 49 | + (v, d) => d |
| 50 | + .Query("any where true") |
| 51 | + .KeepOnCompletion() |
| 52 | + .TimestampField(Infer.Field<Log>(f => f.Timestamp)) |
| 53 | + .WaitForCompletionTimeout("1nanos"), |
| 54 | + (v, c, f) => c.Eql.Search(f), |
| 55 | + (v, c, f) => c.Eql.SearchAsync(f), |
| 56 | + (v, c, r) => c.Eql.Search<Log>(r), |
| 57 | + (v, c, r) => c.Eql.SearchAsync<Log>(r), |
| 58 | + onResponse: (r, values) => values.ExtendedValue("id", r.Id) |
| 59 | + ) |
| 60 | + }, |
| 61 | + {StatusStep, u => |
| 62 | + u.Calls<EqlSearchStatusDescriptor, EqlSearchStatusRequest, IEqlSearchStatusRequest, EqlSearchStatusResponse>( |
| 63 | + v => new EqlSearchStatusRequest(v), |
| 64 | + (v, d) => d, |
| 65 | + (v, c, f) => c.Eql.SearchStatus(v, f), |
| 66 | + (v, c, f) => c.Eql.SearchStatusAsync(v, f), |
| 67 | + (v, c, r) => c.Eql.SearchStatus(r), |
| 68 | + (v, c, r) => c.Eql.SearchStatusAsync(r), |
| 69 | + uniqueValueSelector: values => values.ExtendedValue<string>("id") |
| 70 | + ) |
| 71 | + } |
| 72 | + }) { } |
| 73 | + |
| 74 | + [I] public async Task EqlSearchResponse() => await Assert<EqlSearchResponse<Log>>(SubmitStep, r => |
| 75 | + { |
| 76 | + r.ShouldBeValid(); |
| 77 | + r.Id.Should().NotBeNullOrEmpty(); |
| 78 | + r.IsPartial.Should().BeTrue(); |
| 79 | + r.IsRunning.Should().BeTrue(); |
| 80 | + r.TimedOut.Should().BeFalse(); |
| 81 | + }); |
| 82 | + |
| 83 | + [I] public async Task EqlSearchStatusResponse() => await Assert<EqlSearchStatusResponse>(StatusStep, r => |
| 84 | + { |
| 85 | + r.ShouldBeValid(); |
| 86 | + r.Id.Should().NotBeNullOrEmpty(); |
| 87 | + r.IsPartial.Should().BeTrue(); |
| 88 | + r.IsRunning.Should().BeTrue(); |
| 89 | + r.ExpirationTimeInMillis.Should().BeGreaterThan(0); |
| 90 | + r.StartTimeInMillis.Should().BeGreaterThan(0); |
| 91 | + }); |
| 92 | + } |
| 93 | +} |
0 commit comments