Skip to content

Commit

Permalink
Added tests for pause and resume, support for retry in prologues/epil…
Browse files Browse the repository at this point in the history
…ogues.

Signed-off-by: dblock <dblock@amazon.com>
  • Loading branch information
dblock committed Dec 9, 2024
1 parent f07fea9 commit 3debf75
Show file tree
Hide file tree
Showing 16 changed files with 583 additions and 121 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added missing `status` to `/_search/template` response ([#702](https://github.com/opensearch-project/opensearch-api-specification/pull/702))
- Added `_type` to `rank_eval` API specs ([#704](https://github.com/opensearch-project/opensearch-api-specification/pull/704))
- Added request body to `_search_shards` API specs ([#709](https://github.com/opensearch-project/opensearch-api-specification/pull/709))
- Added `retry` support in `prologues` and `epilogues` ([#711](https://github.com/opensearch-project/opensearch-api-specification/pull/711))

### Removed
- Removed unsupported `_common.mapping:SourceField`'s `mode` field and associated `_common.mapping:SourceFieldMode` enum ([#652](https://github.com/opensearch-project/opensearch-api-specification/pull/652))
Expand Down
18 changes: 4 additions & 14 deletions tests/plugins/replication/autofollow.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test replication APIs specs.
description: Test replication APIs.
version: '>= 1.1'
prologues:
- path: /{index}
method: PUT
Expand All @@ -10,17 +11,15 @@ prologues:
payload: {}
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: movies, _id: movie_1392214}}
- {director: Bennett Miller, title: Moneyball, year: 2011}
- {create: {_index: movies, _id: movie_1392215}}
- {director: Badge Dale, title: The Secret Soldiers, year: 2016}
- path: /{index}/_refresh
method: POST
parameters:
index: movies
- path: /_cluster/settings
method: PUT
request:
Expand All @@ -31,7 +30,6 @@ prologues:
leader-cluster:
seeds: ['172.22.0.3:9300']
- path: /_plugins/_replication/{index}/_start
version: '>= 1.1'
method: PUT
parameters:
index: movies-names
Expand All @@ -58,7 +56,6 @@ epilogues:
chapters:
- synopsis: Create replication rule.
path: /_plugins/_replication/_autofollow
version: '>= 1.1'
method: POST
request:
payload:
Expand All @@ -70,15 +67,8 @@ chapters:
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:
Expand Down
78 changes: 78 additions & 0 deletions tests/plugins/replication/autofollow_stats.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test replication APIs specs.
version: '>= 1.1'
prologues:
- path: /{index}
method: PUT
parameters:
index: movies
request:
payload: {}
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: movies, _id: movie_1392214}}
- {director: Bennett Miller, title: Moneyball, year: 2011}
- {create: {_index: movies, _id: movie_1392215}}
- {director: Badge Dale, title: The Secret Soldiers, year: 2016}
- path: /_cluster/settings
method: PUT
request:
payload:
persistent:
cluster:
remote:
leader-cluster:
seeds: ['172.22.0.3:9300']
- path: /_plugins/_replication/{index}/_start
method: PUT
parameters:
index: movies-names
request:
payload:
leader_alias: leader-cluster
leader_index: movies
use_roles:
leader_cluster_role: all_access
follower_cluster_role: all_access
- path: /_plugins/_replication/_autofollow
method: POST
request:
payload:
leader_alias: leader-cluster
name: movies
pattern: 'movies-*'
use_roles:
leader_cluster_role: leader_role
follower_cluster_role: admin
epilogues:
- path: /_plugins/_replication/_autofollow
method: DELETE
request:
payload:
leader_alias: leader-cluster
name: movies
status: [200, 404]
- path: /_plugins/_replication/{index}/_stop
method: POST
parameters:
index: movies-names
request:
payload: {}
- path: /movies-names
method: DELETE
status: [200, 404]
- path: /movies
method: DELETE
status: [200, 404]
chapters:
- synopsis: Get auto-follow stats.
path: /_plugins/_replication/autofollow_stats
method: GET
response:
status: 200
63 changes: 63 additions & 0 deletions tests/plugins/replication/pause.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test pausing a replication.
version: '>= 1.1'
warnings:
multiple-paths-detected: false
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: music, _id: music_1392214}}
- {author: Selena Gomez, title: Love you like a love song, year: 2011}
- {create: {_index: music, _id: music_1392215}}
- {author: Justin Bieber, title: Baby, year: 2010}
- path: /_cluster/settings
method: PUT
request:
payload:
persistent:
cluster:
remote:
leader-cluster:
seeds: ['172.22.0.3:9300']
- path: /_plugins/_replication/{index}/_start
method: PUT
parameters:
index: music-names
request:
payload:
leader_alias: leader-cluster
leader_index: music
use_roles:
leader_cluster_role: all_access
follower_cluster_role: all_access
epilogues:
- path: /_plugins/_replication/{index}/_stop
method: POST
parameters:
index: music-names
request:
payload: {}
- path: /music-names
method: DELETE
status: [200, 404]
- path: /music
method: DELETE
status: [200, 404]
chapters:
- synopsis: Pause replication.
path: /_plugins/_replication/{index}/_pause
method: POST
retry:
count: 3
parameters:
index: music-names
request:
payload: {}
response:
status: 200
69 changes: 69 additions & 0 deletions tests/plugins/replication/resume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test pausing a replication.
version: '>= 1.1'
warnings:
multiple-paths-detected: false
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
request:
content_type: application/x-ndjson
payload:
- {create: {_index: music, _id: music_1392214}}
- {author: Selena Gomez, title: Love you like a love song, year: 2011}
- {create: {_index: music, _id: music_1392215}}
- {author: Justin Bieber, title: Baby, year: 2010}
- path: /_cluster/settings
method: PUT
request:
payload:
persistent:
cluster:
remote:
leader-cluster:
seeds: ['172.22.0.3:9300']
- path: /_plugins/_replication/{index}/_start
method: PUT
parameters:
index: music-names
request:
payload:
leader_alias: leader-cluster
leader_index: music
use_roles:
leader_cluster_role: all_access
follower_cluster_role: all_access
- path: /_plugins/_replication/music-names/_pause
method: POST
retry:
count: 3
request:
payload: {}
epilogues:
- path: /_plugins/_replication/{index}/_stop
method: POST
parameters:
index: music-names
request:
payload: {}
- path: /music-names
method: DELETE
status: [200, 404]
- path: /music
method: DELETE
status: [200, 404]
chapters:
- synopsis: Resume replication.
path: /_plugins/_replication/{index}/_resume
method: POST
retry:
count: 3
parameters:
index: music-names
request:
payload: {}
response:
status: 200
53 changes: 53 additions & 0 deletions tests/plugins/replication/start.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
$schema: ../../../json_schemas/test_story.schema.yaml

description: Test starting replication.
version: '>= 1.1'
prologues:
- path: /_bulk
method: POST
parameters:
refresh: true
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: /_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
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
Loading

0 comments on commit 3debf75

Please sign in to comment.