From 0e6141e6757655efdf568da458fcd39f16df34a2 Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Mon, 28 Mar 2016 13:03:48 -0400 Subject: [PATCH] Replace is_true: took with took >= 0 This prevents tests from failing on machines that can finish the request less than half a millisecond. --- .../elasticsearch/index/reindex/ReindexResponse.java | 2 +- .../resources/rest-api-spec/test/reindex/10_basic.yaml | 8 ++++---- .../rest-api-spec/test/reindex/80_throttle.yaml | 2 +- .../rest-api-spec/test/update-by-query/10_basic.yaml | 10 +++++----- .../rest-api-spec/test/reindex/40_search_failures.yaml | 2 +- .../test/update-by-query/40_search_failure.yaml | 2 +- .../test/search/70_response_filtering.yaml | 3 +-- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexResponse.java b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexResponse.java index 7e74fe26ec2..0cd4c9cbc18 100644 --- a/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexResponse.java +++ b/modules/reindex/src/main/java/org/elasticsearch/index/reindex/ReindexResponse.java @@ -46,7 +46,7 @@ public class ReindexResponse extends BulkIndexByScrollResponse { @Override public XContentBuilder toXContent(XContentBuilder builder, Params params) throws IOException { - builder.field("took", getTook()); + builder.field("took", getTook().millis()); builder.field("timed_out", isTimedOut()); getStatus().innerXContent(builder, params, true, false); builder.startArray("failures"); diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/10_basic.yaml b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/10_basic.yaml index 413c8d1c143..2f79b01d3f3 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/10_basic.yaml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/10_basic.yaml @@ -22,7 +22,7 @@ - match: {batches: 1} - match: {failures: []} - match: {throttled_millis: 0} - - is_true: took + - gte: { took: 0 } - is_false: task --- @@ -55,7 +55,7 @@ - match: {batches: 1} - match: {failures: []} - match: {throttled_millis: 0} - - is_true: took + - gte: { took: 0 } - is_false: task --- @@ -133,7 +133,7 @@ - match: {failures.0.cause.reason: "/\\[foo\\]\\[1\\]:.version.conflict,.document.already.exists.\\(current.version.\\[\\d+\\]\\)/"} - match: {failures.0.cause.shard: /\d+/} - match: {failures.0.cause.index: dest} - - is_true: took + - gte: { took: 0 } --- "Response format for version conflict with conflicts=proceed": @@ -167,7 +167,7 @@ - match: {batches: 1} - match: {failures: []} - match: {throttled_millis: 0} - - is_true: took + - gte: { took: 0 } --- "Simplest example in docs": diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/80_throttle.yaml b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/80_throttle.yaml index 2543670d5e6..dc78dbbe70b 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/reindex/80_throttle.yaml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/reindex/80_throttle.yaml @@ -49,5 +49,5 @@ - match: {failures: []} - gt: {throttled_millis: 1000} - lt: {throttled_millis: 4000} - - is_true: took + - gte: { took: 1000 } - is_false: task diff --git a/modules/reindex/src/test/resources/rest-api-spec/test/update-by-query/10_basic.yaml b/modules/reindex/src/test/resources/rest-api-spec/test/update-by-query/10_basic.yaml index bf54ac5584f..5b4df1c923d 100644 --- a/modules/reindex/src/test/resources/rest-api-spec/test/update-by-query/10_basic.yaml +++ b/modules/reindex/src/test/resources/rest-api-spec/test/update-by-query/10_basic.yaml @@ -19,7 +19,7 @@ - match: {failures: []} - match: {noops: 0} - match: {throttled_millis: 0} - - is_true: took + - gte: { took: 0 } - is_false: created # Update by query can't create - is_false: task @@ -93,7 +93,7 @@ - match: {failures.0.cause.reason: "/\\[foo\\]\\[1\\]:.version.conflict,.current.version.\\[\\d+\\].is.different.than.the.one.provided.\\[\\d+\\]/"} - match: {failures.0.cause.shard: /\d+/} - match: {failures.0.cause.index: test} - - is_true: took + - gte: { took: 0 } --- "Response for version conflict with conflicts=proceed": @@ -128,7 +128,7 @@ - match: {noops: 0} - match: {failures: []} - match: {throttled_millis: 0} - - is_true: took + - gte: { took: 0 } --- "Limit by query": @@ -158,7 +158,7 @@ - match: {version_conflicts: 0} - match: {batches: 1} - match: {failures: []} - - is_true: took + - gte: { took: 0 } --- "Limit by size": @@ -186,7 +186,7 @@ - match: {batches: 1} - match: {failures: []} - match: {throttled_millis: 0} - - is_true: took + - gte: { took: 0 } --- "Can override scroll_size": diff --git a/qa/smoke-test-reindex-with-groovy/src/test/resources/rest-api-spec/test/reindex/40_search_failures.yaml b/qa/smoke-test-reindex-with-groovy/src/test/resources/rest-api-spec/test/reindex/40_search_failures.yaml index 50442c2d51b..2c649220b75 100644 --- a/qa/smoke-test-reindex-with-groovy/src/test/resources/rest-api-spec/test/reindex/40_search_failures.yaml +++ b/qa/smoke-test-reindex-with-groovy/src/test/resources/rest-api-spec/test/reindex/40_search_failures.yaml @@ -31,4 +31,4 @@ - match: {failures.0.reason.reason: "failed to run inline script [1/0] using lang [groovy]"} - match: {failures.0.reason.caused_by.type: arithmetic_exception} - match: {failures.0.reason.caused_by.reason: Division by zero} - - is_true: took + - gte: { took: 0 } diff --git a/qa/smoke-test-reindex-with-groovy/src/test/resources/rest-api-spec/test/update-by-query/40_search_failure.yaml b/qa/smoke-test-reindex-with-groovy/src/test/resources/rest-api-spec/test/update-by-query/40_search_failure.yaml index 8f89409c586..9b8ba43f4a8 100644 --- a/qa/smoke-test-reindex-with-groovy/src/test/resources/rest-api-spec/test/update-by-query/40_search_failure.yaml +++ b/qa/smoke-test-reindex-with-groovy/src/test/resources/rest-api-spec/test/update-by-query/40_search_failure.yaml @@ -27,4 +27,4 @@ - match: {failures.0.reason.reason: "failed to run inline script [1/0] using lang [groovy]"} - match: {failures.0.reason.caused_by.type: arithmetic_exception} - match: {failures.0.reason.caused_by.reason: Division by zero} - - is_true: took + - gte: { took: 0 } diff --git a/rest-api-spec/src/main/resources/rest-api-spec/test/search/70_response_filtering.yaml b/rest-api-spec/src/main/resources/rest-api-spec/test/search/70_response_filtering.yaml index ade3b68e256..f81cb234691 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/test/search/70_response_filtering.yaml +++ b/rest-api-spec/src/main/resources/rest-api-spec/test/search/70_response_filtering.yaml @@ -27,7 +27,7 @@ filter_path: "*" body: "{ query: { match_all: {} } }" - - is_true: took + - gte: { took: 0 } - is_true: _shards.total - is_true: hits.total - is_true: hits.hits.0._index @@ -84,4 +84,3 @@ - is_true: hits.hits.1._index - is_false: hits.hits.1._type - is_true: hits.hits.1._id -