|
| 1 | +using System; |
| 2 | +using System.Text; |
| 3 | +using Elasticsearch.Net; |
| 4 | +using FluentAssertions; |
| 5 | +using Nest; |
| 6 | +using Tests.Framework; |
| 7 | +using Tests.Framework.Integration; |
| 8 | +using Xunit; |
| 9 | + |
| 10 | +namespace Tests.Reproduce |
| 11 | +{ |
| 12 | + public class GithubIssue2309 : IClusterFixture<ReadOnlyCluster> |
| 13 | + { |
| 14 | + private readonly ReadOnlyCluster _cluster; |
| 15 | + |
| 16 | + public GithubIssue2309(ReadOnlyCluster cluster) |
| 17 | + { |
| 18 | + _cluster = cluster; |
| 19 | + } |
| 20 | + |
| 21 | + [U] |
| 22 | + public void FailedReIndexResponseMarkedAsInvalidAndContainFailures() |
| 23 | + { |
| 24 | + var pool = new SingleNodeConnectionPool(new Uri("http://localhost:9200")); |
| 25 | + |
| 26 | + var json = @"{ |
| 27 | + ""took"": 4, |
| 28 | + ""timed_out"": false, |
| 29 | + ""total"": 1, |
| 30 | + ""updated"": 0, |
| 31 | + ""created"": 0, |
| 32 | + ""deleted"": 0, |
| 33 | + ""batches"": 1, |
| 34 | + ""version_conflicts"": 0, |
| 35 | + ""noops"": 0, |
| 36 | + ""retries"": { |
| 37 | + ""bulk"": 0, |
| 38 | + ""search"": 0 |
| 39 | + }, |
| 40 | + ""throttled_millis"": 0, |
| 41 | + ""requests_per_second"": -1.0, |
| 42 | + ""throttled_until_millis"": 0, |
| 43 | + ""failures"": [{ |
| 44 | + ""index"": ""employees-v2"", |
| 45 | + ""type"": ""employee"", |
| 46 | + ""id"": ""57f7ce8df8a10336a0cf935b"", |
| 47 | + ""cause"": { |
| 48 | + ""type"": ""mapper_parsing_exception"", |
| 49 | + ""reason"": ""failed to parse [id]"", |
| 50 | + ""caused_by"": { |
| 51 | + ""type"": ""number_format_exception"", |
| 52 | + ""reason"": ""For input string: \""57f7ce8df8a10336a0cf935b\"""" |
| 53 | + } |
| 54 | + }, |
| 55 | + ""status"": 400 |
| 56 | + }] |
| 57 | + }"; |
| 58 | + |
| 59 | + var connection = new InMemoryConnection(Encoding.UTF8.GetBytes(json), 400); |
| 60 | + var settings = new ConnectionSettings(pool, connection); |
| 61 | + var client = new ElasticClient(settings); |
| 62 | + |
| 63 | + var reindexResponse = client.ReindexOnServer(r => r |
| 64 | + .Source(s => s |
| 65 | + .Index("employees-v1") |
| 66 | + .Type("employee") |
| 67 | + ) |
| 68 | + .Destination(d => d |
| 69 | + .Index("employees-v2") |
| 70 | + ) |
| 71 | + .Conflicts(Conflicts.Proceed) |
| 72 | + ); |
| 73 | + |
| 74 | + reindexResponse.IsValid.Should().BeFalse(); |
| 75 | + reindexResponse.Failures.Should().NotBeNull().And.HaveCount(1); |
| 76 | + } |
| 77 | + } |
| 78 | +} |
0 commit comments