protected ApiTestBase(ClusterBase cluster, EndpointUsage usage) : base(cluster) { this._usage = usage; this.Cluster = cluster; this._responses = usage.CallOnce(this.ClientUsage); this._port = cluster.Node.Port; this._uniqueValues = usage.CallUniqueValues; this.SetupSerialization(); }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { PutJob(client, callUniqueValue.Value); OpenJob(client, callUniqueValue.Value); PutDatafeed(client, callUniqueValue.Value); StartDatafeed(client, callUniqueValue.Value); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { for (var i = 0; i < 3; i++) { PutFilter(client, callUniqueValue.Value + "_" + (i + 1)); } } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { PutJob(client, callUniqueValue.Value); IndexSnapshot(client, callUniqueValue.Value, "1"); client.GetModelSnapshots(callUniqueValue.Value).Count.Should().Be(1); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { var createShardedIndex = Client.Indices.Create(RandomString(), c => c .Settings(settings => settings .NumberOfShards(3) ) ); createShardedIndex.ShouldBeValid(); }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { if (client.Indices.Exists(Index).Exists) { return; } var createIndexResponse = client.Indices.Create(Index, c => c .Settings(s => s .NumberOfShards(1) .NumberOfReplicas(0) ) .Map <Domain.Shape>(mm => mm .AutoMap() .Properties(p => p .Shape(g => g .Name(n => n.GeometryCollection) ) .Shape(g => g .Name(n => n.Envelope) ) ) ) ); if (!createIndexResponse.IsValid) { throw new Exception($"Error creating index for integration test: {createIndexResponse.DebugInformation}"); } var bulk = new List <object>(); foreach (var shape in Domain.Shape.Shapes) { bulk.Add(new { index = new { _index = Index, _id = shape.Id } }); bulk.Add(new { id = shape.Id, geometryCollection = GeoWKTWriter.Write(shape.GeometryCollection), envelope = GeoWKTWriter.Write(shape.Envelope) }); } var bulkResponse = Client.LowLevel.Bulk <BulkResponse>( PostData.MultiJson(bulk), new BulkRequestParameters { Refresh = Refresh.WaitFor } ); if (!bulkResponse.IsValid) { throw new Exception($"Error indexing shapes for integration test: {bulkResponse.DebugInformation}"); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var value in values) { var index = value.Value; var createIndexResponse = client.Indices.Create(index); if (!createIndexResponse.IsValid) throw new Exception($"Invalid response when setting up index for integration test {GetType().Name}"); } }
protected override void IntegrationTeardown(IElasticClient client, CallUniqueValues values) { foreach (var value in values) { var response = DeleteJob(client, value.Value); if (!response.IsValid) { throw new Exception($"Problem in integration teardown {response.DebugInformation}"); } } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { client.CreateIndex(index, this.CreateIndexSettings).ShouldBeValid(); } var indices = Infer.Indices(values.Values.Select(i => (IndexName)i)); client.ClusterHealth(f => f.WaitForStatus(WaitForStatus.Yellow).Index(indices)) .ShouldBeValid(); }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { this.Client.IndexMany(Project.Projects, index); var cloneIndex = index + "-clone"; this.Client.CreateIndex(cloneIndex); this.Client.Refresh(Index(index).And(cloneIndex)); } }
protected override void IntegrationTeardown(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { var deleteRepositoryResponse = client.Snapshot.DeleteRepository(callUniqueValue.Value); if (!deleteRepositoryResponse.IsValid) { throw new Exception($"Error in integration teardown: {deleteRepositoryResponse.DebugInformation}"); } } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { PutJob(client, callUniqueValue.Value + "_job"); PutCalendar(client, callUniqueValue.Value); for (int i = 0; i < 20; i++) { PutCalendar(client, callUniqueValue.Value + "_" + i); } } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { this.Client.Index(new Test { Id = 1, Flag = "bar" }, i => i.Index(index).Refresh(Refresh.True)); this.Client.Index(new Test { Id = 2, Flag = "bar" }, i => i.Index(index).Refresh(Refresh.True)); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) => client.Ingest.PutPipeline( new PutPipelineRequest(PipelineId) { Description = "Index pipeline test", Processors = new List <IProcessor> { new RenameProcessor { TargetField = "lastSeen", Field = "lastActivity" } } });
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { var putJobResponse = client.PutJob <object>(callUniqueValue.Value, f => f .Description("GetOverallBucketsApiTests") .AnalysisConfig(a => a .BucketSpan($"{BucketSpanSeconds}s") .Detectors(d => d .Count() ) ) .DataDescription(d => d .TimeFormat("epoch_ms") ) ); if (!putJobResponse.IsValid) { throw new Exception($"Problem putting job {callUniqueValue.Value} for integration test: {putJobResponse.DebugInformation}"); } OpenJob(client, callUniqueValue.Value); var timestamp = 1483228800000L; // 2017-01-01T00:00:00Z var data = new List <object>(OverallBucketCount); for (var i = 0; i < OverallBucketCount; i++) { data.Add(new { time = timestamp }); if (i % 1000 == 0) { data.AddRange(new [] { new { time = timestamp }, new { time = timestamp }, new { time = timestamp } }); } timestamp += BucketSpanSeconds * 1000; } var postJobDataResponse = client.PostJobData(callUniqueValue.Value, d => d.Data(data)); if (!postJobDataResponse.IsValid) { throw new Exception($"Problem posting data for integration test: {postJobDataResponse.DebugInformation}"); } FlushJob(client, callUniqueValue.Value, true); CloseJob(client, callUniqueValue.Value); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { // get a suitable load of projects in order to get a decent task status out var sourceIndex = "project-get-completed-task"; var targetIndex = "tasks-lists-completed-get"; var bulkResponse = client.IndexMany(Project.Generator.Generate(500), sourceIndex); if (!bulkResponse.IsValid) { throw new Exception($"failure in setting up integration for {nameof(GetTaskApiCompletedTaskTests)}. {bulkResponse.DebugInformation}"); } var createIndex = client.Indices.Create(targetIndex, i => i .Settings(settings => settings.Analysis(DefaultSeeder.ProjectAnalysisSettings)) .Map <Project>(DefaultSeeder.ProjectTypeMappings) ); createIndex.ShouldBeValid(); var response = client.ReindexOnServer(r => r .Source(s => s.Index(sourceIndex)) .Destination(d => d .Index(targetIndex) .OpType(OpType.Create) ) .Conflicts(Conflicts.Proceed) .WaitForCompletion(false) .Refresh() ); _taskId = response.Task; // poll until task is complete var getTaskResponse = client.Tasks.GetTask(_taskId); var completed = getTaskResponse.Completed; while (!completed) { Thread.Sleep(2000); getTaskResponse = client.Tasks.GetTask(_taskId); if (getTaskResponse.IsValid) { completed = getTaskResponse.Completed; } else { throw new Exception($"problem setting up completed task: {getTaskResponse.DebugInformation}"); } } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { // get a suitable load of projects in order to get a decent task status out foreach (var(_, index) in values) { var createIndex = client.Indices.Create(index, i => i .Settings(settings => settings.Analysis(DefaultSeeder.ProjectAnalysisSettings)) .Map <Project>(DefaultSeeder.ProjectTypeMappings) ); createIndex.ShouldBeValid(); client.IndexMany(Project.Generator.Generate(100), index).ShouldBeValid(); client.Indices.Refresh(index).ShouldBeValid(); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { client.CreateIndex(IndexWithUnassignedShards, s => s .Settings(settings => settings .NumberOfShards(1) .NumberOfReplicas(2) ) ); client.Index(new IndexRequest <object>(IndexWithUnassignedShards) { Document = new { x = 1 }, Refresh = Refresh.True }); }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { var putTemplateResponse = client.PutIndexTemplate(callUniqueValue.Value, d => d.IndexPatterns("startingwiththis-*") .Settings(s => s.NumberOfShards(2)) .Version(1) ); if (!putTemplateResponse.IsValid) throw new Exception($"Problem putting index template for integration test: {putTemplateResponse.DebugInformation}"); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { var oldWay = new M { { "search", new M { { "remote", new M { { "cluster_one", new M { { "seeds", new[] { "127.0.0.1:9300", "127.0.0.1:9301" } } } }, { "cluster_two", new M { { "seeds", new[] { "127.0.0.1:9300" } } } } } } } } }; /** * As of 6.5.0 you can also use the following helper class which uses * the new way to configure remote clusters. */ // ReSharper disable once UnusedVariable var newWay = new RemoteClusterConfiguration() { { "cluster_one", "127.0.0.1:9300", "127.0.0.1:9301" }, { "cluster_two", "127.0.0.1:9300" } }; var enableRemoteClusters = client.Cluster.PutSettings(new ClusterPutSettingsRequest { Transient = oldWay }); enableRemoteClusters.ShouldBeValid(); var remoteSearch = client.Search <Project>(s => s.Index(Index <Project>("cluster_one").And <Project>("cluster_two"))); remoteSearch.ShouldBeValid(); }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { var putJobResponse = client.PutJob <object>(callUniqueValue.Value, f => f .Description("ForecastJobApiTests") .AnalysisConfig(a => a .BucketSpan($"{BucketSpanSeconds}s") .Detectors(d => d .Mean(m => m .FieldName("value") ) ) ) .DataDescription(d => d .TimeFormat("epoch") ) ); if (!putJobResponse.IsValid) { throw new Exception($"Problem putting job {callUniqueValue.Value} for integration test: {putJobResponse.DebugInformation}"); } OpenJob(client, callUniqueValue.Value); var epoch = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); var now = (DateTime.UtcNow - epoch).TotalSeconds; var timestamp = now - 50 * BucketSpanSeconds; var data = new List <object>(50); while (timestamp < now) { data.AddRange(new[] { new { time = timestamp, value = 10d }, new { time = timestamp, value = 30d } }); timestamp += BucketSpanSeconds; } var postJobDataResponse = client.PostJobData(callUniqueValue.Value, d => d.Data(data)); if (!postJobDataResponse.IsValid) { throw new Exception($"Problem posting data for integration test: {postJobDataResponse.DebugInformation}"); } FlushJob(client, callUniqueValue.Value, false); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { var index = client.Indices.Create(IndexWithNoSource, i => i .Map <Project>(mm => mm .SourceField(sf => sf.Enabled(false)) ) ); index.ShouldBeValid(); foreach (var id in values.Values) { Client.Index(Project.Instance, i => i.Id(id).Index(IndexWithNoSource).Routing(id)); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var callUniqueValue in values) { PutJob(client, callUniqueValue.Value); OpenJob(client, callUniqueValue.Value); CloseJob(client, callUniqueValue.Value); IndexSnapshot(client, callUniqueValue.Value, "first"); IndexSnapshot(client, callUniqueValue.Value, "second", "2016-06-01T00:00:00Z"); client.MachineLearning.GetModelSnapshots(callUniqueValue.Value).Count.Should().Be(2); client.Indices.Refresh(".ml-state"); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { // performing a bunch of search actions to make sure some stats have been gathered // even if this api is tested in isolation for (var i = 0; i < 5; i++) { var searchResult = client.MultiSearch(m => m .Search <Project>(s => s.MatchAll().Size(0)) .Search <Project>(s => s.MatchAll().Size(0)) .Search <Project>(s => s.MatchAll().Size(0)) .Search <Project>(s => s.MatchAll().Size(0)) ); searchResult.ShouldBeValid(); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { var searchResponse = client.Search <Project>(s => s .Size(0) .Aggregations(a => a .Average("avg_commits", avg => avg .Field(f => f.NumberOfCommits) ) ) ); if (!searchResponse.IsValid) { throw new Exception($"Exception when setting up {nameof(NodesUsageApiTests)}: {searchResponse.DebugInformation}"); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { this.Client.CreateIndex(index, c => c .Settings(s => s .RefreshInterval(-1) ) ); this.Client.Index(new Project { Name = "project1", Description = "description" }, i => i.Index(index).Id(1).Refresh(Refresh.True)); this.Client.Index(new Project { Name = "project2", Description = "description" }, i => i.Index(index).Id(1)); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var value in values.Values) { var createIndexResponse = client.Indices.Create(value + "-1", c => c); if (!createIndexResponse.IsValid) { throw new Exception(createIndexResponse.DebugInformation); } createIndexResponse = client.Indices.Create(value + "-2", c => c); if (!createIndexResponse.IsValid) { throw new Exception(createIndexResponse.DebugInformation); } } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { // ensure some fielddata is loaded _initialSearchResponse = client.Search <Project>(s => s .Query(q => q .Terms(t => t .Field(p => p.CuratedTags.First().Name) .Terms(Project.Projects.SelectMany(p => p.CuratedTags).Take(50).ToList()) ) ) ); if (!_initialSearchResponse.IsValid) { throw new Exception($"Failure setting up integration test. {_initialSearchResponse.DebugInformation}"); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { foreach (var index in values.Values) { this.Client.CreateIndex(index, c => c .Settings(s => s .RefreshInterval(-1) ) ); this.Client.Index(new Test { Text = "test1", Flag = "bar" }, i => i.Index(index).Id(1).Refresh(Refresh.True)); this.Client.Index(new Test { Text = "test2", Flag = "bar" }, i => i.Index(index).Id(1)); } }
protected override void IntegrationSetup(IElasticClient client, CallUniqueValues values) { // ensure some fielddata is loaded var response = client.Search <Project>(s => s .Query(q => q .Terms(t => t .Field(p => p.CuratedTags.First().Name) .Terms(Tag.Generator.Generate(50).Select(ct => ct.Name)) ) ) ); if (!response.IsValid) { throw new Exception($"Failure setting up integration test. {response.DebugInformation}"); } }