From 106fd001f3409a9edb54be243c63924a31c5f88e Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sat, 3 Aug 2024 22:24:39 +0500 Subject: [PATCH 01/17] replication added Signed-off-by: Tokesh --- spec/namespaces/replication.yaml | 261 ++++++++++++++++++++++++++ spec/schemas/replication._common.yaml | 207 ++++++++++++++++++++ tests/replication/replica.yaml | 39 ++++ 3 files changed, 507 insertions(+) create mode 100644 spec/namespaces/replication.yaml create mode 100644 spec/schemas/replication._common.yaml create mode 100644 tests/replication/replica.yaml diff --git a/spec/namespaces/replication.yaml b/spec/namespaces/replication.yaml new file mode 100644 index 000000000..200dd6356 --- /dev/null +++ b/spec/namespaces/replication.yaml @@ -0,0 +1,261 @@ +openapi: 3.1.0 +info: + title: OpenSearch Replication API + description: OpenSearch Replication API + version: 1.0.0 +paths: + /_plugins/_replication/{index}/_start: + put: + operationId: replication.start.0 + x-operation-group: replication.start + x-version-added: '1.1' + description: Initiate replication of an index from the leader cluster to the follower cluster. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#start-replication + requestBody: + $ref: '#/components/requestBodies/replication.start' + responses: + '200': + $ref: '#/components/responses/replication.start@200' + /_plugins/_replication/{index}/_stop: + post: + operationId: replication.stop.0 + x-operation-group: replication.stop + x-version-added: '1.1' + description: Terminates replication and converts the follower index to a standard index. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#stop-replication + requestBody: + $ref: '#/components/requestBodies/replication.stop' + responses: + '200': + $ref: '#/components/responses/replication.stop@200' + /_plugins/_replication/{index}/_pause: + post: + operationId: replication.pause.0 + x-operation-group: replication.pause + x-version-added: '1.1' + description: Pauses replication of the leader index. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#pause-replication + requestBody: + $ref: '#/components/requestBodies/replication.pause' + responses: + '200': + $ref: '#/components/responses/replication.pause@200' + /_plugins/_replication/{index}/_resume: + post: + operationId: replication.resume.0 + x-operation-group: replication.resume + x-version-added: '1.1' + description: Resumes replication of the leader index. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#resume-replication + requestBody: + $ref: '#/components/requestBodies/replication.resume' + responses: + '200': + $ref: '#/components/responses/replication.resume@200' + /_plugins/_replication/{index}/_status: + get: + operationId: replication.status.0 + x-operation-group: replication.status + x-version-added: '1.1' + description: Gets the status of index replication. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#get-replication-status + responses: + '200': + $ref: '#/components/responses/replication.status@200' + /_plugins/_replication/leader_stats: + get: + operationId: replication.leader_stats.0 + x-operation-group: replication.leader_stats + x-version-added: '1.1' + description: Gets information about replicated leader indexes on a specified cluster. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#get-leader-cluster-stats + responses: + '200': + $ref: '#/components/responses/replication.leader_stats@200' + /_plugins/_replication/follower_stats: + get: + operationId: replication.follower_stats.0 + x-operation-group: replication.follower_stats + x-version-added: '1.1' + description: Gets information about follower (syncing) indexes on a specified cluster. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#get-follower-cluster-stats + responses: + '200': + $ref: '#/components/responses/replication.follower_stats@200' + /_plugins/_replication/autofollow_stats: + get: + operationId: replication.autofollow_stats.0 + x-operation-group: replication.autofollow_stats + x-version-added: '1.1' + description: Gets information about auto-follow activity and any replication rules configured on the specified cluster. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#get-auto-follow-stats + responses: + '200': + $ref: '#/components/responses/replication.autofollow_stats@200' + /_plugins/_replication/{follower-index}/_update: + put: + operationId: replication.update_settings.0 + x-operation-group: replication.update_settings + x-version-added: '1.1' + description: Updates settings on the follower index. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#update-settings + requestBody: + $ref: '#/components/requestBodies/replication.update_settings' + responses: + '200': + $ref: '#/components/responses/replication.update_settings@200' + /_plugins/_replication/_autofollow: + post: + operationId: replication.replication_rule.0 + x-operation-group: replication.replication_rule + x-version-added: '1.1' + description: Automatically starts replication on indexes matching a specified pattern. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#create-replication-rule + requestBody: + $ref: '#/components/requestBodies/replication.create_replication_rule' + responses: + '200': + $ref: '#/components/responses/replication.create_replication_rule@200' + delete: + operationId: replication.delete_replication_rule.0 + x-operation-group: replication.delete_replication_rule + x-version-added: '1.1' + description: Deletes the specified replication rule. + externalDocs: + url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#delete-replication-rule + requestBody: + $ref: '#/components/requestBodies/replication.delete_replication_rule' + responses: + '200': + $ref: '#/components/responses/replication.delete_replication_rule@200' +components: + requestBodies: + replication.start: + content: + application/json: + schema: + $ref: '../schemas/replication._common.yaml#/components/schemas/Replication' + required: true + replication.stop: + content: + application/json: + schema: + type: Object + required: true + replication.pause: + content: + application/json: + schema: + type: Object + required: true + replication.resume: + content: + application/json: + schema: + type: Object + required: true + replication.update_settings: + content: + application/json: + schema: + $ref: '../schemas/replication._common.yaml#/components/schemas/UpdateSettings' + required: true + replication.create_replication_rule: + content: + application/json: + schema: + $ref: '../schemas/replication._common.yaml#/components/schemas/CreateReplicationRule' + required: true + replication.delete_replication_rule: + content: + application/json: + schema: + $ref: '../schemas/replication._common.yaml#/components/schemas/DeleteReplicationRule' + required: true + responses: + replication.start@200: + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + replication.stop@200: + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + replication.pause@200: + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + replication.resume@200: + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + replication.status@200: + content: + application/json: + schema: + $ref: '../schemas/replication._common.yaml#/components/schemas/Status' + replication.leader_stats@200: + content: + application/json: + schema: + $ref: '../schemas/replication._common.yaml#/components/schemas/LeaderStatus' + replication.follower_stats@200: + content: + application/json: + schema: + $ref: '../schemas/replication._common.yaml#/components/schemas/FollowerStatus' + replication.autofollow_stats@200: + content: + application/json: + schema: + $ref: '../schemas/replication._common.yaml#/components/schemas/AutoFollowStatus' + replication.update_settings@200: + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + replication.create_replication_rule@200: + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean + replication.delete_replication_rule@200: + content: + application/json: + schema: + type: object + properties: + acknowledged: + type: boolean \ No newline at end of file diff --git a/spec/schemas/replication._common.yaml b/spec/schemas/replication._common.yaml new file mode 100644 index 000000000..94febb860 --- /dev/null +++ b/spec/schemas/replication._common.yaml @@ -0,0 +1,207 @@ +openapi: 3.1.0 +info: + title: Schemas of replication._common category. + description: Schemas of replication._common category. + version: 1.0.0 +paths: {} +components: + schemas: + Replication: + type: object + properties: + leader_alias: + type: string + leader_index: + type: string + use_roles: + $ref: '#/components/schemas/UseRoles' + UseRoles: + type: object + properties: + leader_cluster_role: + type: string + follower_cluster_role: + type: string + Status: + type: object + properties: + status: + type: string + reason: + type: string + leader_alias: + type: string + leader_index: + type: string + follower_index: + type: string + syncing_details: + $ref: '#/components/schemas/SyncingDetails' + SyncingDetails: + type: object + properties: + leader_checkpoint: + type: integer + follower_checkpoint: + type: integer + seq_no: + type: integer + LeaderStatus: + type: object + properties: + num_replicated_indices: + type: number + operations_read: + type: number + translog_size_bytes: + type: number + operations_read_lucene: + type: number + operations_read_translog: + type: number + total_read_time_lucene_millis: + type: number + total_read_time_translog_millis: + type: number + bytes_read: + type: number + # index_stats: + # type: Object + # additionalProperties: + # type: object + # properties: + # $ref: '#/components/schemas/IndexStatus' + IndexStatus: + type: object + properties: + operations_read: + type: number + translog_size_bytes: + type: number + operations_read_lucene: + type: number + operations_read_translog: + type: number + total_read_time_lucene_millis: + type: number + total_read_time_translog_millis: + type: number + bytes_read: + type: number + FollowerStatus: + type: object + properties: + num_syncing_indices: + type: number + num_bootstrapping_indices: + type: number + num_paused_indices: + type: number + num_failed_indices: + type: number + num_shard_tasks: + type: number + num_index_tasks: + type: number + operations_written: + type: number + operations_read: + type: number + failed_read_requests: + type: number + throttled_read_requests: + type: number + failed_write_requests: + type: number + throttled_write_requests: + type: number + follower_checkpoint: + type: number + leader_checkpoint: + type: number + total_write_time_millis: + type: number + # index_stats: + # type: Object + # additionalProperties: + # type: object + # properties: + # $ref: '#/components/schemas/IndexFollowerStatus' + IndexFollowerStatus: + type: object + properties: + operations_written: + type: number + operations_read: + type: number + failed_read_requests: + type: number + throttled_read_requests: + type: number + failed_write_requests: + type: number + throttled_write_requests: + type: number + follower_checkpoint: + type: number + leader_checkpoint: + type: number + total_write_time_millis: + type: number + AutoFollowStatus: + type: object + properties: + num_success_start_replication: + type: number + num_failed_start_replication: + type: number + num_failed_leader_calls: + type: number + failed_indices: + type: array + items: + type: string + autofollow_stats: + type: array + items: + $ref: '#/components/schemas/AutoFollowStats' + AutoFollowStats: + type: object + properties: + name: + type: string # Предполагается, что это строка + pattern: + type: string # Предполагается, что это строка + num_success_start_replication: + type: number + num_failed_start_replication: + type: number + num_failed_leader_calls: + type: number + failed_indices: + type: array + items: + type: string + UpdateSettings: + type: object + properties: + settings: + type: string + CreateReplicationRule: + type: object + properties: + leader_alias: + type: string + name: + type: string + pattern: + type: string + use_roles: + $ref: '#/components/schemas/UseRoles' + DeleteReplicationRule: + type: object + properties: + leader_alias: + type: string + name: + type: string \ No newline at end of file diff --git a/tests/replication/replica.yaml b/tests/replication/replica.yaml new file mode 100644 index 000000000..54cfde91e --- /dev/null +++ b/tests/replication/replica.yaml @@ -0,0 +1,39 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +description: Test to explicitly clear the cursor context + +# prologues: + # - path: /{index} + # method: PUT + # parameters: + # index: books + # request_body: + # payload: {} + # - path: /_bulk + # method: POST + # request_body: + # content_type: application/x-ndjson + # payload: + # - {create: {_index: books, _id: book_1392214}} + # - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + # - {create: {_index: books, _id: book_1392215}} + # - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} + # - path: /{index}/_refresh + # method: POST + # parameters: + # index: books +# epilogues: + # - path: /books + # method: DELETE + # status: [200, 404] +chapters: + - synopsis: Cat with a json response. + path: /_cat/nodes + version: '>= 2.0' + method: GET + parameters: + format: json + response: + status: 200 + payload: + - cluster_manager: '*' \ No newline at end of file From e912e13792b16d42e4b60fecbe0f36936eabfd9c Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sat, 3 Aug 2024 22:30:38 +0500 Subject: [PATCH 02/17] fixing lint and trying test verbose Signed-off-by: Tokesh --- .cspell | 1 + .github/workflows/test-spec.yml | 2 +- spec/schemas/replication._common.yaml | 12 ++++---- tests/replication/replica.yaml | 44 +++++++++++++-------------- 4 files changed, 30 insertions(+), 29 deletions(-) diff --git a/.cspell b/.cspell index 80670e9b4..fff1b5cef 100644 --- a/.cspell +++ b/.cspell @@ -9,6 +9,7 @@ authc authinfo authtoken autocut +autofollow backendroles backpressure beider diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index c147cbf40..01388d80e 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -56,7 +56,7 @@ jobs: - name: Run Tests run: | npm run test:spec -- \ - --opensearch-insecure \ + --opensearch-insecure --verbose\ --opensearch-version=${{ matrix.entry.version }} \ --coverage coverage/test-spec-coverage-${{ matrix.entry.version }}.json diff --git a/spec/schemas/replication._common.yaml b/spec/schemas/replication._common.yaml index 94febb860..11dfc175b 100644 --- a/spec/schemas/replication._common.yaml +++ b/spec/schemas/replication._common.yaml @@ -67,10 +67,10 @@ components: type: number # index_stats: # type: Object - # additionalProperties: - # type: object - # properties: - # $ref: '#/components/schemas/IndexStatus' + # additionalProperties: + # type: object + # properties: + # $ref: '#/components/schemas/IndexStatus' IndexStatus: type: object properties: @@ -169,9 +169,9 @@ components: type: object properties: name: - type: string # Предполагается, что это строка + type: string pattern: - type: string # Предполагается, что это строка + type: string num_success_start_replication: type: number num_failed_start_replication: diff --git a/tests/replication/replica.yaml b/tests/replication/replica.yaml index 54cfde91e..6a580f21b 100644 --- a/tests/replication/replica.yaml +++ b/tests/replication/replica.yaml @@ -3,29 +3,29 @@ $schema: ../../json_schemas/test_story.schema.yaml description: Test to explicitly clear the cursor context # prologues: - # - path: /{index} - # method: PUT - # parameters: - # index: books - # request_body: - # payload: {} - # - path: /_bulk - # method: POST - # request_body: - # content_type: application/x-ndjson - # payload: - # - {create: {_index: books, _id: book_1392214}} - # - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} - # - {create: {_index: books, _id: book_1392215}} - # - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} - # - path: /{index}/_refresh - # method: POST - # parameters: - # index: books +# - path: /{index} +# method: PUT +# parameters: +# index: books +# request_body: +# payload: {} +# - path: /_bulk +# method: POST +# request_body: +# content_type: application/x-ndjson +# payload: +# - {create: {_index: books, _id: book_1392214}} +# - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} +# - {create: {_index: books, _id: book_1392215}} +# - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} +# - path: /{index}/_refresh +# method: POST +# parameters: +# index: books # epilogues: - # - path: /books - # method: DELETE - # status: [200, 404] +# - path: /books +# method: DELETE +# status: [200, 404] chapters: - synopsis: Cat with a json response. path: /_cat/nodes From bd877a8211b359a6ec143bcaebd70a67882a42ae Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 4 Aug 2024 00:16:47 +0500 Subject: [PATCH 03/17] changing docker compose Signed-off-by: Tokesh --- .github/opensearch-cluster/docker-compose.yml | 52 +++++++++++++++++-- 1 file changed, 48 insertions(+), 4 deletions(-) diff --git a/.github/opensearch-cluster/docker-compose.yml b/.github/opensearch-cluster/docker-compose.yml index bdd6f2be9..3828f452f 100644 --- a/.github/opensearch-cluster/docker-compose.yml +++ b/.github/opensearch-cluster/docker-compose.yml @@ -1,13 +1,57 @@ version: '3' services: - opensearch-cluster: + opensearch-node1: image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF} + container_name: opensearch-node1 + environment: + - cluster.name=opensearch-cluster + - node.name=opensearch-node1 + - discovery.seed_hosts=opensearch-node1,opensearch-node2 + - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 + - bootstrap.memory_lock=true + - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" + - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}' + - path.repo=/tmp/opensearch/repo + - plugins.index_state_management.job_interval=1 + ulimits: + memlock: + soft: -1 + hard: -1 + volumes: + - data1:/usr/share/opensearch/data ports: - - '9200:9200' - - '9600:9600' + - "9200:9200" + - "9600:9600" + networks: + - opensearch-net + + opensearch-node2: + image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF} + container_name: opensearch-node2 environment: + - cluster.name=opensearch-cluster + - node.name=opensearch-node2 + - discovery.seed_hosts=opensearch-node1,opensearch-node2 + - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 + - bootstrap.memory_lock=true + - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}' - - discovery.type=single-node - path.repo=/tmp/opensearch/repo - plugins.index_state_management.job_interval=1 + ulimits: + memlock: + soft: -1 + hard: -1 + volumes: + - data2:/usr/share/opensearch/data + networks: + - opensearch-net + +volumes: + data1: + data2: + +networks: + opensearch-net: + driver: bridge From addcd769cdceeb7908d8b32b68c48d55dfcc43c3 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 4 Aug 2024 01:43:52 +0500 Subject: [PATCH 04/17] adding tests for replication namespace Signed-off-by: Tokesh --- CHANGELOG.md | 1 + spec/namespaces/replication.yaml | 65 +++++++++++- spec/schemas/replication._common.yaml | 39 ++++--- tests/replication/replica.yaml | 147 +++++++++++++++++++++----- 4 files changed, 208 insertions(+), 44 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e24e482b8..0394299b8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -59,6 +59,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added a warning on mulitple paths being tested in the same file ([#452](https://github.com/opensearch-project/opensearch-api-specification/pull/452)) - Added `/_plugins/_query/settings` ([#456](https://github.com/opensearch-project/opensearch-api-specification/pull/456)) - Added `/_plugins/_ppl`, `explain` and `stats` ([#460](https://github.com/opensearch-project/opensearch-api-specification/pull/460)) +- Added `replication` namespace specs ([464](https://github.com/opensearch-project/opensearch-api-specification/pull/464)) ### Changed diff --git a/spec/namespaces/replication.yaml b/spec/namespaces/replication.yaml index 200dd6356..5347131f9 100644 --- a/spec/namespaces/replication.yaml +++ b/spec/namespaces/replication.yaml @@ -12,6 +12,8 @@ paths: description: Initiate replication of an index from the leader cluster to the follower cluster. externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#start-replication + parameters: + - $ref: '#/components/parameters/start::path.index' requestBody: $ref: '#/components/requestBodies/replication.start' responses: @@ -25,6 +27,8 @@ paths: description: Terminates replication and converts the follower index to a standard index. externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#stop-replication + parameters: + - $ref: '#/components/parameters/stop::path.index' requestBody: $ref: '#/components/requestBodies/replication.stop' responses: @@ -38,6 +42,8 @@ paths: description: Pauses replication of the leader index. externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#pause-replication + parameters: + - $ref: '#/components/parameters/pause::path.index' requestBody: $ref: '#/components/requestBodies/replication.pause' responses: @@ -51,6 +57,8 @@ paths: description: Resumes replication of the leader index. externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#resume-replication + parameters: + - $ref: '#/components/parameters/resume::path.index' requestBody: $ref: '#/components/requestBodies/replication.resume' responses: @@ -64,6 +72,8 @@ paths: description: Gets the status of index replication. externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#get-replication-status + parameters: + - $ref: '#/components/parameters/status::path.index' responses: '200': $ref: '#/components/responses/replication.status@200' @@ -100,7 +110,7 @@ paths: responses: '200': $ref: '#/components/responses/replication.autofollow_stats@200' - /_plugins/_replication/{follower-index}/_update: + /_plugins/_replication/{index}/_update: put: operationId: replication.update_settings.0 x-operation-group: replication.update_settings @@ -108,6 +118,8 @@ paths: description: Updates settings on the follower index. externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#update-settings + parameters: + - $ref: '#/components/parameters/update_settings::path.index' requestBody: $ref: '#/components/requestBodies/replication.update_settings' responses: @@ -139,6 +151,55 @@ paths: '200': $ref: '#/components/responses/replication.delete_replication_rule@200' components: + parameters: + start::path.index: + in: path + name: index + description: Name of the data stream, index, or index alias to perform bulk actions on. + required: true + schema: + $ref: '../schemas/_common.yaml#/components/schemas/IndexName' + style: simple + stop::path.index: + in: path + name: index + description: Name of the data stream, index, or index alias to perform bulk actions on. + required: true + schema: + $ref: '../schemas/_common.yaml#/components/schemas/IndexName' + style: simple + pause::path.index: + in: path + name: index + description: Name of the data stream, index, or index alias to perform bulk actions on. + required: true + schema: + $ref: '../schemas/_common.yaml#/components/schemas/IndexName' + style: simple + resume::path.index: + in: path + name: index + description: Name of the data stream, index, or index alias to perform bulk actions on. + required: true + schema: + $ref: '../schemas/_common.yaml#/components/schemas/IndexName' + style: simple + status::path.index: + in: path + name: index + description: Name of the data stream, index, or index alias to perform bulk actions on. + required: true + schema: + $ref: '../schemas/_common.yaml#/components/schemas/IndexName' + style: simple + update_settings::path.index: + in: path + name: index + description: Name of the data stream, index, or index alias to perform bulk actions on. + required: true + schema: + $ref: '../schemas/_common.yaml#/components/schemas/IndexName' + style: simple requestBodies: replication.start: content: @@ -150,7 +211,7 @@ components: content: application/json: schema: - type: Object + type: object required: true replication.pause: content: diff --git a/spec/schemas/replication._common.yaml b/spec/schemas/replication._common.yaml index 11dfc175b..6eea148bc 100644 --- a/spec/schemas/replication._common.yaml +++ b/spec/schemas/replication._common.yaml @@ -65,12 +65,10 @@ components: type: number bytes_read: type: number - # index_stats: - # type: Object - # additionalProperties: - # type: object - # properties: - # $ref: '#/components/schemas/IndexStatus' + index_stats: + type: object + additionalProperties: + $ref: '#/components/schemas/IndexStatus' IndexStatus: type: object properties: @@ -121,12 +119,10 @@ components: type: number total_write_time_millis: type: number - # index_stats: - # type: Object - # additionalProperties: - # type: object - # properties: - # $ref: '#/components/schemas/IndexFollowerStatus' + index_stats: + type: object + additionalProperties: + $ref: '#/components/schemas/IndexFollowerStatus' IndexFollowerStatus: type: object properties: @@ -186,7 +182,24 @@ components: type: object properties: settings: - type: string + anyOf: + - type: object + properties: + index.number_of_shards: + type: integer + index.number_of_replicas: + type: integer + - $ref: '#/components/schemas/SettingsBody' + SettingsBody: + type: object + properties: + index: + type: object + properties: + number_of_shards: + type: integer + number_of_replicas: + type: integer CreateReplicationRule: type: object properties: diff --git a/tests/replication/replica.yaml b/tests/replication/replica.yaml index 6a580f21b..afcd07422 100644 --- a/tests/replication/replica.yaml +++ b/tests/replication/replica.yaml @@ -2,38 +2,127 @@ $schema: ../../json_schemas/test_story.schema.yaml description: Test to explicitly clear the cursor context -# prologues: -# - path: /{index} -# method: PUT -# parameters: -# index: books -# request_body: -# payload: {} -# - path: /_bulk -# method: POST -# request_body: -# content_type: application/x-ndjson -# payload: -# - {create: {_index: books, _id: book_1392214}} -# - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} -# - {create: {_index: books, _id: book_1392215}} -# - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} -# - path: /{index}/_refresh -# method: POST -# parameters: -# index: books -# epilogues: -# - path: /books -# method: DELETE -# status: [200, 404] +prologues: +- path: /{index} + method: PUT + parameters: + index: books + request_body: + payload: {} +- path: /_bulk + method: POST + request_body: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book_1392214}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} +- path: /{index}/_refresh + method: POST + parameters: + index: books +epilogues: +- path: /_plugins/_replication/{index}/_stop + method: POST + parameters: + index: books-names + request_body: + payload: {} +- path: /books-names + method: DELETE + status: [200, 404] +- path: /books + method: DELETE + status: [200, 404] chapters: - - synopsis: Cat with a json response. - path: /_cat/nodes - version: '>= 2.0' + - synopsis: Establish connection. + path: /_cluster/settings + method: PUT + request_body: + payload: + persistent: + cluster: + remote: + my-connection-alias: + seeds: ["172.18.0.3:9300"] + response: + status: 200 + - synopsis: Start replication. + path: /_plugins/_replication/{index}/_start + version: '>= 1.1' + method: PUT + parameters: + index: books-names + request_body: + payload: + leader_alias: 'my-connection-alias' + leader_index: 'books' + use_roles: + leader_cluster_role: 'leader_role' + follower_cluster_role: 'follower_role' + response: + status: 200 + - synopsis: Get replication stats. + path: /_plugins/_replication/{index}/_status + version: '>= 1.1' + method: GET + parameters: + index: books-names + response: + status: 200 + - synopsis: Get leader stats. + path: /_plugins/_replication/leader_stats + version: '>= 1.1' + method: GET + response: + status: 200 + - synopsis: Get follower stats. + path: /_plugins/_replication/follower_stats + version: '>= 1.1' + method: GET + response: + status: 200 + - synopsis: Get auto-follow stats. + path: /_plugins/_replication/autofollow_stats + version: '>= 1.1' method: GET + response: + status: 200 + - synopsis: Update settings. + path: /_plugins/_replication/{index}/_update + version: '>= 1.1' + method: PUT parameters: - format: json + index: books-names + request_body: + payload: + settings: + index.number_of_shards: 4 + index.number_of_replicas: 2 + response: + status: 200 + - synopsis: Create replication rule. + path: /_plugins/_replication/_autofollow + version: '>= 1.1' + method: POST + request_body: + payload: + leader_alias: "my-connection-alias" + name: "books" + pattern: "books-*" + use_roles: + leader_cluster_role: 'leader_role' + follower_cluster_role: 'follower_role' response: status: 200 + - synopsis: Delete replication rule. + path: /_plugins/_replication/_autofollow + version: '>= 1.1' + method: DELETE + request_body: payload: - - cluster_manager: '*' \ No newline at end of file + leader_alias: "my-connection-alias" + name: "books" + response: + status: 200 \ No newline at end of file From 638d60e4978601537df10638e74bf5a72379bc0e Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 4 Aug 2024 01:50:44 +0500 Subject: [PATCH 05/17] fixing lint, validate specs ci Signed-off-by: Tokesh --- .cspell | 2 + .github/opensearch-cluster/docker-compose.yml | 28 +++--- spec/namespaces/replication.yaml | 24 +++--- tests/replication/replica.yaml | 86 +++++++++---------- 4 files changed, 69 insertions(+), 71 deletions(-) diff --git a/.cspell b/.cspell index fff1b5cef..bc33abec4 100644 --- a/.cspell +++ b/.cspell @@ -79,6 +79,7 @@ lucene Lucene lycheeverse marvinpinto +memlock metaphone mget millis @@ -174,6 +175,7 @@ tokenfilters translog Translog tubone +ulimits unigrams Unmanaged unmatch diff --git a/.github/opensearch-cluster/docker-compose.yml b/.github/opensearch-cluster/docker-compose.yml index 3828f452f..cdf77a035 100644 --- a/.github/opensearch-cluster/docker-compose.yml +++ b/.github/opensearch-cluster/docker-compose.yml @@ -5,13 +5,13 @@ services: image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF} container_name: opensearch-node1 environment: + - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}' + - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m + - bootstrap.memory_lock=true + - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 - cluster.name=opensearch-cluster - - node.name=opensearch-node1 - discovery.seed_hosts=opensearch-node1,opensearch-node2 - - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 - - bootstrap.memory_lock=true - - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" - - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}' + - node.name=opensearch-node1 - path.repo=/tmp/opensearch/repo - plugins.index_state_management.job_interval=1 ulimits: @@ -21,8 +21,8 @@ services: volumes: - data1:/usr/share/opensearch/data ports: - - "9200:9200" - - "9600:9600" + - '9200:9200' + - '9600:9600' networks: - opensearch-net @@ -30,13 +30,13 @@ services: image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF} container_name: opensearch-node2 environment: + - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}' + - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m + - bootstrap.memory_lock=true + - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 - cluster.name=opensearch-cluster - - node.name=opensearch-node2 - discovery.seed_hosts=opensearch-node1,opensearch-node2 - - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 - - bootstrap.memory_lock=true - - "OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m" - - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}' + - node.name=opensearch-node2 - path.repo=/tmp/opensearch/repo - plugins.index_state_management.job_interval=1 ulimits: @@ -48,10 +48,6 @@ services: networks: - opensearch-net -volumes: - data1: - data2: - networks: opensearch-net: driver: bridge diff --git a/spec/namespaces/replication.yaml b/spec/namespaces/replication.yaml index 5347131f9..c08d4092e 100644 --- a/spec/namespaces/replication.yaml +++ b/spec/namespaces/replication.yaml @@ -13,7 +13,7 @@ paths: externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#start-replication parameters: - - $ref: '#/components/parameters/start::path.index' + - $ref: '#/components/parameters/replication.start::path.index' requestBody: $ref: '#/components/requestBodies/replication.start' responses: @@ -28,7 +28,7 @@ paths: externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#stop-replication parameters: - - $ref: '#/components/parameters/stop::path.index' + - $ref: '#/components/parameters/replication.stop::path.index' requestBody: $ref: '#/components/requestBodies/replication.stop' responses: @@ -43,7 +43,7 @@ paths: externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#pause-replication parameters: - - $ref: '#/components/parameters/pause::path.index' + - $ref: '#/components/parameters/replication.pause::path.index' requestBody: $ref: '#/components/requestBodies/replication.pause' responses: @@ -58,7 +58,7 @@ paths: externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#resume-replication parameters: - - $ref: '#/components/parameters/resume::path.index' + - $ref: '#/components/parameters/replication.resume::path.index' requestBody: $ref: '#/components/requestBodies/replication.resume' responses: @@ -73,7 +73,7 @@ paths: externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#get-replication-status parameters: - - $ref: '#/components/parameters/status::path.index' + - $ref: '#/components/parameters/replication.status::path.index' responses: '200': $ref: '#/components/responses/replication.status@200' @@ -119,7 +119,7 @@ paths: externalDocs: url: https://opensearch.org/docs/latest/tuning-your-cluster/replication-plugin/api/#update-settings parameters: - - $ref: '#/components/parameters/update_settings::path.index' + - $ref: '#/components/parameters/replication.update_settings::path.index' requestBody: $ref: '#/components/requestBodies/replication.update_settings' responses: @@ -152,7 +152,7 @@ paths: $ref: '#/components/responses/replication.delete_replication_rule@200' components: parameters: - start::path.index: + replication.start::path.index: in: path name: index description: Name of the data stream, index, or index alias to perform bulk actions on. @@ -160,7 +160,7 @@ components: schema: $ref: '../schemas/_common.yaml#/components/schemas/IndexName' style: simple - stop::path.index: + replication.stop::path.index: in: path name: index description: Name of the data stream, index, or index alias to perform bulk actions on. @@ -168,7 +168,7 @@ components: schema: $ref: '../schemas/_common.yaml#/components/schemas/IndexName' style: simple - pause::path.index: + replication.pause::path.index: in: path name: index description: Name of the data stream, index, or index alias to perform bulk actions on. @@ -176,7 +176,7 @@ components: schema: $ref: '../schemas/_common.yaml#/components/schemas/IndexName' style: simple - resume::path.index: + replication.resume::path.index: in: path name: index description: Name of the data stream, index, or index alias to perform bulk actions on. @@ -184,7 +184,7 @@ components: schema: $ref: '../schemas/_common.yaml#/components/schemas/IndexName' style: simple - status::path.index: + replication.status::path.index: in: path name: index description: Name of the data stream, index, or index alias to perform bulk actions on. @@ -192,7 +192,7 @@ components: schema: $ref: '../schemas/_common.yaml#/components/schemas/IndexName' style: simple - update_settings::path.index: + replication.update_settings::path.index: in: path name: index description: Name of the data stream, index, or index alias to perform bulk actions on. diff --git a/tests/replication/replica.yaml b/tests/replication/replica.yaml index afcd07422..c32e141f4 100644 --- a/tests/replication/replica.yaml +++ b/tests/replication/replica.yaml @@ -3,38 +3,38 @@ $schema: ../../json_schemas/test_story.schema.yaml description: Test to explicitly clear the cursor context prologues: -- path: /{index} - method: PUT - parameters: - index: books - request_body: - payload: {} -- path: /_bulk - method: POST - request_body: - content_type: application/x-ndjson - payload: - - {create: {_index: books, _id: book_1392214}} - - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} - - {create: {_index: books, _id: book_1392215}} - - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} -- path: /{index}/_refresh - method: POST - parameters: - index: books + - path: /{index} + method: PUT + parameters: + index: books + request_body: + payload: {} + - path: /_bulk + method: POST + request_body: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book_1392214}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} + - path: /{index}/_refresh + method: POST + parameters: + index: books epilogues: -- path: /_plugins/_replication/{index}/_stop - method: POST - parameters: - index: books-names - request_body: - payload: {} -- path: /books-names - method: DELETE - status: [200, 404] -- path: /books - method: DELETE - status: [200, 404] + - path: /_plugins/_replication/{index}/_stop + method: POST + parameters: + index: books-names + request_body: + payload: {} + - path: /books-names + method: DELETE + status: [200, 404] + - path: /books + method: DELETE + status: [200, 404] chapters: - synopsis: Establish connection. path: /_cluster/settings @@ -45,7 +45,7 @@ chapters: cluster: remote: my-connection-alias: - seeds: ["172.18.0.3:9300"] + seeds: ['172.18.0.3:9300'] response: status: 200 - synopsis: Start replication. @@ -56,11 +56,11 @@ chapters: index: books-names request_body: payload: - leader_alias: 'my-connection-alias' - leader_index: 'books' + leader_alias: my-connection-alias + leader_index: books use_roles: - leader_cluster_role: 'leader_role' - follower_cluster_role: 'follower_role' + leader_cluster_role: leader_role + follower_cluster_role: follower_role response: status: 200 - synopsis: Get replication stats. @@ -108,12 +108,12 @@ chapters: method: POST request_body: payload: - leader_alias: "my-connection-alias" - name: "books" - pattern: "books-*" + leader_alias: my-connection-alias + name: books + pattern: 'books-*' use_roles: - leader_cluster_role: 'leader_role' - follower_cluster_role: 'follower_role' + leader_cluster_role: leader_role + follower_cluster_role: follower_role response: status: 200 - synopsis: Delete replication rule. @@ -122,7 +122,7 @@ chapters: method: DELETE request_body: payload: - leader_alias: "my-connection-alias" - name: "books" + leader_alias: my-connection-alias + name: books response: status: 200 \ No newline at end of file From a6e0a87da98b4eef04c195361d6d4e7dea2af5fd Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 4 Aug 2024 01:55:13 +0500 Subject: [PATCH 06/17] fixing docker-compose and validate specs ci Signed-off-by: Tokesh --- .github/opensearch-cluster/docker-compose.yml | 4 ---- spec/namespaces/replication.yaml | 4 ++-- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/opensearch-cluster/docker-compose.yml b/.github/opensearch-cluster/docker-compose.yml index cdf77a035..bfb05f01f 100644 --- a/.github/opensearch-cluster/docker-compose.yml +++ b/.github/opensearch-cluster/docker-compose.yml @@ -18,8 +18,6 @@ services: memlock: soft: -1 hard: -1 - volumes: - - data1:/usr/share/opensearch/data ports: - '9200:9200' - '9600:9600' @@ -43,8 +41,6 @@ services: memlock: soft: -1 hard: -1 - volumes: - - data2:/usr/share/opensearch/data networks: - opensearch-net diff --git a/spec/namespaces/replication.yaml b/spec/namespaces/replication.yaml index c08d4092e..b4f81902e 100644 --- a/spec/namespaces/replication.yaml +++ b/spec/namespaces/replication.yaml @@ -127,8 +127,8 @@ paths: $ref: '#/components/responses/replication.update_settings@200' /_plugins/_replication/_autofollow: post: - operationId: replication.replication_rule.0 - x-operation-group: replication.replication_rule + operationId: replication.create_replication_rule.0 + x-operation-group: replication.create_replication_rule x-version-added: '1.1' description: Automatically starts replication on indexes matching a specified pattern. externalDocs: From b012e7b7eed02e31e34e1bb90530b22a337083d5 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 4 Aug 2024 02:03:35 +0500 Subject: [PATCH 07/17] fixing validate specs ci Signed-off-by: Tokesh --- spec/namespaces/replication.yaml | 4 ++-- spec/schemas/replication._common.yaml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/namespaces/replication.yaml b/spec/namespaces/replication.yaml index b4f81902e..5bb133021 100644 --- a/spec/namespaces/replication.yaml +++ b/spec/namespaces/replication.yaml @@ -217,13 +217,13 @@ components: content: application/json: schema: - type: Object + type: object required: true replication.resume: content: application/json: schema: - type: Object + type: object required: true replication.update_settings: content: diff --git a/spec/schemas/replication._common.yaml b/spec/schemas/replication._common.yaml index 6eea148bc..d33ff2b0d 100644 --- a/spec/schemas/replication._common.yaml +++ b/spec/schemas/replication._common.yaml @@ -183,13 +183,13 @@ components: properties: settings: anyOf: + - $ref: '#/components/schemas/SettingsBody' - type: object properties: index.number_of_shards: type: integer index.number_of_replicas: type: integer - - $ref: '#/components/schemas/SettingsBody' SettingsBody: type: object properties: From 236fea70ebb30d5b200d78f560509085428a0d66 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 4 Aug 2024 02:06:25 +0500 Subject: [PATCH 08/17] trying to fix validate specs Signed-off-by: Tokesh --- spec/schemas/replication._common.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/spec/schemas/replication._common.yaml b/spec/schemas/replication._common.yaml index d33ff2b0d..be864a967 100644 --- a/spec/schemas/replication._common.yaml +++ b/spec/schemas/replication._common.yaml @@ -178,28 +178,28 @@ components: type: array items: type: string + SettingsBody: + type: object + properties: + index: + type: object + properties: + number_of_shards: + type: integer + number_of_replicas: + type: integer UpdateSettings: type: object properties: settings: anyOf: - - $ref: '#/components/schemas/SettingsBody' - type: object properties: index.number_of_shards: type: integer index.number_of_replicas: type: integer - SettingsBody: - type: object - properties: - index: - type: object - properties: - number_of_shards: - type: integer - number_of_replicas: - type: integer + - $ref: '#/components/schemas/SettingsBody' CreateReplicationRule: type: object properties: From 864ee68e743e209038ffd1062a1e0d9131e919f8 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 4 Aug 2024 02:08:36 +0500 Subject: [PATCH 09/17] trying to fix validate specs v2 Signed-off-by: Tokesh --- spec/schemas/replication._common.yaml | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/spec/schemas/replication._common.yaml b/spec/schemas/replication._common.yaml index be864a967..bdd11c3f3 100644 --- a/spec/schemas/replication._common.yaml +++ b/spec/schemas/replication._common.yaml @@ -182,12 +182,7 @@ components: type: object properties: index: - type: object - properties: - number_of_shards: - type: integer - number_of_replicas: - type: integer + $ref: '#/components/schemas/IndexSchema' UpdateSettings: type: object properties: @@ -200,6 +195,13 @@ components: index.number_of_replicas: type: integer - $ref: '#/components/schemas/SettingsBody' + IndexSchema: + type: object + properties: + number_of_shards: + type: integer + number_of_replicas: + type: integer CreateReplicationRule: type: object properties: From 42056a66c58bc1b50e26dc22e746d748e6096aec Mon Sep 17 00:00:00 2001 From: Tokesh Date: Mon, 18 Nov 2024 02:36:41 +0500 Subject: [PATCH 10/17] adding not covered index api tests Signed-off-by: Tokesh --- tests/default/indices/explain.yaml | 59 ++++++++++++++ tests/default/indices/mapping.yaml | 37 +++++++++ tests/default/indices/msearch.yaml | 124 +++++++++++++++++++++++++++++ tests/default/indices/refresh.yaml | 24 ++++++ 4 files changed, 244 insertions(+) create mode 100644 tests/default/indices/explain.yaml create mode 100644 tests/default/indices/msearch.yaml diff --git a/tests/default/indices/explain.yaml b/tests/default/indices/explain.yaml new file mode 100644 index 000000000..e5873ec58 --- /dev/null +++ b/tests/default/indices/explain.yaml @@ -0,0 +1,59 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test _explain. +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +prologues: + - id: doc + path: /movies/_doc + method: POST + request: + payload: + title: Beauty and the Beast + year: 1991 + status: [201] + output: + id: payload._id + - path: /_refresh + method: POST +chapters: + - synopsis: Post explanation for a document with query. + path: /{index}/_explain/{id} + method: POST + parameters: + index: movies + id: ${doc.id} + request: + payload: + query: + match: + title: "Beauty and the Beast" + response: + status: 200 + payload: + matched: true + explanation: + value: 1.1507283 + description: "sum of:" + details: [] + - synopsis: Get explanation for a document. + path: /{index}/_explain/{id} + method: GET + parameters: + index: movies + id: ${doc.id} + request: + payload: + query: + match: + title: "Beauty and the Beast" + response: + status: 200 + payload: + matched: true + explanation: + value: 1.1507283 + description: "sum of:" + details: [] \ No newline at end of file diff --git a/tests/default/indices/mapping.yaml b/tests/default/indices/mapping.yaml index 635ffe5cc..016a4f5ad 100644 --- a/tests/default/indices/mapping.yaml +++ b/tests/default/indices/mapping.yaml @@ -146,3 +146,40 @@ chapters: status: 200 payload: acknowledged: true + - synopsis: Add new fields to index mapping. + path: /{index}/_mapping + method: POST + parameters: + index: movies + request: + payload: + properties: + genre: + type: text + rating: + type: float + response: + status: 200 + payload: + acknowledged: true + - synopsis: Get specific field mappings for an index. + path: /{index}/_mapping/field/{fields} + method: GET + parameters: + index: movies + fields: director,year + response: + status: 200 + payload: + movies: + mappings: + year: + full_name: "year" + mapping: + year: + type: integer + director: + full_name: "director" + mapping: + director: + type: text diff --git a/tests/default/indices/msearch.yaml b/tests/default/indices/msearch.yaml new file mode 100644 index 000000000..7f1dc03db --- /dev/null +++ b/tests/default/indices/msearch.yaml @@ -0,0 +1,124 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test endpoints relevant to the lifecycle of an index, including multi-get and multi-search operations. +epilogues: + - path: /books + method: DELETE + status: [200, 404] + - path: /games + method: DELETE + status: [200, 404] +chapters: + - synopsis: Create an index named `books` with mappings and settings. + path: /{index} + method: PUT + parameters: + index: books + request: + payload: + mappings: + properties: + name: + type: keyword + age: + type: integer + settings: + number_of_shards: 5 + number_of_replicas: 2 + response: + status: 200 + + - synopsis: Create an index named `games` with default settings. + path: /{index} + method: PUT + parameters: + index: games + + - synopsis: Add documents to the `books` index. + path: /{index}/_doc/{id} + method: POST + parameters: + index: books + id: '1' + request: + payload: + name: "Book 1" + age: 10 + response: + status: 201 + + - synopsis: Add more documents to the `books` index. + path: /{index}/_doc/{id} + method: POST + parameters: + index: books + id: '2' + request: + payload: + name: "Book 2" + age: 20 + response: + status: 201 + + - synopsis: Add another document to the `books` index. + path: /{index}/_doc/{id} + method: POST + parameters: + index: books + id: '3' + request: + payload: + name: "Book 3" + age: 30 + response: + status: 201 + + - synopsis: Perform a `_mget` request to retrieve documents by IDs. + path: /{index}/_mget + method: POST + parameters: + index: books + request: + payload: + ids: ['1', '2', '3'] + response: + status: 200 + payload: + docs: + - _index: "books" + _id: "1" + _source: + name: "Book 1" + age: 10 + - _index: "books" + _id: "2" + _source: + name: "Book 2" + age: 20 + - _index: "books" + _id: "3" + _source: + name: "Book 3" + age: 30 + + - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call. + path: /{index}/_msearch + method: POST + parameters: + index: books + request: + content_type: application/x-ndjson + payload: + - { index: "books" } + - { "query": { "match": { "name": "Book 1" } } } + - { index: "books" } + - { "query": { "match": { "name": "Book 2" } } } + response: + status: 200 + - synopsis: Delete the `books` and `games` indices. + path: /{index} + method: DELETE + parameters: + index: books,games + response: + status: 200 \ No newline at end of file diff --git a/tests/default/indices/refresh.yaml b/tests/default/indices/refresh.yaml index 2303ed287..e5a02431b 100644 --- a/tests/default/indices/refresh.yaml +++ b/tests/default/indices/refresh.yaml @@ -32,3 +32,27 @@ chapters: payload: _shards: failed: 0 + - synopsis: Adding one more document. + path: /{index}/_doc + method: POST + parameters: + index: movies + request: + payload: + title: Margin call + year: 2011 + response: + status: 201 + - synopsis: Refresh an index. + path: /{index}/_refresh + method: GET + parameters: + index: movies + ignore_unavailable: true + allow_no_indices: false + expand_wildcards: all + response: + status: 200 + payload: + _shards: + failed: 0 \ No newline at end of file From 94915e9bb77fc4a72ceca7a9f8a5d14fe1d0ed9b Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sat, 23 Nov 2024 13:36:49 +0500 Subject: [PATCH 11/17] deleting not necessary files Signed-off-by: Tokesh --- .github/workflows/test-spec.yml | 2 +- tests/default/indices/explain.yaml | 2 - tests/replication/replica.yaml | 128 ----------------------------- tests/snapshot/docker-compose.yml | 19 +---- 4 files changed, 3 insertions(+), 148 deletions(-) delete mode 100644 tests/replication/replica.yaml diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index ff267a566..895ac1e4d 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -93,7 +93,7 @@ jobs: - name: Run Tests run: | npm run test:spec -- \ - --opensearch-insecure --verbose\ + --opensearch-insecure \ --opensearch-version=${{ matrix.entry.version }} \ --coverage coverage/test-spec-coverage-${{ steps.tests.outputs.hash }}.json \ --opensearch-url=${{ matrix.entry.url || 'https://localhost:9200'}} \ diff --git a/tests/default/indices/explain.yaml b/tests/default/indices/explain.yaml index 7a1727ab4..a99cc3561 100644 --- a/tests/default/indices/explain.yaml +++ b/tests/default/indices/explain.yaml @@ -1,7 +1,6 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test getting an explanation of how the relevance score is calculated for every result. - epilogues: - path: /movies method: DELETE @@ -50,4 +49,3 @@ chapters: title: Drive response: status: 200 - diff --git a/tests/replication/replica.yaml b/tests/replication/replica.yaml deleted file mode 100644 index c32e141f4..000000000 --- a/tests/replication/replica.yaml +++ /dev/null @@ -1,128 +0,0 @@ -$schema: ../../json_schemas/test_story.schema.yaml - -description: Test to explicitly clear the cursor context - -prologues: - - path: /{index} - method: PUT - parameters: - index: books - request_body: - payload: {} - - path: /_bulk - method: POST - request_body: - content_type: application/x-ndjson - payload: - - {create: {_index: books, _id: book_1392214}} - - {author: Harper Lee, title: To Kill a Mockingbird, year: 1960} - - {create: {_index: books, _id: book_1392215}} - - {author: Elizabeth Rudnick, title: Beauty and the Beast, year: 1991} - - path: /{index}/_refresh - method: POST - parameters: - index: books -epilogues: - - path: /_plugins/_replication/{index}/_stop - method: POST - parameters: - index: books-names - request_body: - payload: {} - - path: /books-names - method: DELETE - status: [200, 404] - - path: /books - method: DELETE - status: [200, 404] -chapters: - - synopsis: Establish connection. - path: /_cluster/settings - method: PUT - request_body: - payload: - persistent: - cluster: - remote: - my-connection-alias: - seeds: ['172.18.0.3:9300'] - response: - status: 200 - - synopsis: Start replication. - path: /_plugins/_replication/{index}/_start - version: '>= 1.1' - method: PUT - parameters: - index: books-names - request_body: - payload: - leader_alias: my-connection-alias - leader_index: books - use_roles: - leader_cluster_role: leader_role - follower_cluster_role: follower_role - response: - status: 200 - - synopsis: Get replication stats. - path: /_plugins/_replication/{index}/_status - version: '>= 1.1' - method: GET - parameters: - index: books-names - response: - status: 200 - - synopsis: Get leader stats. - path: /_plugins/_replication/leader_stats - version: '>= 1.1' - method: GET - response: - status: 200 - - synopsis: Get follower stats. - path: /_plugins/_replication/follower_stats - version: '>= 1.1' - method: GET - response: - status: 200 - - synopsis: Get auto-follow stats. - path: /_plugins/_replication/autofollow_stats - version: '>= 1.1' - method: GET - response: - status: 200 - - synopsis: Update settings. - path: /_plugins/_replication/{index}/_update - version: '>= 1.1' - method: PUT - parameters: - index: books-names - request_body: - payload: - settings: - index.number_of_shards: 4 - index.number_of_replicas: 2 - response: - status: 200 - - synopsis: Create replication rule. - path: /_plugins/_replication/_autofollow - version: '>= 1.1' - method: POST - request_body: - payload: - leader_alias: my-connection-alias - name: books - pattern: 'books-*' - use_roles: - leader_cluster_role: leader_role - follower_cluster_role: follower_role - response: - status: 200 - - synopsis: Delete replication rule. - path: /_plugins/_replication/_autofollow - version: '>= 1.1' - method: DELETE - request_body: - payload: - leader_alias: my-connection-alias - name: books - response: - status: 200 \ No newline at end of file diff --git a/tests/snapshot/docker-compose.yml b/tests/snapshot/docker-compose.yml index 88cbbb300..b084ec3ed 100644 --- a/tests/snapshot/docker-compose.yml +++ b/tests/snapshot/docker-compose.yml @@ -1,23 +1,8 @@ version: '3' services: - opensearch-node1: + opensearch-cluster: image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF} - container_name: opensearch-node1 - environment: - - 'OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!}' - - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m - - bootstrap.memory_lock=true - - cluster.initial_master_nodes=opensearch-node1,opensearch-node2 - - cluster.name=opensearch-cluster - - discovery.seed_hosts=opensearch-node1,opensearch-node2 - - node.name=opensearch-node1 - - path.repo=/tmp/opensearch/repo - - plugins.index_state_management.job_interval=1 - ulimits: - memlock: - soft: -1 - hard: -1 ports: - 9200:9200 - 9600:9600 @@ -25,4 +10,4 @@ services: - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!} - OPENSEARCH_JAVA_OPTS=${OPENSEARCH_JAVA_OPTS} - discovery.type=single-node - - path.repo=/tmp/opensearch/repo + - path.repo=/tmp/opensearch/repo \ No newline at end of file From cf167fda2c2e55ec02fdccdd1021d3af920c7590 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sat, 23 Nov 2024 13:38:12 +0500 Subject: [PATCH 12/17] fixing lint Signed-off-by: Tokesh --- tests/default/indices/mapping.yaml | 4 ++-- tests/default/indices/msearch.yaml | 32 +++++++++++++++--------------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/tests/default/indices/mapping.yaml b/tests/default/indices/mapping.yaml index 928f919f1..f22dc2d4c 100644 --- a/tests/default/indices/mapping.yaml +++ b/tests/default/indices/mapping.yaml @@ -174,12 +174,12 @@ chapters: movies: mappings: year: - full_name: "year" + full_name: year mapping: year: type: integer director: - full_name: "director" + full_name: director mapping: director: type: text diff --git a/tests/default/indices/msearch.yaml b/tests/default/indices/msearch.yaml index 7f1dc03db..33170668c 100644 --- a/tests/default/indices/msearch.yaml +++ b/tests/default/indices/msearch.yaml @@ -42,7 +42,7 @@ chapters: id: '1' request: payload: - name: "Book 1" + name: Book 1 age: 10 response: status: 201 @@ -55,7 +55,7 @@ chapters: id: '2' request: payload: - name: "Book 2" + name: Book 2 age: 20 response: status: 201 @@ -68,7 +68,7 @@ chapters: id: '3' request: payload: - name: "Book 3" + name: Book 3 age: 30 response: status: 201 @@ -85,20 +85,20 @@ chapters: status: 200 payload: docs: - - _index: "books" - _id: "1" + - _index: books + _id: '1' _source: - name: "Book 1" + name: Book 1 age: 10 - - _index: "books" - _id: "2" + - _index: books + _id: '2' _source: - name: "Book 2" + name: Book 2 age: 20 - - _index: "books" - _id: "3" + - _index: books + _id: '3' _source: - name: "Book 3" + name: Book 3 age: 30 - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call. @@ -109,10 +109,10 @@ chapters: request: content_type: application/x-ndjson payload: - - { index: "books" } - - { "query": { "match": { "name": "Book 1" } } } - - { index: "books" } - - { "query": { "match": { "name": "Book 2" } } } + - {index: books} + - {query: {match: {name: Book 1}}} + - {index: books} + - {query: {match: {name: Book 2}}} response: status: 200 - synopsis: Delete the `books` and `games` indices. From 93a58c98915bf79008c38347b1ae7e81de289b23 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 24 Nov 2024 04:36:33 +0500 Subject: [PATCH 13/17] fixing paths, deleting not necessary code, adding validate query api specs Signed-off-by: Tokesh --- tests/default/indices/mapping.yaml | 185 ---------------------- tests/default/indices/mapping/field.yaml | 61 +++++++ tests/default/indices/mapping/index.yaml | 148 +++++++++++++++++ tests/default/indices/msearch.yaml | 120 ++------------ tests/default/indices/refresh.yaml | 24 --- tests/default/indices/validate_query.yaml | 49 ++++++ 6 files changed, 274 insertions(+), 313 deletions(-) create mode 100644 tests/default/indices/mapping/field.yaml create mode 100644 tests/default/indices/mapping/index.yaml create mode 100644 tests/default/indices/validate_query.yaml diff --git a/tests/default/indices/mapping.yaml b/tests/default/indices/mapping.yaml index f22dc2d4c..e69de29bb 100644 --- a/tests/default/indices/mapping.yaml +++ b/tests/default/indices/mapping.yaml @@ -1,185 +0,0 @@ -$schema: ../../../json_schemas/test_story.schema.yaml - -description: Test mappings endpoints. -prologues: - - path: /{index} - method: PUT - parameters: - index: games - - path: /{index} - method: PUT - parameters: - index: movies - request: - payload: - mappings: - properties: - director: - type: text - year: - type: integer - location: - type: ip - ignore_malformed: true -epilogues: - - path: /movies,games - method: DELETE - status: [200, 404] -chapters: - - synopsis: Get mappings for an index. - path: /{index}/_mapping - method: GET - parameters: - index: movies - response: - status: 200 - payload: - movies: - mappings: - properties: - director: - type: text - year: - type: integer - - synopsis: Get mappings for multiple indexes. - path: /{index}/_mapping - method: GET - parameters: - index: movies,games - response: - status: 200 - payload: - movies: - mappings: - properties: - director: - type: text - year: - type: integer - games: - mappings: {} - - synopsis: Update mapping for an index. - path: /{index}/_mapping - method: PUT - parameters: - index: movies - allow_no_indices: true - expand_wildcards: all - ignore_unavailable: true - timeout: 10s - write_index_only: true - request: - payload: - dynamic: 'true' - properties: - producer: - type: text - response: - status: 200 - payload: - acknowledged: true - - synopsis: Update mapping for an index (cluster_manager_timeout). - path: /{index}/_mapping - method: PUT - version: '>= 2.0' - parameters: - index: movies - cluster_manager_timeout: 1s - request: - payload: - properties: - producer: - type: text - response: - status: 200 - payload: - acknowledged: true - - synopsis: Update mapping for an index with setting dynamic to false. - path: /{index}/_mapping - method: PUT - parameters: - index: movies - allow_no_indices: true - expand_wildcards: all - ignore_unavailable: true - timeout: 10s - write_index_only: true - request: - payload: - dynamic: 'false' - response: - status: 200 - payload: - acknowledged: true - - synopsis: Update mapping for an index with setting dynamic to strict. - path: /{index}/_mapping - method: PUT - parameters: - index: movies - allow_no_indices: true - expand_wildcards: all - ignore_unavailable: true - timeout: 10s - write_index_only: true - request: - payload: - dynamic: strict - response: - status: 200 - payload: - acknowledged: true - - synopsis: Update mapping for an index with setting dynamic to strict_allow_templates. - version: '>= 2.16' - path: /{index}/_mapping - method: PUT - parameters: - index: movies - allow_no_indices: true - expand_wildcards: all - ignore_unavailable: true - timeout: 10s - write_index_only: true - request: - payload: - dynamic: strict_allow_templates - response: - status: 200 - payload: - acknowledged: true - - synopsis: Add new fields to index mapping. - path: /{index}/_mapping - method: POST - parameters: - index: movies - request: - payload: - properties: - genre: - type: text - rating: - type: float - response: - status: 200 - payload: - acknowledged: true - - synopsis: Get specific field mappings for an index. - path: /{index}/_mapping/field/{fields} - method: GET - parameters: - index: movies - fields: director,year - response: - status: 200 - payload: - movies: - mappings: - year: - full_name: year - mapping: - year: - type: integer - director: - full_name: director - mapping: - director: - type: text diff --git a/tests/default/indices/mapping/field.yaml b/tests/default/indices/mapping/field.yaml new file mode 100644 index 000000000..5037e2ec3 --- /dev/null +++ b/tests/default/indices/mapping/field.yaml @@ -0,0 +1,61 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test specific field mappings endpoints. +prologues: + - path: /{index} + method: PUT + parameters: + index: movies + request: + payload: + mappings: + properties: + director: + type: text + year: + type: integer + location: + type: ip + ignore_malformed: true +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +chapters: + - synopsis: Add new fields to index mapping. + path: /{index}/_mapping + method: POST + parameters: + index: movies + request: + payload: + properties: + genre: + type: text + rating: + type: float + response: + status: 200 + payload: + acknowledged: true + - synopsis: Get specific field mappings for an index. + path: /{index}/_mapping/field/{fields} + method: GET + parameters: + index: movies + fields: director,year + response: + status: 200 + payload: + movies: + mappings: + year: + full_name: year + mapping: + year: + type: integer + director: + full_name: director + mapping: + director: + type: text diff --git a/tests/default/indices/mapping/index.yaml b/tests/default/indices/mapping/index.yaml new file mode 100644 index 000000000..35a74eeea --- /dev/null +++ b/tests/default/indices/mapping/index.yaml @@ -0,0 +1,148 @@ +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test mappings endpoints. +prologues: + - path: /{index} + method: PUT + parameters: + index: games + - path: /{index} + method: PUT + parameters: + index: movies + request: + payload: + mappings: + properties: + director: + type: text + year: + type: integer + location: + type: ip + ignore_malformed: true +epilogues: + - path: /movies,games + method: DELETE + status: [200, 404] +chapters: + - synopsis: Get mappings for an index. + path: /{index}/_mapping + method: GET + parameters: + index: movies + response: + status: 200 + payload: + movies: + mappings: + properties: + director: + type: text + year: + type: integer + - synopsis: Get mappings for multiple indexes. + path: /{index}/_mapping + method: GET + parameters: + index: movies,games + response: + status: 200 + payload: + movies: + mappings: + properties: + director: + type: text + year: + type: integer + games: + mappings: {} + - synopsis: Update mapping for an index. + path: /{index}/_mapping + method: PUT + parameters: + index: movies + allow_no_indices: true + expand_wildcards: all + ignore_unavailable: true + timeout: 10s + write_index_only: true + request: + payload: + dynamic: 'true' + properties: + producer: + type: text + response: + status: 200 + payload: + acknowledged: true + - synopsis: Update mapping for an index (cluster_manager_timeout). + path: /{index}/_mapping + method: PUT + version: '>= 2.0' + parameters: + index: movies + cluster_manager_timeout: 1s + request: + payload: + properties: + producer: + type: text + response: + status: 200 + payload: + acknowledged: true + - synopsis: Update mapping for an index with setting dynamic to false. + path: /{index}/_mapping + method: PUT + parameters: + index: movies + allow_no_indices: true + expand_wildcards: all + ignore_unavailable: true + timeout: 10s + write_index_only: true + request: + payload: + dynamic: 'false' + response: + status: 200 + payload: + acknowledged: true + - synopsis: Update mapping for an index with setting dynamic to strict. + path: /{index}/_mapping + method: PUT + parameters: + index: movies + allow_no_indices: true + expand_wildcards: all + ignore_unavailable: true + timeout: 10s + write_index_only: true + request: + payload: + dynamic: strict + response: + status: 200 + payload: + acknowledged: true + - synopsis: Update mapping for an index with setting dynamic to strict_allow_templates. + version: '>= 2.16' + path: /{index}/_mapping + method: PUT + parameters: + index: movies + allow_no_indices: true + expand_wildcards: all + ignore_unavailable: true + timeout: 10s + write_index_only: true + request: + payload: + dynamic: strict_allow_templates + response: + status: 200 + payload: + acknowledged: true \ No newline at end of file diff --git a/tests/default/indices/msearch.yaml b/tests/default/indices/msearch.yaml index 33170668c..9d97fc6aa 100644 --- a/tests/default/indices/msearch.yaml +++ b/tests/default/indices/msearch.yaml @@ -1,106 +1,25 @@ $schema: ../../../json_schemas/test_story.schema.yaml description: Test endpoints relevant to the lifecycle of an index, including multi-get and multi-search operations. +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: books, _id: book1}} + - {author: Harper Lee, title: To Kill a Mockingbird, year: 60} + - {create: {_index: movies, _id: movie1}} + - {director: Bennett Miller, title: The Cruise, year: 1998} + - {create: {_index: movies, _id: movie2}} + - {director: Nicolas Winding Refn, title: Drive, year: 1960} epilogues: - path: /books method: DELETE status: [200, 404] - - path: /games - method: DELETE - status: [200, 404] chapters: - - synopsis: Create an index named `books` with mappings and settings. - path: /{index} - method: PUT - parameters: - index: books - request: - payload: - mappings: - properties: - name: - type: keyword - age: - type: integer - settings: - number_of_shards: 5 - number_of_replicas: 2 - response: - status: 200 - - - synopsis: Create an index named `games` with default settings. - path: /{index} - method: PUT - parameters: - index: games - - - synopsis: Add documents to the `books` index. - path: /{index}/_doc/{id} - method: POST - parameters: - index: books - id: '1' - request: - payload: - name: Book 1 - age: 10 - response: - status: 201 - - - synopsis: Add more documents to the `books` index. - path: /{index}/_doc/{id} - method: POST - parameters: - index: books - id: '2' - request: - payload: - name: Book 2 - age: 20 - response: - status: 201 - - - synopsis: Add another document to the `books` index. - path: /{index}/_doc/{id} - method: POST - parameters: - index: books - id: '3' - request: - payload: - name: Book 3 - age: 30 - response: - status: 201 - - - synopsis: Perform a `_mget` request to retrieve documents by IDs. - path: /{index}/_mget - method: POST - parameters: - index: books - request: - payload: - ids: ['1', '2', '3'] - response: - status: 200 - payload: - docs: - - _index: books - _id: '1' - _source: - name: Book 1 - age: 10 - - _index: books - _id: '2' - _source: - name: Book 2 - age: 20 - - _index: books - _id: '3' - _source: - name: Book 3 - age: 30 - - synopsis: Perform a `_msearch` request to execute multiple search queries in a single call. path: /{index}/_msearch method: POST @@ -110,15 +29,8 @@ chapters: content_type: application/x-ndjson payload: - {index: books} - - {query: {match: {name: Book 1}}} + - {query: {match: {title: To Kill a Mockingbird}}} - {index: books} - - {query: {match: {name: Book 2}}} - response: - status: 200 - - synopsis: Delete the `books` and `games` indices. - path: /{index} - method: DELETE - parameters: - index: books,games + - {query: {match: {title: The Cruise}}} response: status: 200 \ No newline at end of file diff --git a/tests/default/indices/refresh.yaml b/tests/default/indices/refresh.yaml index 9fb1e7598..55b171e23 100644 --- a/tests/default/indices/refresh.yaml +++ b/tests/default/indices/refresh.yaml @@ -27,30 +27,6 @@ chapters: - synopsis: Refresh an index (POST). path: /{index}/_refresh method: POST - parameters: - index: movies - ignore_unavailable: true - allow_no_indices: false - expand_wildcards: all - response: - status: 200 - payload: - _shards: - failed: 0 - - synopsis: Adding one more document. - path: /{index}/_doc - method: POST - parameters: - index: movies - request: - payload: - title: Margin call - year: 2011 - response: - status: 201 - - synopsis: Refresh an index. - path: /{index}/_refresh - method: GET parameters: index: movies ignore_unavailable: true diff --git a/tests/default/indices/validate_query.yaml b/tests/default/indices/validate_query.yaml new file mode 100644 index 000000000..a75ca2e97 --- /dev/null +++ b/tests/default/indices/validate_query.yaml @@ -0,0 +1,49 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test validating queries for a specific index using both GET and POST methods. +epilogues: + - path: /movies + method: DELETE + status: [200, 404] +prologues: + - path: /_bulk + method: POST + parameters: + refresh: true + request: + content_type: application/x-ndjson + payload: + - {create: {_index: movies, _id: movie1}} + - {director: Bennett Miller, title: The Cruise, year: 1998} + - {create: {_index: movies, _id: movie2}} + - {director: Nicolas Winding Refn, title: Drive, year: 1960} +chapters: + - synopsis: Validate a match query (GET). + path: /{index}/_validate/query + method: GET + parameters: + index: movies + request: + payload: + query: + match: + year: 1998 + response: + status: 200 + payload: + valid: true + + - synopsis: Validate a match query (POST). + path: /{index}/_validate/query + method: POST + parameters: + index: movies + request: + payload: + query: + match: + title: Drive + response: + status: 200 + payload: + valid: true \ No newline at end of file From 7e5570b72ac46a0e28180fb9daccd3920d63df89 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 24 Nov 2024 04:40:09 +0500 Subject: [PATCH 14/17] deleting empty file Signed-off-by: Tokesh --- tests/default/indices/mapping.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 tests/default/indices/mapping.yaml diff --git a/tests/default/indices/mapping.yaml b/tests/default/indices/mapping.yaml deleted file mode 100644 index e69de29bb..000000000 From 1514af505ff2474f210de007bd4b789ff56e8a2c Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 24 Nov 2024 04:49:39 +0500 Subject: [PATCH 15/17] fixing minor bug in scenario Signed-off-by: Tokesh --- tests/default/indices/msearch.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/default/indices/msearch.yaml b/tests/default/indices/msearch.yaml index 9d97fc6aa..ba5cd97eb 100644 --- a/tests/default/indices/msearch.yaml +++ b/tests/default/indices/msearch.yaml @@ -11,9 +11,9 @@ prologues: payload: - {create: {_index: books, _id: book1}} - {author: Harper Lee, title: To Kill a Mockingbird, year: 60} - - {create: {_index: movies, _id: movie1}} + - {create: {_index: books, _id: book2}} - {director: Bennett Miller, title: The Cruise, year: 1998} - - {create: {_index: movies, _id: movie2}} + - {create: {_index: books, _id: book3}} - {director: Nicolas Winding Refn, title: Drive, year: 1960} epilogues: - path: /books From 37b40b116b72b22ac95c647c11915ce84d09eba7 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 24 Nov 2024 15:39:26 +0500 Subject: [PATCH 16/17] adding special folder for validation tests in indices Signed-off-by: Tokesh --- .../default/indices/{validate_query.yaml => validate/query.yaml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename tests/default/indices/{validate_query.yaml => validate/query.yaml} (100%) diff --git a/tests/default/indices/validate_query.yaml b/tests/default/indices/validate/query.yaml similarity index 100% rename from tests/default/indices/validate_query.yaml rename to tests/default/indices/validate/query.yaml From d925d04e2cf1abfba8137b96c5c4b95dd566ca30 Mon Sep 17 00:00:00 2001 From: Tokesh Date: Sun, 24 Nov 2024 15:41:49 +0500 Subject: [PATCH 17/17] fixing path to test story schema Signed-off-by: Tokesh --- tests/default/indices/validate/query.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/default/indices/validate/query.yaml b/tests/default/indices/validate/query.yaml index a75ca2e97..264579058 100644 --- a/tests/default/indices/validate/query.yaml +++ b/tests/default/indices/validate/query.yaml @@ -1,4 +1,4 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$schema: ../../../../json_schemas/test_story.schema.yaml description: Test validating queries for a specific index using both GET and POST methods. epilogues: