From 1c2971ac1d31a10d32f65d709045b2a786f80b0b Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 7 Jun 2024 16:20:49 -0400 Subject: [PATCH 1/6] Validate order of superseded operations. Signed-off-by: dblock --- tools/helpers.ts | 12 +++++ .../components/SupersededOperationsFile.ts | 32 ++++++++++++ .../linter/SupersededOperationsFile.test.ts | 49 ++++++++++++++++--- .../incorrect_order_of_operations.yaml | 11 +++++ .../invalid_schema.yaml} | 2 +- 5 files changed, 97 insertions(+), 9 deletions(-) create mode 100644 tools/tests/linter/fixtures/superseded_operations/incorrect_order_of_operations.yaml rename tools/tests/linter/fixtures/{_superseded_operations.yaml => superseded_operations/invalid_schema.yaml} (91%) diff --git a/tools/helpers.ts b/tools/helpers.ts index 49b7218f1..790407497 100644 --- a/tools/helpers.ts +++ b/tools/helpers.ts @@ -56,6 +56,18 @@ export function sort_by_keys (obj: Record, priorities: string[] = [ }) } +export function sort_array_by_keys (values: any[], priorities: string[] = []): string[] { + const orders = _.fromPairs(priorities.map((k, i) => [k, i + 1])) + return _.clone(values).sort((a, b) => { + const order_a = orders[a] + const order_b = orders[b] + if (order_a != null && order_b != null) return order_a - order_b + if (order_a != null) return 1 + if (order_b != null) return -1 + return a.localeCompare(b) + }) +} + export function ensure_parent_dir (file_path: string): void { fs.mkdirSync(path.dirname(file_path), { recursive: true }) } diff --git a/tools/src/linter/components/SupersededOperationsFile.ts b/tools/src/linter/components/SupersededOperationsFile.ts index 47b34fe9f..7c0f5d3b0 100644 --- a/tools/src/linter/components/SupersededOperationsFile.ts +++ b/tools/src/linter/components/SupersededOperationsFile.ts @@ -7,8 +7,40 @@ * compatible open source license. */ +import _ from 'lodash' +import { sort_array_by_keys } from '../../../helpers' import FileValidator from './base/FileValidator' +import { type ValidationError } from 'types' +import { type OpenAPIV3 } from 'openapi-types' + +const HTTP_METHODS = ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS', 'TRACE'] export default class SupersededOperationsFile extends FileValidator { has_json_schema = true + protected _superseded_ops: OpenAPIV3.Document | undefined + + validate (): ValidationError[] { + const schema_validations = super.validate() + if (schema_validations.length > 0) return schema_validations + return this.validate_order_of_operations() + } + + superseded_ops (): OpenAPIV3.Document { + if (this._superseded_ops) return this._superseded_ops + this._superseded_ops = this.spec() + delete (this._superseded_ops as any).$schema + return this._superseded_ops + } + + validate_order_of_operations (): ValidationError[] { + return _.entries(this.superseded_ops()).map(([path, p]) => { + const current_keys = p.operations + const sorted_keys = sort_array_by_keys(p.operations as string[], HTTP_METHODS) + if(!_.isEqual(current_keys, sorted_keys)) { + return this.error( + `Operations must be sorted. Expected ${_.join(sorted_keys, ', ')}.`, + path) + } + }).filter((e) => e) as ValidationError[] + } } diff --git a/tools/tests/linter/SupersededOperationsFile.test.ts b/tools/tests/linter/SupersededOperationsFile.test.ts index 13102d45c..696e78426 100644 --- a/tools/tests/linter/SupersededOperationsFile.test.ts +++ b/tools/tests/linter/SupersededOperationsFile.test.ts @@ -9,12 +9,45 @@ import SupersededOperationsFile from 'linter/components/SupersededOperationsFile' -test('validate()', () => { - const validator = new SupersededOperationsFile('./tools/tests/linter/fixtures/_superseded_operations.yaml') - expect(validator.validate()).toEqual([ - { - file: 'fixtures/_superseded_operations.yaml', - message: "File content does not match JSON schema found in './json_schemas/_superseded_operations.schema.yaml':\n [\n {\n \"instancePath\": \"/~1hello~1world/operations/1\",\n \"schemaPath\": \"#/patternProperties/%5E~1/properties/operations/items/enum\",\n \"keyword\": \"enum\",\n \"params\": {\n \"allowedValues\": [\n \"GET\",\n \"POST\",\n \"PUT\",\n \"DELETE\",\n \"HEAD\",\n \"OPTIONS\",\n \"PATCH\"\n ]\n },\n \"message\": \"must be equal to one of the allowed values\"\n }\n]" - } - ]) +describe('validate()', () => { + test('invalid schema', () => { + const validator = new SupersededOperationsFile('./tools/tests/linter/fixtures/superseded_operations/invalid_schema.yaml') + expect(validator.validate()).toEqual([ + { + file: 'superseded_operations/invalid_schema.yaml', + message: "File content does not match JSON schema found in './json_schemas/_superseded_operations.schema.yaml':\n " + + JSON.stringify([ + { + "instancePath": "/~1hello~1world/operations/1", + "schemaPath": "#/patternProperties/%5E~1/properties/operations/items/enum", + "keyword": "enum", + "params": { + "allowedValues": [ + "GET", + "POST", + "PUT", + "DELETE", + "HEAD", + "OPTIONS", + "PATCH" + ] + }, + "message": "must be equal to one of the allowed values" + } + ], null, 2), + }, + ]) + }) + + test('incorrect order of operations', () => { + const validator = new SupersededOperationsFile('./tools/tests/linter/fixtures/superseded_operations/incorrect_order_of_operations.yaml') + expect(validator.validate()).toEqual([ + { + file: 'superseded_operations/incorrect_order_of_operations.yaml', + location: '/world/hello', + message: "Operations must be sorted. Expected GET, HEAD, POST, PUT, PATCH, DELETE." + }, + ]) + }) }) + diff --git a/tools/tests/linter/fixtures/superseded_operations/incorrect_order_of_operations.yaml b/tools/tests/linter/fixtures/superseded_operations/incorrect_order_of_operations.yaml new file mode 100644 index 000000000..076e22685 --- /dev/null +++ b/tools/tests/linter/fixtures/superseded_operations/incorrect_order_of_operations.yaml @@ -0,0 +1,11 @@ +$schema: ./json_schemas/_superseded_operations.schema.yaml + +/world/hello: + superseded_by: /world/goodbye + operations: + - PATCH + - GET + - DELETE + - HEAD + - POST + - PUT diff --git a/tools/tests/linter/fixtures/_superseded_operations.yaml b/tools/tests/linter/fixtures/superseded_operations/invalid_schema.yaml similarity index 91% rename from tools/tests/linter/fixtures/_superseded_operations.yaml rename to tools/tests/linter/fixtures/superseded_operations/invalid_schema.yaml index 17341c41f..34e2b3fea 100644 --- a/tools/tests/linter/fixtures/_superseded_operations.yaml +++ b/tools/tests/linter/fixtures/superseded_operations/invalid_schema.yaml @@ -4,4 +4,4 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml superseded_by: /goodbye/world operations: - GET - - CLEAN \ No newline at end of file + - CLEAN From d7a699f710ce1f03e9f190871db4087a54033d65 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 7 Jun 2024 16:25:35 -0400 Subject: [PATCH 2/6] Correct order of superseded operations. Signed-off-by: dblock --- spec/_superseded_operations.yaml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/_superseded_operations.yaml b/spec/_superseded_operations.yaml index 9db450730..a0ffaeadc 100644 --- a/spec/_superseded_operations.yaml +++ b/spec/_superseded_operations.yaml @@ -49,9 +49,9 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml superseded_by: /_plugins/_alerting/monitors/{monitorID} operations: - GET + - HEAD - PUT - DELETE - - HEAD /_opendistro/_alerting/monitors/{monitorID}/_acknowledge/alerts: superseded_by: /_plugins/_alerting/monitors/{monitorID}/_acknowledge/alerts operations: @@ -107,9 +107,9 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml superseded_by: /_plugins/_anomaly_detection/detectors/{detectorID} operations: - GET + - HEAD - PUT - DELETE - - HEAD /_opendistro/_anomaly_detection/detectors/{detectorID}/_preview: superseded_by: /_plugins/_anomaly_detection/detectors/{detectorID}/_preview operations: @@ -200,9 +200,9 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml superseded_by: /_plugins/_ism/policies/{policyID} operations: - GET + - HEAD - PUT - DELETE - - HEAD /_opendistro/_ism/remove: superseded_by: /_plugins/_ism/remove operations: @@ -353,9 +353,9 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml superseded_by: /_plugins/_rollup/jobs/{rollupID} operations: - GET + - HEAD - PUT - DELETE - - HEAD /_opendistro/_rollup/jobs/{rollupID}/_explain: superseded_by: /_plugins/_rollup/jobs/{rollupID}/_explain operations: @@ -420,8 +420,8 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml superseded_by: /_plugins/_security/api/cache operations: - GET - - PUT - POST + - PUT - DELETE /_opendistro/_security/api/internalusers/: superseded_by: /_plugins/_security/api/internalusers/ @@ -433,8 +433,8 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml operations: - GET - PUT - - DELETE - PATCH + - DELETE /_opendistro/_security/api/internalusers/{name}/authtoken: superseded_by: /_plugins/_security/api/internalusers/{name}/authtoken operations: @@ -457,8 +457,8 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml operations: - GET - PUT - - DELETE - PATCH + - DELETE /_opendistro/_security/api/rolesmapping/: superseded_by: /_plugins/_security/api/rolesmapping/ operations: @@ -469,8 +469,8 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml operations: - GET - PUT - - DELETE - PATCH + - DELETE /_opendistro/_security/api/securityconfig: superseded_by: /_plugins/_security/api/securityconfig operations: @@ -519,8 +519,8 @@ $schema: ./json_schemas/_superseded_operations.schema.yaml operations: - GET - PUT - - DELETE - PATCH + - DELETE /_opendistro/_security/api/user: superseded_by: /_plugins/_security/api/user operations: From ac9939a41ddc5a53d783e162879190c814320016 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 7 Jun 2024 16:37:18 -0400 Subject: [PATCH 3/6] Moved helpers into src. Signed-off-by: dblock --- tools/src/OpenSearchHttpClient.ts | 2 +- tools/src/coverage/CoverageCalculator.ts | 2 +- .../dump-cluster-spec/dump-cluster-spec.ts | 2 +- tools/{ => src}/helpers.ts | 0 tools/src/linter/components/NamespaceFile.ts | 2 +- .../components/SupersededOperationsFile.ts | 2 +- .../linter/components/base/FileValidator.ts | 2 +- tools/src/merger/GlobalParamsGenerator.ts | 2 +- tools/src/merger/OpenApiMerger.ts | 2 +- tools/src/merger/OpenDistro.ts | 2 +- tools/src/merger/SupersededOpsGenerator.ts | 2 +- tools/src/tester/OperationLocator.ts | 2 +- tools/src/tester/TestRunner.ts | 2 +- tools/src/tester/_generate_story_types.ts | 2 +- tools/tests/helpers.test.ts | 28 +++++++++++++++++++ tools/tests/tester/helpers.ts | 2 +- 16 files changed, 42 insertions(+), 14 deletions(-) rename tools/{ => src}/helpers.ts (100%) create mode 100644 tools/tests/helpers.test.ts diff --git a/tools/src/OpenSearchHttpClient.ts b/tools/src/OpenSearchHttpClient.ts index 76cb8672d..cd5ce9cb2 100644 --- a/tools/src/OpenSearchHttpClient.ts +++ b/tools/src/OpenSearchHttpClient.ts @@ -10,7 +10,7 @@ import { Option } from '@commander-js/extra-typings' import axios, { type AxiosInstance, type AxiosRequestConfig, type AxiosResponse } from 'axios' import * as https from 'node:https' -import { sleep } from '../helpers' +import { sleep } from './helpers' const DEFAULT_URL = 'https://localhost:9200' const DEFAULT_USER = 'admin' diff --git a/tools/src/coverage/CoverageCalculator.ts b/tools/src/coverage/CoverageCalculator.ts index 090e0ecb1..0bc33a837 100644 --- a/tools/src/coverage/CoverageCalculator.ts +++ b/tools/src/coverage/CoverageCalculator.ts @@ -8,7 +8,7 @@ */ import { type OpenAPIV3 } from 'openapi-types' -import { HTTP_METHODS, read_yaml, write_json } from '../../helpers' +import { HTTP_METHODS, read_yaml, write_json } from '../helpers' export default class CoverageCalculator { private readonly _cluster_spec: OpenAPIV3.Document diff --git a/tools/src/dump-cluster-spec/dump-cluster-spec.ts b/tools/src/dump-cluster-spec/dump-cluster-spec.ts index 16038396c..cedc7094a 100644 --- a/tools/src/dump-cluster-spec/dump-cluster-spec.ts +++ b/tools/src/dump-cluster-spec/dump-cluster-spec.ts @@ -10,7 +10,7 @@ import { Command, Option } from '@commander-js/extra-typings' import { resolve } from 'path' import * as process from 'node:process' -import { write_yaml } from '../../helpers' +import { write_yaml } from '../helpers' import { get_opensearch_opts_from_cli, OPENSEARCH_INSECURE_OPTION, diff --git a/tools/helpers.ts b/tools/src/helpers.ts similarity index 100% rename from tools/helpers.ts rename to tools/src/helpers.ts diff --git a/tools/src/linter/components/NamespaceFile.ts b/tools/src/linter/components/NamespaceFile.ts index 2808b6986..fb6ad52f7 100644 --- a/tools/src/linter/components/NamespaceFile.ts +++ b/tools/src/linter/components/NamespaceFile.ts @@ -12,7 +12,7 @@ import { type OperationSpec, type ValidationError } from 'types' import OperationGroup from './OperationGroup' import _ from 'lodash' import Operation from './Operation' -import { resolve_ref, sort_by_keys } from '../../../helpers' +import { resolve_ref, sort_by_keys } from '../../helpers' import FileValidator from './base/FileValidator' const HTTP_METHODS = ['get', 'head', 'post', 'put', 'patch', 'delete', 'options', 'trace'] diff --git a/tools/src/linter/components/SupersededOperationsFile.ts b/tools/src/linter/components/SupersededOperationsFile.ts index 7c0f5d3b0..65e3ec825 100644 --- a/tools/src/linter/components/SupersededOperationsFile.ts +++ b/tools/src/linter/components/SupersededOperationsFile.ts @@ -8,7 +8,7 @@ */ import _ from 'lodash' -import { sort_array_by_keys } from '../../../helpers' +import { sort_array_by_keys } from '../../helpers' import FileValidator from './base/FileValidator' import { type ValidationError } from 'types' import { type OpenAPIV3 } from 'openapi-types' diff --git a/tools/src/linter/components/base/FileValidator.ts b/tools/src/linter/components/base/FileValidator.ts index 2ed0aa128..53a887014 100644 --- a/tools/src/linter/components/base/FileValidator.ts +++ b/tools/src/linter/components/base/FileValidator.ts @@ -10,7 +10,7 @@ import ValidatorBase from './ValidatorBase' import { type ValidationError } from 'types' import { type OpenAPIV3 } from 'openapi-types' -import { read_yaml } from '../../../../helpers' +import { read_yaml } from '../../../helpers' import AJV from 'ajv' import addFormats from 'ajv-formats' diff --git a/tools/src/merger/GlobalParamsGenerator.ts b/tools/src/merger/GlobalParamsGenerator.ts index 1e1af59fb..192e711b9 100644 --- a/tools/src/merger/GlobalParamsGenerator.ts +++ b/tools/src/merger/GlobalParamsGenerator.ts @@ -9,7 +9,7 @@ import { type OpenAPIV3 } from 'openapi-types' import _ from 'lodash' -import { read_yaml } from '../../helpers' +import { read_yaml } from '../helpers' export default class GlobalParamsGenerator { global_params: Record diff --git a/tools/src/merger/OpenApiMerger.ts b/tools/src/merger/OpenApiMerger.ts index 47decaeaa..5d38ddeca 100644 --- a/tools/src/merger/OpenApiMerger.ts +++ b/tools/src/merger/OpenApiMerger.ts @@ -10,7 +10,7 @@ import { type OpenAPIV3 } from 'openapi-types' import fs from 'fs' import _ from 'lodash' -import { read_yaml, write_yaml } from '../../helpers' +import { read_yaml, write_yaml } from '../helpers' import SupersededOpsGenerator from './SupersededOpsGenerator' import GlobalParamsGenerator from './GlobalParamsGenerator' import { Logger } from '../Logger' diff --git a/tools/src/merger/OpenDistro.ts b/tools/src/merger/OpenDistro.ts index f7081ce06..021e58b70 100644 --- a/tools/src/merger/OpenDistro.ts +++ b/tools/src/merger/OpenDistro.ts @@ -8,7 +8,7 @@ */ import { type HttpVerb, type OperationPath, type SupersededOperationMap } from 'types' -import { read_yaml, write_yaml } from '../../helpers' +import { read_yaml, write_yaml } from '../helpers' // One-time script to generate _superseded_operations.yaml file for OpenDistro // Keeping this for now in case we need to update the file in the near future. Can be removed after a few months. diff --git a/tools/src/merger/SupersededOpsGenerator.ts b/tools/src/merger/SupersededOpsGenerator.ts index 0fd34eb54..9228af55d 100644 --- a/tools/src/merger/SupersededOpsGenerator.ts +++ b/tools/src/merger/SupersededOpsGenerator.ts @@ -9,7 +9,7 @@ import { type OperationSpec, type SupersededOperationMap } from 'types' import _ from 'lodash' -import { read_yaml } from '../../helpers' +import { read_yaml } from '../helpers' import { type Logger } from '../Logger' export default class SupersededOpsGenerator { diff --git a/tools/src/tester/OperationLocator.ts b/tools/src/tester/OperationLocator.ts index 2d5df08ee..df0f2dc91 100644 --- a/tools/src/tester/OperationLocator.ts +++ b/tools/src/tester/OperationLocator.ts @@ -8,7 +8,7 @@ */ import { type OpenAPIV3 } from 'openapi-types' -import { resolve_ref } from '../../helpers' +import { resolve_ref } from '../helpers' import { type Chapter } from './types/story.types' import { type ParsedOperation } from './types/spec.types' import _ from 'lodash' diff --git a/tools/src/tester/TestRunner.ts b/tools/src/tester/TestRunner.ts index fa88306ab..779d314de 100644 --- a/tools/src/tester/TestRunner.ts +++ b/tools/src/tester/TestRunner.ts @@ -11,7 +11,7 @@ import type StoryEvaluator from './StoryEvaluator' import { type StoryFile } from './StoryEvaluator' import fs from 'fs' import { type Story } from './types/story.types' -import { read_yaml } from '../../helpers' +import { read_yaml } from '../helpers' import { Result, type StoryEvaluation } from './types/eval.types' import { type ResultLogger } from './ResultLogger' import { basename, resolve } from 'path' diff --git a/tools/src/tester/_generate_story_types.ts b/tools/src/tester/_generate_story_types.ts index 98e9ed1f6..6113e7948 100644 --- a/tools/src/tester/_generate_story_types.ts +++ b/tools/src/tester/_generate_story_types.ts @@ -9,7 +9,7 @@ import * as js2ts from 'json-schema-to-typescript' import fs from 'fs' -import { read_yaml } from '../../helpers' +import { read_yaml } from '../helpers' const schema = read_yaml('json_schemas/test_story.schema.yaml') void js2ts.compile(schema, 'Story', diff --git a/tools/tests/helpers.test.ts b/tools/tests/helpers.test.ts new file mode 100644 index 000000000..de8db04c3 --- /dev/null +++ b/tools/tests/helpers.test.ts @@ -0,0 +1,28 @@ +/* +* Copyright OpenSearch Contributors +* SPDX-License-Identifier: Apache-2.0 +* +* The OpenSearch Contributors require contributions made to +* this file be licensed under the Apache-2.0 license or a +* compatible open source license. +*/ + +import { sort_array_by_keys } from '../src/helpers' + +describe('helpers', () => { + describe('sort_array_by_keys', () => { + test('sorts arrays of string', () => { + expect(sort_array_by_keys([])).toEqual([]) + expect(sort_array_by_keys(['GET', 'POST'], ['GET', 'POST'])).toEqual(['GET', 'POST']) + expect(sort_array_by_keys(['GET', 'POST'], ['POST', 'GET'])).toEqual(['POST', 'GET']) + expect(sort_array_by_keys(['GET', 'POST'], ['POST', 'GET', 'DELETE'])).toEqual(['POST', 'GET']) + expect(sort_array_by_keys(['DELETE', 'POST', 'GET'], ['POST', 'GET', 'DELETE'])).toEqual(['POST', 'GET', 'DELETE']) + }) + + test('does not modify the original object', () => { + const arr = ['GET', 'POST'] + expect(sort_array_by_keys(arr, ['POST', 'GET'])).toEqual(['POST', 'GET']) + expect(arr).toEqual(['GET', 'POST'] ) + }) + }) +}) diff --git a/tools/tests/tester/helpers.ts b/tools/tests/tester/helpers.ts index e10accce6..05bf981eb 100644 --- a/tools/tests/tester/helpers.ts +++ b/tools/tests/tester/helpers.ts @@ -9,7 +9,7 @@ import YAML from 'yaml' import type { ChapterEvaluation, Evaluation, StoryEvaluation } from '../../src/tester/types/eval.types' -import { read_yaml } from '../../helpers' +import { read_yaml } from 'helpers' import StoryEvaluator from '../../src/tester/StoryEvaluator' import OperationLocator from '../../src/tester/OperationLocator' import ChapterReader from '../../src/tester/ChapterReader' From cb902b68f5ade3385e602d46bbe1bffd6f74a5a9 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 7 Jun 2024 16:37:28 -0400 Subject: [PATCH 4/6] Added CHANGELOG entry. Signed-off-by: dblock --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5d9d2a243..ceae883de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,7 +17,8 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - Added `npm run test:unit` and `test:integ` ([#320](https://github.com/opensearch-project/opensearch-api-specification/pull/320)) - Added code coverage to tools' tests ([#323](https://github.com/opensearch-project/opensearch-api-specification/pull/323)) - Added a YAML linter ([#312](https://github.com/opensearch-project/opensearch-api-specification/pull/312)) - +- Added linter to validate order of spec operations ([#325](https://github.com/opensearch-project/opensearch-api-specification/pull/326)) ([#326](https://github.com/opensearch-project/opensearch-api-specification/pull/326)) + ### Changed - Replaced Smithy with a native OpenAPI spec ([#189](https://github.com/opensearch-project/opensearch-api-specification/issues/189)) From e6272d593a78245c6cd68f09bb8e895e7cf8b394 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 7 Jun 2024 16:43:44 -0400 Subject: [PATCH 5/6] Everything is relative to src. Signed-off-by: dblock --- tools/tests/linter/SchemasValidator.test.ts | 2 +- tools/tests/merger/OpenApiMerger.test.ts | 2 +- tools/tests/tester/ansi.test.ts | 2 +- tools/tests/tester/helpers.test.ts | 4 ++-- tools/tests/tester/helpers.ts | 18 +++++++++--------- tools/tests/tester/integ/TestRunner.test.ts | 2 +- tools/tests/tester/start.test.ts | 2 +- 7 files changed, 16 insertions(+), 16 deletions(-) diff --git a/tools/tests/linter/SchemasValidator.test.ts b/tools/tests/linter/SchemasValidator.test.ts index 7bb99a945..c2d48dc4f 100644 --- a/tools/tests/linter/SchemasValidator.test.ts +++ b/tools/tests/linter/SchemasValidator.test.ts @@ -8,7 +8,7 @@ */ import { Logger } from 'Logger' -import SchemasValidator from '../../src/linter/SchemasValidator' +import SchemasValidator from 'linter/SchemasValidator' test('validate() - named_schemas', () => { const validator = new SchemasValidator('./tools/tests/linter/fixtures/schemas_validator/named_schemas', new Logger()) diff --git a/tools/tests/merger/OpenApiMerger.test.ts b/tools/tests/merger/OpenApiMerger.test.ts index c8cd0e812..4e5acc20e 100644 --- a/tools/tests/merger/OpenApiMerger.test.ts +++ b/tools/tests/merger/OpenApiMerger.test.ts @@ -9,7 +9,7 @@ import OpenApiMerger from 'merger/OpenApiMerger' import fs from 'fs' -import { Logger } from '../../src/Logger' +import { Logger } from 'Logger' test('merge()', () => { const merger = new OpenApiMerger('./tools/tests/merger/fixtures/spec/', new Logger()) diff --git a/tools/tests/tester/ansi.test.ts b/tools/tests/tester/ansi.test.ts index 3cb90eab0..cc74ba8f0 100644 --- a/tools/tests/tester/ansi.test.ts +++ b/tools/tests/tester/ansi.test.ts @@ -7,7 +7,7 @@ * compatible open source license. */ -import * as ansi from '../../src/tester/Ansi' +import * as ansi from 'tester/Ansi' test('b', () => { expect(ansi.b('xyz')).toEqual('\x1b[1mxyz\x1b[0m') diff --git a/tools/tests/tester/helpers.test.ts b/tools/tests/tester/helpers.test.ts index 8383edb42..3395e3087 100644 --- a/tools/tests/tester/helpers.test.ts +++ b/tools/tests/tester/helpers.test.ts @@ -7,8 +7,8 @@ * compatible open source license. */ -import { overall_result } from '../../src/tester/helpers' -import { type Evaluation, Result } from '../../src/tester/types/eval.types' +import { overall_result } from 'tester/helpers' +import { type Evaluation, Result } from 'tester/types/eval.types' describe('helpers', () => { function e (...results: Result[]): Evaluation[] { diff --git a/tools/tests/tester/helpers.ts b/tools/tests/tester/helpers.ts index 05bf981eb..9bb984458 100644 --- a/tools/tests/tester/helpers.ts +++ b/tools/tests/tester/helpers.ts @@ -8,17 +8,17 @@ */ import YAML from 'yaml' -import type { ChapterEvaluation, Evaluation, StoryEvaluation } from '../../src/tester/types/eval.types' +import type { ChapterEvaluation, Evaluation, StoryEvaluation } from 'tester/types/eval.types' import { read_yaml } from 'helpers' -import StoryEvaluator from '../../src/tester/StoryEvaluator' -import OperationLocator from '../../src/tester/OperationLocator' -import ChapterReader from '../../src/tester/ChapterReader' -import SchemaValidator from '../../src/tester/SchemaValidator' -import ChapterEvaluator from '../../src/tester/ChapterEvaluator' -import { OpenSearchHttpClient } from '../../src/OpenSearchHttpClient' +import StoryEvaluator from 'tester/StoryEvaluator' +import OperationLocator from 'tester/OperationLocator' +import ChapterReader from 'tester/ChapterReader' +import SchemaValidator from 'tester/SchemaValidator' +import ChapterEvaluator from 'tester/ChapterEvaluator' +import { OpenSearchHttpClient } from 'OpenSearchHttpClient' import { type OpenAPIV3 } from 'openapi-types' -import TestRunner from '../../src/tester/TestRunner' -import { NoOpResultLogger, type ResultLogger } from '../../src/tester/ResultLogger' +import TestRunner from 'tester/TestRunner' +import { NoOpResultLogger, type ResultLogger } from 'tester/ResultLogger' import * as process from 'node:process' export function construct_tester_components (spec_path: string): { diff --git a/tools/tests/tester/integ/TestRunner.test.ts b/tools/tests/tester/integ/TestRunner.test.ts index b6c8c99f9..e06802c95 100644 --- a/tools/tests/tester/integ/TestRunner.test.ts +++ b/tools/tests/tester/integ/TestRunner.test.ts @@ -8,7 +8,7 @@ */ import { construct_tester_components, flatten_errors, load_expected_evaluation } from '../helpers' -import { type StoryEvaluation } from '../../../src/tester/types/eval.types' +import { type StoryEvaluation } from 'tester/types/eval.types' test('stories folder', async () => { const { test_runner } = construct_tester_components('tools/tests/tester/fixtures/specs/indices_excerpt.yaml') diff --git a/tools/tests/tester/start.test.ts b/tools/tests/tester/start.test.ts index 47dcb6846..8e6fc88e3 100644 --- a/tools/tests/tester/start.test.ts +++ b/tools/tests/tester/start.test.ts @@ -8,7 +8,7 @@ */ import { spawnSync } from 'child_process' -import * as ansi from '../../src/tester/Ansi' +import * as ansi from 'tester/Ansi' import * as path from 'path' const spec = (args: string[]): any => { From 70a0c1471f80f1eeb1dbc81aee3c8a248d6ef9c9 Mon Sep 17 00:00:00 2001 From: dblock Date: Fri, 7 Jun 2024 16:46:54 -0400 Subject: [PATCH 6/6] Fix badge. Signed-off-by: dblock --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 5d6e20513..9412efb1b 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![Code Covergage](https://codecov.io/github/opensearch-project/opensearch-api-specification/graph/badge.svg?token=TO9YMAKSHH)](https://codecov.io/github/opensearch-project/opensearch-api-specification) [![Test Tools (Unit)](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/test-tools-unit.yml/badge.svg)](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/test-tools-unit.yml) [![Test Tools (Integration)](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/test-tools-integ.yml/badge.svg)](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/test-tools-integ.yml) -[![Test Spec](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/test.yml/badge.svg)](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/test.yml) +[![Test Spec](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/test-spec.yml/badge.svg)](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/test-spec.yml) [![Validate Spec](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/validate-spec.yml/badge.svg)](https://github.com/opensearch-project/opensearch-api-specification/actions/workflows/validate-spec.yml) - [OpenSearch API Specification](#opensearch-api-specification)