Skip to content

Commit

Permalink
adding tests for replication namespace
Browse files Browse the repository at this point in the history
Signed-off-by: Tokesh <[email protected]>
  • Loading branch information
Tokesh committed Aug 3, 2024
1 parent 6fd6292 commit addcd76
Show file tree
Hide file tree
Showing 4 changed files with 208 additions and 44 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
65 changes: 63 additions & 2 deletions spec/namespaces/replication.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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'
Expand Down Expand Up @@ -100,14 +110,16 @@ 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
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/update_settings::path.index'
requestBody:
$ref: '#/components/requestBodies/replication.update_settings'
responses:
Expand Down Expand Up @@ -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:
Expand All @@ -150,7 +211,7 @@ components:
content:
application/json:
schema:
type: Object
type: object
required: true
replication.pause:
content:
Expand Down
39 changes: 26 additions & 13 deletions spec/schemas/replication._common.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
147 changes: 118 additions & 29 deletions tests/replication/replica.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: '*'
leader_alias: "my-connection-alias"
name: "books"
response:
status: 200

0 comments on commit addcd76

Please sign in to comment.