From 8ece8c118e2be54138fd95eed90b4697a475b23c Mon Sep 17 00:00:00 2001 From: Theo Truong Date: Tue, 28 May 2024 12:29:57 -0600 Subject: [PATCH] # path.basename Signed-off-by: Theo Truong --- tests/indices/index_lifecycle.yaml | 84 ++++++++++++++++++++++++++++++ tools/src/tester/TestsRunner.ts | 8 +-- 2 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 tests/indices/index_lifecycle.yaml diff --git a/tests/indices/index_lifecycle.yaml b/tests/indices/index_lifecycle.yaml new file mode 100644 index 000000000..f974b928a --- /dev/null +++ b/tests/indices/index_lifecycle.yaml @@ -0,0 +1,84 @@ +$schema: ../../json_schemas/test_story.schema.yaml + +skip: false +description: This story tests all endpoints relevant the lifecycle of an index, from creation to deletion. +epilogues: + - path: /books,movies,games + method: DELETE + ignore_errors: false +chapters: + - synopsis: Create an index named `books` with mappings and settings. + path: /{index} + method: PUT + parameters: + index: books + request_body: + payload: + mappings: + properties: + name: + type: keyword + age: + type: integer + settings: + number_of_shards: 5 + number_of_replicas: 2 + response: + status: 200 + + - synopsis: Create an index named `games` with default settings, + path: /{index} + method: PUT + parameters: + index: games + response: + status: 200 + + - synopsis: Check if the index `books` exists. It should. + path: /{index} + method: HEAD + parameters: + index: books + response: + status: 200 + + - synopsis: Check if the index `movies` exists. It should not. + path: /{index} + method: HEAD + parameters: + index: movies + response: + status: 404 + + - synopsis: Retrieve the mappings and settings of the `books` and `games` indices. + path: /{index} + method: GET + parameters: + index: books,games + flat_settings: true + response: + status: 200 + + - synopsis: Close the `books` index. + path: /{index}/_close + method: POST + parameters: + index: books + response: + status: 200 + + - synopsis: Open the `books` index. + path: /{index}/_open + method: POST + parameters: + index: books + response: + status: 200 + + - synopsis: Delete the `books` and `games` indices. + path: /{index} + method: DELETE + parameters: + index: books,games + response: + status: 200 diff --git a/tools/src/tester/TestsRunner.ts b/tools/src/tester/TestsRunner.ts index 26b84f883..12c36c1f2 100644 --- a/tools/src/tester/TestsRunner.ts +++ b/tools/src/tester/TestsRunner.ts @@ -9,14 +9,14 @@ import { read_yaml } from '../../helpers' import { type Result, type StoryEvaluation } from './types/eval.types' import ResultsDisplayer from './ResultsDisplayer' import SharedResources from './SharedResources' -import path from 'path' +import { resolve, basename } from 'path' export default class TestsRunner { path: string // Path to a story file or a directory containing story files ignored_results: Set // Chapter results to ignore when displaying results - constructor (spec: OpenAPIV3.Document, test_path: string, ignored_results: Set) { - this.path = path.resolve(test_path) + constructor (spec: OpenAPIV3.Document, path: string, ignored_results: Set) { + this.path = resolve(path) this.ignored_results = ignored_results // TODO: Grab server URL from environment variable and add authentication. @@ -49,7 +49,7 @@ export default class TestsRunner { if (fs.statSync(path).isFile()) { const story: Story = read_yaml(path) return [{ - display_path: next_prefix === '' ? (path.split('/').reverse()[0]) : next_prefix, + display_path: next_prefix === '' ? basename(path) : next_prefix, full_path: path, story }]