From 3d1cd4c1564357657994c2ff49816a9b7894e084 Mon Sep 17 00:00:00 2001 From: David Kyle Date: Wed, 12 Apr 2023 14:52:40 +0100 Subject: [PATCH 1/4] [ML] Add missing text_similarity config support to the Inference Processor (#95190) --- docs/changelog/95190.yaml | 5 +++++ .../action/InferModelActionResponseTests.java | 22 +++++++++++-------- .../inference/ingest/InferenceProcessor.java | 14 +++++++++--- .../InferenceProcessorFactoryTests.java | 19 +++++++++++++++- 4 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 docs/changelog/95190.yaml diff --git a/docs/changelog/95190.yaml b/docs/changelog/95190.yaml new file mode 100644 index 0000000000000..452fa6c7a3656 --- /dev/null +++ b/docs/changelog/95190.yaml @@ -0,0 +1,5 @@ +pr: 95190 +summary: Add missing `text_similarity` config support to the Inference Processor +area: Machine Learning +type: bug +issues: [] diff --git a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/InferModelActionResponseTests.java b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/InferModelActionResponseTests.java index 639393a079fda..591e085ff6f36 100644 --- a/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/InferModelActionResponseTests.java +++ b/x-pack/plugin/core/src/test/java/org/elasticsearch/xpack/core/ml/action/InferModelActionResponseTests.java @@ -29,6 +29,8 @@ import org.elasticsearch.xpack.core.ml.inference.results.TextEmbeddingResultsTests; import org.elasticsearch.xpack.core.ml.inference.results.TextExpansionResults; import org.elasticsearch.xpack.core.ml.inference.results.TextExpansionResultsTests; +import org.elasticsearch.xpack.core.ml.inference.results.TextSimilarityInferenceResults; +import org.elasticsearch.xpack.core.ml.inference.results.TextSimilarityInferenceResultsTests; import org.elasticsearch.xpack.core.ml.inference.results.WarningInferenceResults; import org.elasticsearch.xpack.core.ml.inference.results.WarningInferenceResultsTests; @@ -43,14 +45,15 @@ public class InferModelActionResponseTests extends AbstractWireSerializingTestCa private static List INFERENCE_RESULT_TYPES = List.of( ClassificationInferenceResults.NAME, - RegressionInferenceResults.NAME, NerResults.NAME, - TextEmbeddingResults.NAME, - PyTorchPassThroughResults.NAME, FillMaskResults.NAME, - WarningInferenceResults.NAME, + PyTorchPassThroughResults.NAME, QuestionAnsweringInferenceResults.NAME, - TextExpansionResults.NAME + RegressionInferenceResults.NAME, + TextEmbeddingResults.NAME, + TextExpansionResults.NAME, + TextSimilarityInferenceResults.NAME, + WarningInferenceResults.NAME ); @Override @@ -79,14 +82,15 @@ protected Response mutateInstance(Response instance) { private static InferenceResults randomInferenceResult(String resultType) { return switch (resultType) { case ClassificationInferenceResults.NAME -> ClassificationInferenceResultsTests.createRandomResults(); - case RegressionInferenceResults.NAME -> RegressionInferenceResultsTests.createRandomResults(); case NerResults.NAME -> NerResultsTests.createRandomResults(); - case TextEmbeddingResults.NAME -> TextEmbeddingResultsTests.createRandomResults(); - case PyTorchPassThroughResults.NAME -> PyTorchPassThroughResultsTests.createRandomResults(); case FillMaskResults.NAME -> FillMaskResultsTests.createRandomResults(); - case WarningInferenceResults.NAME -> WarningInferenceResultsTests.createRandomResults(); + case PyTorchPassThroughResults.NAME -> PyTorchPassThroughResultsTests.createRandomResults(); case QuestionAnsweringInferenceResults.NAME -> QuestionAnsweringInferenceResultsTests.createRandomResults(); + case RegressionInferenceResults.NAME -> RegressionInferenceResultsTests.createRandomResults(); + case TextEmbeddingResults.NAME -> TextEmbeddingResultsTests.createRandomResults(); case TextExpansionResults.NAME -> TextExpansionResultsTests.createRandomResults(); + case TextSimilarityInferenceResults.NAME -> TextSimilarityInferenceResultsTests.createRandomResults(); + case WarningInferenceResults.NAME -> WarningInferenceResultsTests.createRandomResults(); default -> throw new AssertionError("unexpected result type [" + resultType + "]"); }; } diff --git a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java index d29e590a09668..5b68e782facde 100644 --- a/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java +++ b/x-pack/plugin/ml/src/main/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessor.java @@ -47,6 +47,8 @@ import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextEmbeddingConfigUpdate; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextExpansionConfig; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextExpansionConfigUpdate; +import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextSimilarityConfig; +import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextSimilarityConfigUpdate; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.ZeroShotClassificationConfig; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.ZeroShotClassificationConfigUpdate; import org.elasticsearch.xpack.core.ml.job.messages.Messages; @@ -308,15 +310,18 @@ InferenceConfigUpdate inferenceConfigUpdateFromMap(Map configMap } else if (configMap.containsKey(RegressionConfig.NAME.getPreferredName())) { checkSupportedVersion(RegressionConfig.EMPTY_PARAMS); return RegressionConfigUpdate.fromMap(valueMap); - } else if (configMap.containsKey(TextExpansionConfig.NAME)) { - checkNlpSupported(TextExpansionConfig.NAME); - return TextExpansionConfigUpdate.fromMap(valueMap); } else if (configMap.containsKey(TextClassificationConfig.NAME)) { checkNlpSupported(TextClassificationConfig.NAME); return TextClassificationConfigUpdate.fromMap(valueMap); } else if (configMap.containsKey(TextEmbeddingConfig.NAME)) { checkNlpSupported(TextEmbeddingConfig.NAME); return TextEmbeddingConfigUpdate.fromMap(valueMap); + } else if (configMap.containsKey(TextExpansionConfig.NAME)) { + checkNlpSupported(TextExpansionConfig.NAME); + return TextExpansionConfigUpdate.fromMap(valueMap); + } else if (configMap.containsKey(TextSimilarityConfig.NAME)) { + checkNlpSupported(TextSimilarityConfig.NAME); + return TextSimilarityConfigUpdate.fromMap(valueMap); } else if (configMap.containsKey(ZeroShotClassificationConfig.NAME)) { checkNlpSupported(ZeroShotClassificationConfig.NAME); return ZeroShotClassificationConfigUpdate.fromMap(valueMap); @@ -333,8 +338,11 @@ InferenceConfigUpdate inferenceConfigUpdateFromMap(Map configMap FillMaskConfig.NAME, NerConfig.NAME, PassThroughConfig.NAME, + QuestionAnsweringConfig.NAME, TextClassificationConfig.NAME, TextEmbeddingConfig.NAME, + TextExpansionConfigUpdate.NAME, + TextSimilarityConfig.NAME, ZeroShotClassificationConfig.NAME ) ); diff --git a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessorFactoryTests.java b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessorFactoryTests.java index 85835d4ae816b..8ceeea952318f 100644 --- a/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessorFactoryTests.java +++ b/x-pack/plugin/ml/src/test/java/org/elasticsearch/xpack/ml/inference/ingest/InferenceProcessorFactoryTests.java @@ -42,6 +42,8 @@ import org.elasticsearch.xpack.core.ml.inference.trainedmodel.RegressionConfig; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextClassificationConfig; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextEmbeddingConfig; +import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextExpansionConfigUpdate; +import org.elasticsearch.xpack.core.ml.inference.trainedmodel.TextSimilarityConfig; import org.elasticsearch.xpack.core.ml.inference.trainedmodel.ZeroShotClassificationConfig; import org.junit.Before; @@ -146,7 +148,8 @@ public void testCreateProcessorWithInvalidInferenceConfig() { equalTo( "unrecognized inference configuration type [unknown_type]." + " Supported types [classification, regression, fill_mask, ner, pass_through, " - + "text_classification, text_embedding, zero_shot_classification]" + + "question_answering, text_classification, text_embedding, text_expansion, " + + "text_similarity, zero_shot_classification]" ) ); @@ -262,8 +265,11 @@ public void testCreateProcessorWithTooOldMinNodeVersionNlp() throws IOException FillMaskConfig.NAME, NerConfig.NAME, PassThroughConfig.NAME, + QuestionAnsweringConfig.NAME, TextClassificationConfig.NAME, TextEmbeddingConfig.NAME, + TextExpansionConfigUpdate.NAME, + TextSimilarityConfig.NAME, ZeroShotClassificationConfig.NAME )) { ElasticsearchException ex = expectThrows( @@ -275,6 +281,17 @@ public void testCreateProcessorWithTooOldMinNodeVersionNlp() throws IOException equalTo("Configuration [" + name + "] requires minimum node version [8.0.0] (current minimum node version [7.5.0]") ); } + + for (String name : List.of(ClassificationConfig.NAME.getPreferredName(), RegressionConfig.NAME.getPreferredName())) { + ElasticsearchException ex = expectThrows( + ElasticsearchException.class, + () -> processorFactory.inferenceConfigUpdateFromMap(Map.of(name, Map.of())) + ); + assertThat( + ex.getMessage(), + equalTo("Configuration [" + name + "] requires minimum node version [7.6.0] (current minimum node version [7.5.0]") + ); + } }); } From e832e630b2eb524b497fd5833abd25f3e50b2478 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Witek?= Date: Wed, 12 Apr 2023 16:12:59 +0200 Subject: [PATCH 2/4] [Transform] Fix privileges check failures by adding `allow_restricted_indices` flag (#95187) --- docs/changelog/95187.yaml | 5 +++++ .../qa/multi-node-tests/build.gradle | 1 + .../transform/qa/multi-node-tests/roles.yml | 8 +++++++ .../TransformInsufficientPermissionsIT.java | 22 +++++++++++++++++++ .../action/TransformPrivilegeChecker.java | 2 ++ .../TransformPrivilegeCheckerTests.java | 8 +++++++ 6 files changed, 46 insertions(+) create mode 100644 docs/changelog/95187.yaml diff --git a/docs/changelog/95187.yaml b/docs/changelog/95187.yaml new file mode 100644 index 0000000000000..776e9d3be9c62 --- /dev/null +++ b/docs/changelog/95187.yaml @@ -0,0 +1,5 @@ +pr: 95187 +summary: Fix privileges check failures by adding `allow_restricted_indices` flag +area: Transform +type: bug +issues: [] diff --git a/x-pack/plugin/transform/qa/multi-node-tests/build.gradle b/x-pack/plugin/transform/qa/multi-node-tests/build.gradle index f57ba8cbd2e5a..55034dba8e82f 100644 --- a/x-pack/plugin/transform/qa/multi-node-tests/build.gradle +++ b/x-pack/plugin/transform/qa/multi-node-tests/build.gradle @@ -50,4 +50,5 @@ testClusters.matching { it.name == 'javaRestTest' }.configureEach { user username: "john_junior", password: "x-pack-test-password", role: "transform_admin" user username: "bill_senior", password: "x-pack-test-password", role: "transform_admin,source_index_access" user username: "not_a_transform_admin", password: "x-pack-test-password", role: "source_index_access" + user username: "fleet_access", password: "x-pack-test-password", role: "transform_admin,source_index_access,fleet_index_access" } diff --git a/x-pack/plugin/transform/qa/multi-node-tests/roles.yml b/x-pack/plugin/transform/qa/multi-node-tests/roles.yml index 4b22a9467147d..ce2dbf4119a63 100644 --- a/x-pack/plugin/transform/qa/multi-node-tests/roles.yml +++ b/x-pack/plugin/transform/qa/multi-node-tests/roles.yml @@ -15,3 +15,11 @@ source_index_access: - view_index_metadata - indices:data/write/bulk - indices:data/write/index + +fleet_index_access: + indices: + # Give access to the Fleet indices (which are system indices) + - names: [ '.fleet*' ] + privileges: + - all + allow_restricted_indices: true diff --git a/x-pack/plugin/transform/qa/multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/transform/integration/TransformInsufficientPermissionsIT.java b/x-pack/plugin/transform/qa/multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/transform/integration/TransformInsufficientPermissionsIT.java index 82938b76765da..028a1c0f2d8ee 100644 --- a/x-pack/plugin/transform/qa/multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/transform/integration/TransformInsufficientPermissionsIT.java +++ b/x-pack/plugin/transform/qa/multi-node-tests/src/javaRestTest/java/org/elasticsearch/xpack/transform/integration/TransformInsufficientPermissionsIT.java @@ -50,6 +50,8 @@ public class TransformInsufficientPermissionsIT extends TransformRestTestCase { private static final String SENIOR_HEADER = basicAuthHeaderValue(SENIOR_USERNAME, TEST_PASSWORD_SECURE_STRING); private static final String NOT_A_TRANSFORM_ADMIN = "not_a_transform_admin"; private static final String NOT_A_TRANSFORM_ADMIN_HEADER = basicAuthHeaderValue(NOT_A_TRANSFORM_ADMIN, TEST_PASSWORD_SECURE_STRING); + private static final String FLEET_ACCESS_USERNAME = "fleet_access"; + private static final String FLEET_ACCESS_HEADER = basicAuthHeaderValue(FLEET_ACCESS_USERNAME, TEST_PASSWORD_SECURE_STRING); private static final int NUM_USERS = 28; @@ -388,6 +390,26 @@ public void testPreviewRequestFailsPermissionsCheck() throws Exception { previewTransform(Strings.toString(config), RequestOptions.DEFAULT.toBuilder().addHeader(AUTH_KEY, SENIOR_HEADER).build()); } + public void testFleetIndicesAccess() throws Exception { + String transformId = "transform-permissions-fleet"; + String sourceIndexPattern = ".fleet-agents*"; + String destIndexName = transformId + "-dest"; + + TransformConfig config = createConfig(transformId, sourceIndexPattern, destIndexName, false); + + ResponseException e = expectThrows( + ResponseException.class, + () -> previewTransform( + Strings.toString(config), + RequestOptions.DEFAULT.toBuilder().addHeader(AUTH_KEY, FLEET_ACCESS_HEADER).build() + ) + ); + // The _preview request got past the authorization step (which is what interests us in this test) but failed because the referenced + // source indices do not exist. + assertThat(e.getResponse().getStatusLine().getStatusCode(), is(equalTo(400))); + assertThat(e.getMessage(), containsString("Source indices have been deleted or closed.")); + } + @Override protected Settings restAdminSettings() { return Settings.builder().put(ThreadContext.PREFIX + ".Authorization", TEST_ADMIN_HEADER).build(); diff --git a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransformPrivilegeChecker.java b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransformPrivilegeChecker.java index b401068087b0d..c39e31fb47e42 100644 --- a/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransformPrivilegeChecker.java +++ b/x-pack/plugin/transform/src/main/java/org/elasticsearch/xpack/transform/action/TransformPrivilegeChecker.java @@ -95,6 +95,7 @@ private static HasPrivilegesRequest buildPrivilegesRequest( .indices(sourceIndex) // We need to read the source indices mapping to deduce the destination mapping, hence the need for view_index_metadata .privileges("read", "view_index_metadata") + .allowRestrictedIndices(true) .build(); indicesPrivileges.add(sourceIndexPrivileges); } @@ -121,6 +122,7 @@ private static HasPrivilegesRequest buildPrivilegesRequest( RoleDescriptor.IndicesPrivileges destIndexPrivileges = RoleDescriptor.IndicesPrivileges.builder() .indices(destIndex) .privileges(destPrivileges) + .allowRestrictedIndices(true) .build(); indicesPrivileges.add(destIndexPrivileges); } diff --git a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/action/TransformPrivilegeCheckerTests.java b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/action/TransformPrivilegeCheckerTests.java index 1272f14904a75..d94263ae8ef1a 100644 --- a/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/action/TransformPrivilegeCheckerTests.java +++ b/x-pack/plugin/transform/src/test/java/org/elasticsearch/xpack/transform/action/TransformPrivilegeCheckerTests.java @@ -127,6 +127,7 @@ public void testCheckPrivileges_NoCheckDestIndexPrivileges() { RoleDescriptor.IndicesPrivileges sourceIndicesPrivileges = request.indexPrivileges()[0]; assertThat(sourceIndicesPrivileges.getIndices(), is(arrayContaining(SOURCE_INDEX_NAME))); assertThat(sourceIndicesPrivileges.getPrivileges(), is(arrayContaining("read", "view_index_metadata"))); + assertThat(sourceIndicesPrivileges.allowRestrictedIndices(), is(true)); }, e -> fail(e.getMessage())) ); } @@ -169,9 +170,11 @@ public void testCheckPrivileges_CheckDestIndexPrivileges_DestIndexDoesNotExist() RoleDescriptor.IndicesPrivileges sourceIndicesPrivileges = request.indexPrivileges()[0]; assertThat(sourceIndicesPrivileges.getIndices(), is(arrayContaining(SOURCE_INDEX_NAME))); assertThat(sourceIndicesPrivileges.getPrivileges(), is(arrayContaining("read", "view_index_metadata"))); + assertThat(sourceIndicesPrivileges.allowRestrictedIndices(), is(true)); RoleDescriptor.IndicesPrivileges destIndicesPrivileges = request.indexPrivileges()[1]; assertThat(destIndicesPrivileges.getIndices(), is(arrayContaining(DEST_INDEX_NAME))); assertThat(destIndicesPrivileges.getPrivileges(), is(arrayContaining("read", "index", "create_index"))); + assertThat(destIndicesPrivileges.allowRestrictedIndices(), is(true)); }, e -> fail(e.getMessage())) ); } @@ -201,9 +204,11 @@ public void testCheckPrivileges_CheckDestIndexPrivileges_DestIndexExists() { RoleDescriptor.IndicesPrivileges sourceIndicesPrivileges = request.indexPrivileges()[0]; assertThat(sourceIndicesPrivileges.getIndices(), is(arrayContaining(SOURCE_INDEX_NAME))); assertThat(sourceIndicesPrivileges.getPrivileges(), is(arrayContaining("read", "view_index_metadata"))); + assertThat(sourceIndicesPrivileges.allowRestrictedIndices(), is(true)); RoleDescriptor.IndicesPrivileges destIndicesPrivileges = request.indexPrivileges()[1]; assertThat(destIndicesPrivileges.getIndices(), is(arrayContaining(DEST_INDEX_NAME))); assertThat(destIndicesPrivileges.getPrivileges(), is(arrayContaining("read", "index"))); + assertThat(destIndicesPrivileges.allowRestrictedIndices(), is(true)); }, e -> fail(e.getMessage())) ); } @@ -235,6 +240,7 @@ public void testCheckPrivileges_NoLocalIndices_CheckDestIndexPrivileges_DestInde RoleDescriptor.IndicesPrivileges destIndicesPrivileges = request.indexPrivileges()[0]; assertThat(destIndicesPrivileges.getIndices(), is(arrayContaining(DEST_INDEX_NAME))); assertThat(destIndicesPrivileges.getPrivileges(), is(arrayContaining("read", "index"))); + assertThat(destIndicesPrivileges.allowRestrictedIndices(), is(true)); }, e -> fail(e.getMessage())) ); } @@ -267,9 +273,11 @@ public void testCheckPrivileges_CheckDestIndexPrivileges_DestIndexExistsWithRete RoleDescriptor.IndicesPrivileges sourceIndicesPrivileges = request.indexPrivileges()[0]; assertThat(sourceIndicesPrivileges.getIndices(), is(arrayContaining(SOURCE_INDEX_NAME))); assertThat(sourceIndicesPrivileges.getPrivileges(), is(arrayContaining("read", "view_index_metadata"))); + assertThat(sourceIndicesPrivileges.allowRestrictedIndices(), is(true)); RoleDescriptor.IndicesPrivileges destIndicesPrivileges = request.indexPrivileges()[1]; assertThat(destIndicesPrivileges.getIndices(), is(arrayContaining(DEST_INDEX_NAME))); assertThat(destIndicesPrivileges.getPrivileges(), is(arrayContaining("read", "index", "delete"))); + assertThat(destIndicesPrivileges.allowRestrictedIndices(), is(true)); }, e -> fail(e.getMessage())) ); } From 53ddd34f4423e2912e1a575db9a6513666e34724 Mon Sep 17 00:00:00 2001 From: Ryan Ernst Date: Wed, 12 Apr 2023 07:40:04 -0700 Subject: [PATCH 3/4] Move logging shutdown to after waiting on node close (#95093) When Elasticsearch is shutting down, the Node instance is closed, and then logging is shutdown. However, some aspects of Node shutdown happen asynchronously, and awaiting that final close from the node occurs after shutting down logging. This commit moves logging shutdown to the very end of shutdown, to allow for as much information as possible to be logged if something goes wrong. --- .../main/java/org/elasticsearch/bootstrap/Elasticsearch.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java index bfaf712d4872f..d1031b1da4984 100644 --- a/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java +++ b/server/src/main/java/org/elasticsearch/bootstrap/Elasticsearch.java @@ -446,8 +446,6 @@ private static void shutdown() { var es = INSTANCE; try { IOUtils.close(es.node, es.spawner); - LoggerContext context = (LoggerContext) LogManager.getContext(false); - Configurator.shutdown(context); if (es.node != null && es.node.awaitClose(10, TimeUnit.SECONDS) == false) { throw new IllegalStateException( "Node didn't stop within 10 seconds. " + "Any outstanding requests or tasks might get killed." @@ -459,6 +457,9 @@ private static void shutdown() { LogManager.getLogger(Elasticsearch.class).warn("Thread got interrupted while waiting for the node to shutdown."); Thread.currentThread().interrupt(); } finally { + LoggerContext context = (LoggerContext) LogManager.getContext(false); + Configurator.shutdown(context); + es.keepAliveLatch.countDown(); } } From 46f5ee4fd79821129c9e5b1a9f6685f3ded96a97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20FOUCRET?= Date: Wed, 12 Apr 2023 17:11:32 +0200 Subject: [PATCH 4/4] Behavioral Analytics - Fix failing YAML tests on main (#95193) * Fix failing tests on main --- ...tion.post_behavioral_analytics_event.json} | 2 +- x-pack/plugin/ent-search/qa/rest/build.gradle | 2 +- .../90_behavioral_analytics_event_post.yml | 48 +++++++++---------- 3 files changed, 26 insertions(+), 26 deletions(-) rename rest-api-spec/src/main/resources/rest-api-spec/api/{behavioral_analytics.post_event.json => search_application.post_behavioral_analytics_event.json} (94%) diff --git a/rest-api-spec/src/main/resources/rest-api-spec/api/behavioral_analytics.post_event.json b/rest-api-spec/src/main/resources/rest-api-spec/api/search_application.post_behavioral_analytics_event.json similarity index 94% rename from rest-api-spec/src/main/resources/rest-api-spec/api/behavioral_analytics.post_event.json rename to rest-api-spec/src/main/resources/rest-api-spec/api/search_application.post_behavioral_analytics_event.json index 2a8206b5fefa3..0de23b23d3797 100644 --- a/rest-api-spec/src/main/resources/rest-api-spec/api/behavioral_analytics.post_event.json +++ b/rest-api-spec/src/main/resources/rest-api-spec/api/search_application.post_behavioral_analytics_event.json @@ -1,5 +1,5 @@ { - "behavioral_analytics.post_event": { + "search_application.post_behavioral_analytics_event": { "documentation": { "url": "http://todo.com/tbd", "description": "Creates a behavioral analytics event for existing collection." diff --git a/x-pack/plugin/ent-search/qa/rest/build.gradle b/x-pack/plugin/ent-search/qa/rest/build.gradle index da915fc3e87a6..8c717bda1380c 100644 --- a/x-pack/plugin/ent-search/qa/rest/build.gradle +++ b/x-pack/plugin/ent-search/qa/rest/build.gradle @@ -7,7 +7,7 @@ dependencies { restResources { restApi { - include '_common', 'cluster', 'nodes', 'indices', 'index', 'search_application', 'behavioral_analytics' + include '_common', 'cluster', 'nodes', 'indices', 'index', 'search_application' } } diff --git a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/90_behavioral_analytics_event_post.yml b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/90_behavioral_analytics_event_post.yml index ba5598becfd2d..c28282504ae98 100644 --- a/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/90_behavioral_analytics_event_post.yml +++ b/x-pack/plugin/ent-search/qa/rest/src/yamlRestTest/resources/rest-api-spec/test/entsearch/90_behavioral_analytics_event_post.yml @@ -1,12 +1,12 @@ setup: - do: - behavioral_analytics.put: + search_application.put_behavioral_analytics: name: my-test-analytics-collection --- teardown: - do: - behavioral_analytics.delete: + search_application.delete_behavioral_analytics: name: my-test-analytics-collection ignore: 404 @@ -15,7 +15,7 @@ teardown: --- "Post page_view analytics event": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "page_view" body: @@ -30,7 +30,7 @@ teardown: "Post page_view analytics event - Missing page.url": - do: catch: "bad_request" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "page_view" body: @@ -43,7 +43,7 @@ teardown: --- "Post page_view analytics event - With document": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "page_view" body: @@ -60,7 +60,7 @@ teardown: --- "Post page_view analytics event - With page title": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "page_view" body: @@ -75,7 +75,7 @@ teardown: --- "Post page_view analytics event - With referrer": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "page_view" body: @@ -91,7 +91,7 @@ teardown: --- "Post search analytics event": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search" body: @@ -106,7 +106,7 @@ teardown: "Post search analytics event – Missing search query": - do: catch: "bad_request" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search" body: @@ -119,7 +119,7 @@ teardown: --- "Post search analytics event - With sort order": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search" body: @@ -135,7 +135,7 @@ teardown: --- "Post search analytics event - With sort name and direction": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search" body: @@ -152,7 +152,7 @@ teardown: --- "Post search analytics event - With pagination": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search" body: @@ -169,7 +169,7 @@ teardown: --- "Post search analytics event - With search application": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search" body: @@ -184,7 +184,7 @@ teardown: --- "Post search analytics event - With search results": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search" body: @@ -214,7 +214,7 @@ teardown: --- "Post search_click analytics event": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search_click" body: @@ -232,7 +232,7 @@ teardown: --- "Post search_click analytics event - Page Only": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search_click" body: @@ -248,7 +248,7 @@ teardown: --- "Post search_click analytics event - Document Only": - do: - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search_click" body: @@ -266,7 +266,7 @@ teardown: "Post search_click analytics event – Missing search query": - do: catch: "bad_request" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search_click" body: @@ -282,7 +282,7 @@ teardown: "Post search_click analytics event – Missing page url and document": - do: catch: "bad_request" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "search_click" body: @@ -299,7 +299,7 @@ teardown: "Post analytics event - Analytics collection does not exist": - do: catch: "missing" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: test-nonexistent-analytics-collection event_type: "page_view" body: @@ -314,7 +314,7 @@ teardown: "Post analytics event - Event type does not exist": - do: catch: "bad_request" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "nonexistent-event-type" body: @@ -331,7 +331,7 @@ teardown: "Post page_view analytics event - Missing session.id": - do: catch: "bad_request" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "page_view" body: @@ -345,7 +345,7 @@ teardown: "Post page_view analytics event - Missing user.id": - do: catch: "bad_request" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "page_view" body: @@ -359,7 +359,7 @@ teardown: "Post analytics event - Unknown event field": - do: catch: "bad_request" - behavioral_analytics.post_event: + search_application.post_behavioral_analytics_event: collection_name: my-test-analytics-collection event_type: "nonexistent-event-type" body: