From 4771bfd2884bc5705d66c3ca35554244e2aa1ce6 Mon Sep 17 00:00:00 2001 From: Niyazbek Torekeldi <78027392+Tokesh@users.noreply.github.com> Date: Mon, 18 Nov 2024 18:54:38 +0500 Subject: [PATCH] Replication namespace (#464) --- .cspell | 4 + .github/workflows/test-spec.yml | 4 + .lycheeignore | 1 + CHANGELOG.md | 1 + spec/namespaces/replication.yaml | 301 +++++++++++++++++++ spec/schemas/replication._common.yaml | 230 ++++++++++++++ tests/plugins/replication/autofollow.yaml | 88 ++++++ tests/plugins/replication/docker-compose.yml | 62 ++++ tests/plugins/replication/index.yaml | 74 +++++ tests/plugins/replication/stats.yaml | 84 ++++++ 10 files changed, 849 insertions(+) create mode 100644 spec/namespaces/replication.yaml create mode 100644 spec/schemas/replication._common.yaml create mode 100644 tests/plugins/replication/autofollow.yaml create mode 100644 tests/plugins/replication/docker-compose.yml create mode 100644 tests/plugins/replication/index.yaml create mode 100644 tests/plugins/replication/stats.yaml diff --git a/.cspell b/.cspell index eb1d955ba..bf297ec39 100644 --- a/.cspell +++ b/.cspell @@ -10,6 +10,7 @@ authc authinfo authtoken autocut +autofollow backendroles backpressure beider @@ -74,6 +75,7 @@ ignorecase integ internalusers Intertransport +ipam Jelinek kibanainfo kibanaserver @@ -90,6 +92,7 @@ lucene Lucene lycheeverse marvinpinto +memlock metaphone mget millis @@ -206,6 +209,7 @@ Translog trbl truststore tubone +ulimits Undeploys unigrams Unmanaged diff --git a/.github/workflows/test-spec.yml b/.github/workflows/test-spec.yml index a6c1e78ec..8bc1abeea 100644 --- a/.github/workflows/test-spec.yml +++ b/.github/workflows/test-spec.yml @@ -36,6 +36,9 @@ jobs: tests: routing - version: 2.18.0 tests: snapshot + - version: 2.18.0 + tests: plugins/replication + url: http://localhost:9200 - version: 2.18.0 tests: plugins/streaming - version: 2.18.0 @@ -89,6 +92,7 @@ jobs: --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'}} \ --tests=tests/${{ matrix.entry.tests || 'default' }} - name: Get Container Logs diff --git a/.lycheeignore b/.lycheeignore index caa2546d0..1b6a61169 100644 --- a/.lycheeignore +++ b/.lycheeignore @@ -1,2 +1,3 @@ https://localhost:* +http://localhost:* http://webhook:8080 diff --git a/CHANGELOG.md b/CHANGELOG.md index 045729721..5854a451c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -96,6 +96,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added support for request headers in tests [#461](https://github.com/opensearch-project/opensearch-api-specification/pull/461) - Added metadata additionalProperties to `ErrorCause` ([#462](https://github.com/opensearch-project/opensearch-api-specification/pull/462)) - Added `creation_date` field to `DanglingIndex` ([#462](https://github.com/opensearch-project/opensearch-api-specification/pull/462)) +- Added `replication` namespace API specifications ([#464](https://github.com/opensearch-project/opensearch-api-specification/pull/464)) - Added doc on `cluster create-index blocked` workaround ([#465](https://github.com/opensearch-project/opensearch-api-specification/pull/465)) - Added `observability` namespace API specifications ([#474](https://github.com/opensearch-project/opensearch-api-specification/pull/474)) - Added support for reusing output variables as keys in payload expectations ([#471](https://github.com/opensearch-project/opensearch-api-specification/pull/471)) diff --git a/spec/namespaces/replication.yaml b/spec/namespaces/replication.yaml new file mode 100644 index 000000000..db8e0c7b8 --- /dev/null +++ b/spec/namespaces/replication.yaml @@ -0,0 +1,301 @@ +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 + parameters: + - $ref: '#/components/parameters/replication.start::path.index' + 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 + parameters: + - $ref: '#/components/parameters/replication.stop::path.index' + 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 + parameters: + - $ref: '#/components/parameters/replication.pause::path.index' + 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 + parameters: + - $ref: '#/components/parameters/replication.resume::path.index' + 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 + parameters: + - $ref: '#/components/parameters/replication.status::path.index' + 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/{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 + parameters: + - $ref: '#/components/parameters/replication.update_settings::path.index' + requestBody: + $ref: '#/components/requestBodies/replication.update_settings' + responses: + '200': + $ref: '#/components/responses/replication.update_settings@200' + /_plugins/_replication/_autofollow: + post: + 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: + 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: + parameters: + replication.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 + replication.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 + replication.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 + replication.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 + replication.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 + replication.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: + 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: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' + replication.stop@200: + content: + application/json: + schema: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' + replication.pause@200: + content: + application/json: + schema: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' + replication.resume@200: + content: + application/json: + schema: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' + 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: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' + replication.create_replication_rule@200: + content: + application/json: + schema: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' + replication.delete_replication_rule@200: + content: + application/json: + schema: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' \ 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..e2b965b0e --- /dev/null +++ b/spec/schemas/replication._common.yaml @@ -0,0 +1,230 @@ +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: + $ref: '_common.yaml#/components/schemas/IndexAlias' + leader_index: + $ref: '_common.yaml#/components/schemas/IndexName' + 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 + enum: + - BOOTSTRAPPING + - PAUSED + - REPLICATION NOT IN PROGRESS + - RUNNING + - SYNCING + reason: + type: string + leader_alias: + $ref: '_common.yaml#/components/schemas/IndexAlias' + leader_index: + $ref: '_common.yaml#/components/schemas/IndexName' + follower_index: + $ref: '_common.yaml#/components/schemas/IndexName' + syncing_details: + $ref: '#/components/schemas/SyncingDetails' + SyncingDetails: + type: object + properties: + leader_checkpoint: + type: integer + follower_checkpoint: + type: integer + seq_no: + $ref: '_common.yaml#/components/schemas/SequenceNumber' + LeaderStatus: + type: object + properties: + num_replicated_indices: + type: number + operations_read: + type: number + translog_size_bytes: + $ref: '_common.yaml#/components/schemas/ByteCount' + operations_read_lucene: + type: number + operations_read_translog: + type: number + total_read_time_lucene_millis: + $ref: '_common.yaml#/components/schemas/StringifiedEpochTimeUnitMillis' + total_read_time_translog_millis: + $ref: '_common.yaml#/components/schemas/StringifiedEpochTimeUnitMillis' + bytes_read: + $ref: '_common.yaml#/components/schemas/ByteCount' + index_stats: + type: object + additionalProperties: + $ref: '#/components/schemas/IndexStatus' + IndexStatus: + type: object + properties: + operations_read: + type: number + translog_size_bytes: + $ref: '_common.yaml#/components/schemas/ByteCount' + operations_read_lucene: + type: number + operations_read_translog: + type: number + total_read_time_lucene_millis: + $ref: '_common.yaml#/components/schemas/StringifiedEpochTimeUnitMillis' + total_read_time_translog_millis: + $ref: '_common.yaml#/components/schemas/StringifiedEpochTimeUnitMillis' + bytes_read: + $ref: '_common.yaml#/components/schemas/ByteCount' + 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: + $ref: '_common.yaml#/components/schemas/StringifiedEpochTimeUnitMillis' + index_stats: + type: object + additionalProperties: + $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: + $ref: '_common.yaml#/components/schemas/StringifiedEpochTimeUnitMillis' + 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 + last_execution_time: + type: number + SettingsBody: + type: object + properties: + index: + $ref: '#/components/schemas/IndexSchema' + UpdateSettings: + type: object + properties: + settings: + allOf: + - type: object + properties: + index.number_of_shards: + type: integer + 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: + leader_alias: + $ref: '_common.yaml#/components/schemas/IndexAlias' + name: + type: string + pattern: + type: string + use_roles: + $ref: '#/components/schemas/UseRoles' + DeleteReplicationRule: + type: object + properties: + leader_alias: + $ref: '_common.yaml#/components/schemas/IndexAlias' + name: + type: string \ No newline at end of file diff --git a/tests/plugins/replication/autofollow.yaml b/tests/plugins/replication/autofollow.yaml new file mode 100644 index 000000000..89eabce30 --- /dev/null +++ b/tests/plugins/replication/autofollow.yaml @@ -0,0 +1,88 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test replication APIs specs. +prologues: + - path: /{index} + method: PUT + parameters: + index: books + request: + payload: {} + - path: /_bulk + method: POST + request: + 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: /_cluster/settings + method: PUT + request: + payload: + persistent: + cluster: + remote: + leader-cluster: + seeds: ['172.22.0.3:9300'] + - path: /_plugins/_replication/{index}/_start + version: '>= 1.1' + method: PUT + parameters: + index: books-names + request: + payload: + leader_alias: leader-cluster + leader_index: books + use_roles: + leader_cluster_role: all_access + follower_cluster_role: all_access +epilogues: + - path: /_plugins/_replication/{index}/_stop + method: POST + parameters: + index: books-names + request: + payload: {} + - path: /books-names + method: DELETE + status: [200, 404] + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Create replication rule. + path: /_plugins/_replication/_autofollow + version: '>= 1.1' + method: POST + request: + payload: + leader_alias: leader-cluster + name: books + pattern: 'books-*' + use_roles: + leader_cluster_role: leader_role + follower_cluster_role: admin + response: + status: 200 + - synopsis: Get auto-follow stats. + path: /_plugins/_replication/autofollow_stats + version: '>= 1.1' + method: GET + response: + status: 200 + - synopsis: Delete replication rule. + path: /_plugins/_replication/_autofollow + version: '>= 1.1' + method: DELETE + request: + payload: + leader_alias: leader-cluster + name: books + response: + status: 200 \ No newline at end of file diff --git a/tests/plugins/replication/docker-compose.yml b/tests/plugins/replication/docker-compose.yml new file mode 100644 index 000000000..041be3f9d --- /dev/null +++ b/tests/plugins/replication/docker-compose.yml @@ -0,0 +1,62 @@ +version: '3' + +services: + opensearch-leader-node1: + image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF} + environment: + - DISABLE_INSTALL_DEMO_CONFIG=true + - DISABLE_SECURITY_PLUGIN=true + - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!} + - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m + - bootstrap.memory_lock=true + - cluster.initial_master_nodes=opensearch-leader-node1 + - cluster.name=leader-cluster + - discovery.seed_hosts=opensearch-leader-node1 + - network.host=0.0.0.0 + - node.name=opensearch-leader-node1 + - path.repo=/tmp/opensearch/repo + - plugins.index_state_management.job_interval=1 + ulimits: + memlock: + soft: -1 + hard: -1 + ports: + - '9200:9200' + - '9600:9600' + networks: + opensearch-net: + ipv4_address: 172.22.0.3 + + opensearch-follower-node1: + image: ${OPENSEARCH_DOCKER_HUB_PROJECT:-opensearchproject}/opensearch:${OPENSEARCH_VERSION:-latest}${OPENSEARCH_DOCKER_REF} + environment: + - DISABLE_INSTALL_DEMO_CONFIG=true + - DISABLE_SECURITY_PLUGIN=true + - OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD:-myStrongPassword123!} + - OPENSEARCH_JAVA_OPTS=-Xms512m -Xmx512m + - bootstrap.memory_lock=true + - cluster.initial_master_nodes=opensearch-follower-node1 + - cluster.name=follower-cluster + - cluster.remote.leader-cluster.seeds=172.22.0.3:9300 + - discovery.seed_hosts=opensearch-follower-node1 + - network.host=0.0.0.0 + - node.name=opensearch-follower-node1 + - path.repo=/tmp/opensearch/repo + - plugins.index_state_management.job_interval=1 + ulimits: + memlock: + soft: -1 + hard: -1 + ports: + - '9201:9200' + - '9601:9600' + networks: + opensearch-net: + ipv4_address: 172.22.0.4 + +networks: + opensearch-net: + driver: bridge + ipam: + config: + - subnet: 172.22.0.0/24 diff --git a/tests/plugins/replication/index.yaml b/tests/plugins/replication/index.yaml new file mode 100644 index 000000000..a70a0b991 --- /dev/null +++ b/tests/plugins/replication/index.yaml @@ -0,0 +1,74 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test replication APIs specs. +prologues: + - path: /{index} + method: PUT + parameters: + index: books + request: + payload: {} + - path: /_bulk + method: POST + request: + 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: /_cluster/settings + method: PUT + request: + payload: + persistent: + cluster: + remote: + leader-cluster: + seeds: ['172.22.0.3:9300'] +epilogues: + - path: /_plugins/_replication/{index}/_stop + method: POST + parameters: + index: books-names + request: + payload: {} + - path: /books-names + method: DELETE + status: [200, 404] + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Start replication. + path: /_plugins/_replication/{index}/_start + version: '>= 1.1' + method: PUT + parameters: + index: books-names + request: + payload: + leader_alias: leader-cluster + leader_index: books + use_roles: + leader_cluster_role: all_access + follower_cluster_role: all_access + response: + status: 200 + - synopsis: Update settings. + path: /_plugins/_replication/{index}/_update + version: '>= 1.1' + method: PUT + parameters: + index: books-names + request: + payload: + settings: + index.number_of_shards: 4 + index.number_of_replicas: 2 + response: + status: 200 \ No newline at end of file diff --git a/tests/plugins/replication/stats.yaml b/tests/plugins/replication/stats.yaml new file mode 100644 index 000000000..6584200ed --- /dev/null +++ b/tests/plugins/replication/stats.yaml @@ -0,0 +1,84 @@ +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test replication APIs specs. +prologues: + - path: /{index} + method: PUT + parameters: + index: books + request: + payload: {} + - path: /_bulk + method: POST + request: + 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: /_cluster/settings + method: PUT + request: + payload: + persistent: + cluster: + remote: + leader-cluster: + seeds: ['172.22.0.3:9300'] + - path: /_plugins/_replication/{index}/_start + version: '>= 1.1' + method: PUT + parameters: + index: books-names + request: + payload: + leader_alias: leader-cluster + leader_index: books + use_roles: + leader_cluster_role: all_access + follower_cluster_role: all_access +epilogues: + - path: /_plugins/_replication/{index}/_stop + method: POST + parameters: + index: books-names + request: + payload: {} + - path: /books-names + method: DELETE + status: [200, 404] + - path: /books + method: DELETE + status: [200, 404] +chapters: + - 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 \ No newline at end of file