From 712aa4a848b4cd2129392bdba9a111b7456dc42f Mon Sep 17 00:00:00 2001 From: dblock Date: Mon, 9 Dec 2024 16:59:39 -0500 Subject: [PATCH] Added/fixed /_plugins/_rollup/jobs. Signed-off-by: dblock --- spec/namespaces/rollups.yaml | 24 ++++++--- spec/schemas/rollups._common.yaml | 32 ++++++------ tests/default/rollups/jobs.yaml | 67 +++++++++++++++++++++++++ tests/default/rollups/jobs/explain.yaml | 59 ++++++++++++++++++++++ tests/default/rollups/jobs/start.yaml | 57 +++++++++++++++++++++ tests/default/rollups/jobs/stop.yaml | 59 ++++++++++++++++++++++ 6 files changed, 277 insertions(+), 21 deletions(-) create mode 100644 tests/default/rollups/jobs.yaml create mode 100644 tests/default/rollups/jobs/explain.yaml create mode 100644 tests/default/rollups/jobs/start.yaml create mode 100644 tests/default/rollups/jobs/stop.yaml diff --git a/spec/namespaces/rollups.yaml b/spec/namespaces/rollups.yaml index e5e56a68a..5a5a70416 100644 --- a/spec/namespaces/rollups.yaml +++ b/spec/namespaces/rollups.yaml @@ -25,8 +25,8 @@ paths: externalDocs: url: https://opensearch.org/docs/latest/im-plugin/index-rollups/rollup-api/#create-or-update-an-index-rollup-job responses: - '200': - $ref: '#/components/responses/rollups.put@200' + '201': + $ref: '#/components/responses/rollups.put@201' parameters: - $ref: '#/components/parameters/rollups.put::path.id' - $ref: '#/components/parameters/rollups.put::query.if_primary_term' @@ -97,14 +97,26 @@ components: application/json: schema: $ref: '../schemas/rollups._common.yaml#/components/schemas/RollupEntity' - rollups.put@200: + rollups.put@201: content: application/json: schema: $ref: '../schemas/rollups._common.yaml#/components/schemas/RollupEntity' - rollups.delete@200: {} - rollups.start@200: {} - rollups.stop@200: {} + rollups.delete@200: + content: + application/json: + schema: + $ref: '../schemas/_common.yaml#/components/schemas/WriteResponseBase' + rollups.start@200: + content: + application/json: + schema: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' + rollups.stop@200: + content: + application/json: + schema: + $ref: '../schemas/_common.yaml#/components/schemas/AcknowledgedResponseBase' rollups.explain@200: content: application/json: diff --git a/spec/schemas/rollups._common.yaml b/spec/schemas/rollups._common.yaml index 6e6da5704..8557b1214 100644 --- a/spec/schemas/rollups._common.yaml +++ b/spec/schemas/rollups._common.yaml @@ -10,11 +10,14 @@ components: type: object properties: _id: - type: string - _seqNo: - type: number - _primaryTerm: - type: number + $ref: '_common.yaml#/components/schemas/Id' + _seq_no: + $ref: '_common.yaml#/components/schemas/SequenceNumber' + _primary_term: + type: integer + format: int64 + _version: + $ref: '_common.yaml#/components/schemas/VersionNumber' rollup: $ref: '#/components/schemas/Rollup' Rollup: @@ -39,7 +42,7 @@ components: target_index: type: string metadata_id: - type: string + type: ['null', string] page_size: type: number delay: @@ -59,18 +62,15 @@ components: description: 'Set up a Mustache message template for error notifications. For example, if an index rollup job fails, the system sends a message to a Slack channel.' ExplainEntities: type: object - properties: - item: - $ref: '#/components/schemas/Explain' + additionalProperties: + $ref: '#/components/schemas/Explain' Explain: type: object properties: - rollup_id: - type: string - last_updated_time: - type: number - continuous: - $ref: '#/components/schemas/Continuous' + metadata_id: + type: ['null', string] + rollup_metadata: + type: ['null', object] DimensionsConfigItem: type: object properties: @@ -95,6 +95,8 @@ components: type: string target_field: type: string + format: + type: ['null', string] HistogramDimension: type: object properties: diff --git a/tests/default/rollups/jobs.yaml b/tests/default/rollups/jobs.yaml new file mode 100644 index 000000000..055ebe606 --- /dev/null +++ b/tests/default/rollups/jobs.yaml @@ -0,0 +1,67 @@ + +$schema: ../../../json_schemas/test_story.schema.yaml + +description: Test index rollups. + +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, order_date: '2021-02-27T03:56:10+00:00', pages: 285} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, order_date: '2024-12-09T04:37:10-05:00', pages: 275} +epilogues: + - path: /_plugins/_rollup/jobs/books + method: DELETE + status: [200, 404] + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Create an index rollup job. + path: /_plugins/_rollup/jobs/{id} + method: PUT + parameters: + id: books + request: + payload: + rollup: + enabled: true + description: Rollup books. + schedule: + interval: + period: 1 + unit: Minutes + source_index: books + target_index: books_by_order_date + page_size: 1 + delay: 0 + continuous: false + dimensions: + - date_histogram: + source_field: order_date + fixed_interval: 1h + - terms: + source_field: title + metrics: + - source_field: pages + metrics: + - sum: {} + - avg: {} + response: + status: 201 + payload: + _id: books + rollup: + rollup_id: books + enabled: true + - synopsis: Delete an index rollup job. + path: /_plugins/_rollup/jobs/{id} + method: DELETE + parameters: + id: books diff --git a/tests/default/rollups/jobs/explain.yaml b/tests/default/rollups/jobs/explain.yaml new file mode 100644 index 000000000..a7659d5a4 --- /dev/null +++ b/tests/default/rollups/jobs/explain.yaml @@ -0,0 +1,59 @@ + +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test index rollups. + +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, order_date: '2021-02-27T03:56:10+00:00', pages: 285} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, order_date: '2024-12-09T04:37:10-05:00', pages: 275} + - path: /_plugins/_rollup/jobs/books_rollup_job + method: PUT + request: + payload: + rollup: + enabled: true + description: Rollup books. + schedule: + interval: + period: 1 + unit: Minutes + source_index: books + target_index: books_by_order_date + page_size: 1 + delay: 0 + continuous: false + dimensions: + - date_histogram: + source_field: order_date + fixed_interval: 1h + - terms: + source_field: title + metrics: + - source_field: pages + metrics: + - sum: {} + - avg: {} + - path: /_plugins/_rollup/jobs/books_rollup_job/_start + method: POST +epilogues: + - path: /_plugins/_rollup/jobs/books_rollup_job + method: DELETE + status: [200, 404] + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Explain an index rollup job. + path: /_plugins/_rollup/jobs/{id}/_explain + method: GET + parameters: + id: books_rollup_job diff --git a/tests/default/rollups/jobs/start.yaml b/tests/default/rollups/jobs/start.yaml new file mode 100644 index 000000000..16ee3ba95 --- /dev/null +++ b/tests/default/rollups/jobs/start.yaml @@ -0,0 +1,57 @@ + +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test index rollups. + +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, order_date: '2021-02-27T03:56:10+00:00', pages: 285} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, order_date: '2024-12-09T04:37:10-05:00', pages: 275} + - path: /_plugins/_rollup/jobs/books + method: PUT + request: + payload: + rollup: + enabled: true + description: Rollup books. + schedule: + interval: + period: 1 + unit: Minutes + source_index: books + target_index: books_by_order_date + page_size: 1 + delay: 0 + continuous: false + dimensions: + - date_histogram: + source_field: order_date + fixed_interval: 1h + - terms: + source_field: title + metrics: + - source_field: pages + metrics: + - sum: {} + - avg: {} +epilogues: + - path: /_plugins/_rollup/jobs/books + method: DELETE + status: [200, 404] + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Start an index rollup job. + path: /_plugins/_rollup/jobs/{id}/_start + method: POST + parameters: + id: books diff --git a/tests/default/rollups/jobs/stop.yaml b/tests/default/rollups/jobs/stop.yaml new file mode 100644 index 000000000..7cef61e68 --- /dev/null +++ b/tests/default/rollups/jobs/stop.yaml @@ -0,0 +1,59 @@ + +$schema: ../../../../json_schemas/test_story.schema.yaml + +description: Test index rollups. + +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, order_date: '2021-02-27T03:56:10+00:00', pages: 285} + - {create: {_index: books, _id: book_1392215}} + - {author: Elizabeth Rudnick, title: Beauty and the Beast, order_date: '2024-12-09T04:37:10-05:00', pages: 275} + - path: /_plugins/_rollup/jobs/books + method: PUT + request: + payload: + rollup: + enabled: true + description: Rollup books. + schedule: + interval: + period: 1 + unit: Minutes + source_index: books + target_index: books_by_order_date + page_size: 1 + delay: 0 + continuous: false + dimensions: + - date_histogram: + source_field: order_date + fixed_interval: 1h + - terms: + source_field: title + metrics: + - source_field: pages + metrics: + - sum: {} + - avg: {} + - path: /_plugins/_rollup/jobs/books/_start + method: POST +epilogues: + - path: /_plugins/_rollup/jobs/books + method: DELETE + status: [200, 404] + - path: /books + method: DELETE + status: [200, 404] +chapters: + - synopsis: Stop an index rollup job. + path: /_plugins/_rollup/jobs/{id}/_stop + method: POST + parameters: + id: books