Skip to content

Commit

Permalink
Added support for retry in prologues/epilogues, added replication tes…
Browse files Browse the repository at this point in the history
…ts. (#713)

Signed-off-by: dblock <[email protected]>
Signed-off-by: Thomas Farr <[email protected]>
Co-authored-by: Thomas Farr <[email protected]>
  • Loading branch information
dblock and Xtansia authored Dec 10, 2024
1 parent 8b9a491 commit a54a5f5
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 @@ -28,6 +28,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Added missing `repository` query parameter to `/_cat/snapshots` ([#700](https://github.com/opensearch-project/opensearch-api-specification/pull/700))
- Added `sm` namespace API specifications ([#701](https://github.com/opensearch-project/opensearch-api-specification/pull/701))
- Added schema for `/_plugins/_knn/stats`, `/_plugins/_knn/models/{model_id}`, `_train` and `_search` ([#704](https://github.com/opensearch-project/opensearch-api-specification/pull/704))
- Added `retry` support in `prologues` and `epilogues` ([#713](https://github.com/opensearch-project/opensearch-api-specification/pull/713))

### 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 a54a5f5

Please sign in to comment.