Skip to content

Commit 140c0fd

Browse files
committed
Move docker-compose into the test suite path.
Signed-off-by: dblock <[email protected]>
1 parent d4a0c05 commit 140c0fd

File tree

7 files changed

+32
-8
lines changed

7 files changed

+32
-8
lines changed

.github/workflows/test-spec.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
run: npm ci
6161

6262
- name: Run OpenSearch Cluster
63-
working-directory: .github/opensearch-cluster/${{ matrix.entry.tests || 'default' }}
63+
working-directory: tests/${{ matrix.entry.tests || 'default' }}
6464
run: docker compose up -d
6565

6666
- name: Get Container ID

.github/workflows/test-tools-integ.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
uses: actions/checkout@v4
3333

3434
- name: Run OpenSearch Cluster
35-
working-directory: .github/opensearch-cluster/default
35+
working-directory: tests/default
3636
run: |
3737
docker compose up -d
3838
sleep 15

TESTING_GUIDE.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Set up an OpenSearch cluster with Docker:
2525
(Replace `<<your_password>>` with your desired password. If not provided, the default password inside the `docker-compose.yml` file will be used.)
2626
```bash
2727
export OPENSEARCH_PASSWORD=<<your_password>>
28-
cd .github/opensearch-cluster/default
28+
cd tests/default
2929
docker compose up -d
3030
```
3131
@@ -71,7 +71,7 @@ curl -k -X PUT --user "admin:${OPENSEARCH_PASSWORD}" https://localhost:9200/_clu
7171
7272
The spec tests reside in the [tests/](tests) directory. Tests are organized in suites ([default](tests/default/), etc.), and subsequently 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/default/indices/index.yaml](tests/default/indices/index.yaml) (for `/{index}`), and [tests/default/indices/doc.yaml](tests/default/indices/doc.yaml) (for `/{index}/_doc`).
7373
74-
Additional suites require custom configuration that is defined in a separate `docker-compose.yml`. For example [.github/opensearch-cluster/plugins/index_state_management/docker-compose.yml](.github/opensearch-cluster/plugins/index_state_management/docker-compose.yml) uses a custom setting of `plugins.index_state_management.job_interval=1` to cause the `/_nodes` API to return plugin information tested in [tests/plugins/index_state_management/nodes/plugins/index_state_management.yaml](tests/plugins/index_state_management/nodes/plugins/index_state_management.yaml).
74+
Additional suites require custom configuration that is defined in a separate `docker-compose.yml`. For example [tests/plugins/index_state_management/docker-compose.yml](tests/plugins/index_state_management/docker-compose.yml) uses a custom setting of `plugins.index_state_management.job_interval=1` to cause the `/_nodes` API to return plugin information tested in [tests/plugins/index_state_management/nodes/plugins/index_state_management.yaml](tests/plugins/index_state_management/nodes/plugins/index_state_management.yaml).
7575
7676
Each yaml file in the tests directory represents a test story that tests a collection of related operations.
7777

tools/src/tester/TestRunner.ts

+18-4
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,18 @@ import { basename, resolve } from 'path'
1818
import type StoryValidator from "./StoryValidator";
1919
import { OpenSearchHttpClient } from 'OpenSearchHttpClient'
2020
import * as ansi from './Ansi'
21+
import _ from 'lodash'
22+
23+
const EXCLUDED_FILES = [
24+
'docker-compose.yml'
25+
]
2126

2227
export default class TestRunner {
2328
private readonly _http_client: OpenSearchHttpClient
2429
private readonly _story_validator: StoryValidator
2530
private readonly _story_evaluator: StoryEvaluator
2631
private readonly _result_logger: ResultLogger
32+
private readonly _story_files: Record<string, StoryFile[]> = {}
2733

2834
constructor (http_client: OpenSearchHttpClient, story_validator: StoryValidator, story_evaluator: StoryEvaluator, result_logger: ResultLogger) {
2935
this._http_client = http_client
@@ -34,7 +40,7 @@ export default class TestRunner {
3440

3541
async run (story_path: string, version?: string, dry_run: boolean = false): Promise<{ results: StoryEvaluations, failed: boolean }> {
3642
let failed = false
37-
const story_files = this.#sort_story_files(this.#collect_story_files(resolve(story_path), '', ''))
43+
const story_files = this.story_files(story_path)
3844
const results: StoryEvaluations = { evaluations: [] }
3945

4046
if (!dry_run) {
@@ -53,6 +59,12 @@ export default class TestRunner {
5359
return { results, failed }
5460
}
5561

62+
story_files(story_path: string): StoryFile[] {
63+
if (this._story_files[story_path] !== undefined) return this._story_files[story_path]
64+
this._story_files[story_path] = this.#sort_story_files(this.#collect_story_files(resolve(story_path), '', ''))
65+
return this._story_files[story_path]
66+
}
67+
5668
#collect_story_files (folder: string, file: string, prefix: string): StoryFile[] {
5769
const path = file === '' ? folder : `${folder}/${file}`
5870
const next_prefix = prefix === '' ? file : `${prefix}/${file}`
@@ -64,9 +76,11 @@ export default class TestRunner {
6476
story
6577
}]
6678
} else {
67-
return fs.readdirSync(path).flatMap(next_file => {
68-
return this.#collect_story_files(path, next_file, next_prefix)
69-
})
79+
return _.compact(fs.readdirSync(path).flatMap(next_file => {
80+
if (!EXCLUDED_FILES.includes(next_file)) {
81+
return this.#collect_story_files(path, next_file, next_prefix)
82+
}
83+
}))
7084
}
7185
}
7286

tools/tests/tester/integ/TestRunner.test.ts

+10
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,13 @@ test('stories folder', async () => {
3939
const expected_evaluations = [passed, chapter_error, output_error, prologue_error, invalid_data, not_found, skipped]
4040
expect(actual_evaluations).toEqual(expected_evaluations)
4141
})
42+
43+
describe('story_files', () => {
44+
const { test_runner } = construct_tester_components('tools/tests/tester/fixtures/specs/excerpt.yaml')
45+
46+
test('does not contain docker-compose.yml', () => {
47+
expect(test_runner.story_files('tests/plugins/index_state_management').map(
48+
story_file => story_file.display_path
49+
)).not.toContain('nodes/plugins/docker-compose.yml')
50+
})
51+
})

0 commit comments

Comments
 (0)