From cf8d6413dfe26c05a643458297dc030eaa6559b1 Mon Sep 17 00:00:00 2001 From: dblock Date: Tue, 11 Jun 2024 07:51:46 -0400 Subject: [PATCH] Reorganize tests in namespaces. Signed-off-by: dblock --- DEVELOPER_GUIDE.md | 16 ++++++++++++++-- tests/{_core/index => indices}/_doc.yaml | 2 +- tests/{_core => indices}/index.yaml | 0 .../processors.yaml => ingest/pipeline.yaml} | 2 +- 4 files changed, 16 insertions(+), 4 deletions(-) rename tests/{_core/index => indices}/_doc.yaml (95%) rename tests/{_core => indices}/index.yaml (100%) rename tests/{_ingest/pipeline/_common/processors.yaml => ingest/pipeline.yaml} (93%) diff --git a/DEVELOPER_GUIDE.md b/DEVELOPER_GUIDE.md index 1a42372cd..76f19a1a4 100644 --- a/DEVELOPER_GUIDE.md +++ b/DEVELOPER_GUIDE.md @@ -9,6 +9,8 @@ - [Global Parameters](#global-parameters) - [OpenAPI Extensions](#openapi-extensions) - [Writing Spec Tests](#writing-spec-tests) + - [Test Stories](#test-stories) + - [Organizing Tests](#organizing-tests) - [Running Spec Tests Locally](#running-spec-tests-locally) - [Tools](#tools) - [Setup](#setup) @@ -150,12 +152,18 @@ This repository includes several OpenAPI Specification Extensions to fill in any ## Writing Spec Tests -To assure the correctness of the spec, you must add tests for the spec in the [tests/](tests) directory. Each yaml file in the tests directory represents a test story that tests a collection of related operations. A test story has 3 main components: +To assure the correctness of the spec, you must add tests for the spec in the [tests/](tests) directory. + +### Test Stories + +Each yaml file in the tests directory represents a test story that tests a collection of related operations. + +A test story has 3 main components: - prologues: These are the operations that are executed before the test story is run. They are used to set up the environment for the test story. - chapters: These are the operations that are being tested. - epilogues: These are the operations that are executed after the test story is run. They are used to clean up the environment after the test story. -Below is the simplified version of the test story that tests the [index operations](tests/_core/index.yaml): +Below is the simplified version of the test story that tests the [index operations](tests/indices/index.yaml): ```yaml $schema: ../json_schemas/test_story.schema.yaml # The schema of the test story. Include this line so that your editor can validate the test story on the fly. @@ -205,6 +213,10 @@ chapters: Check the [test_story JSON Schema](json_schemas/test_story.schema.yaml) for the complete structure of a test story. +### Organizing Tests + +Tests are organized in folders that match [namespaces](spec/namespaces). For example, tests for APIs defined in [spec/namespaces/indices.yaml](spec/namespaces/indices.yaml) can be found in [tests/indices/index.yaml](tests/indices/index.yaml) (for `/{index}`), and [tests/indices/_doc.yaml](tests/indices/_doc.yaml) (for `/{index}/_doc`). + ### Running Spec Tests Locally Set up an OpenSearch cluster with Docker using the default OPENSEARCH_PASSWORD (Recommended): diff --git a/tests/_core/index/_doc.yaml b/tests/indices/_doc.yaml similarity index 95% rename from tests/_core/index/_doc.yaml rename to tests/indices/_doc.yaml index b85d72151..b4789f0c7 100644 --- a/tests/_core/index/_doc.yaml +++ b/tests/indices/_doc.yaml @@ -1,4 +1,4 @@ -$schema: ../../../json_schemas/test_story.schema.yaml +$schema: ../../json_schemas/test_story.schema.yaml skip: false description: Test inserting and retrieving a doc. diff --git a/tests/_core/index.yaml b/tests/indices/index.yaml similarity index 100% rename from tests/_core/index.yaml rename to tests/indices/index.yaml diff --git a/tests/_ingest/pipeline/_common/processors.yaml b/tests/ingest/pipeline.yaml similarity index 93% rename from tests/_ingest/pipeline/_common/processors.yaml rename to tests/ingest/pipeline.yaml index 214a27cb1..2408d79d3 100644 --- a/tests/_ingest/pipeline/_common/processors.yaml +++ b/tests/ingest/pipeline.yaml @@ -1,4 +1,4 @@ -$schema: ../../../../json_schemas/test_story.schema.yaml +$schema: ../../json_schemas/test_story.schema.yaml skip: false description: |