Skip to content

Commit

Permalink
Spec Test Framework
Browse files Browse the repository at this point in the history
Signed-off-by: Theo Truong <[email protected]>
  • Loading branch information
nhtruong committed May 29, 2024
1 parent c58908d commit 078326f
Show file tree
Hide file tree
Showing 21 changed files with 1,693 additions and 4 deletions.
11 changes: 11 additions & 0 deletions .github/opensearch-cluster/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
version: '3'

services:
opensearch-cluster:
image: opensearchproject/opensearch:${OPENSEARCH_VERSION}
ports:
- "9200:9200"
- "9600:9600"
environment:
- "discovery.type=single-node"
- "OPENSEARCH_INITIAL_ADMIN_PASSWORD=${OPENSEARCH_PASSWORD}"
45 changes: 45 additions & 0 deletions .github/workflows/test-spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Test the OS cluster against the OpenSearch Spec

on:
push:
branches: [ '**' ]
paths:
- 'package*.json'
- 'tsconfig.json'
- 'tools/tester/**'
- 'spec/**'
pull_request:
branches: [ '**' ]
paths:
- 'package*.json'
- 'tsconfig.json'
- 'tools/tester/**'
- 'spec/**'

jobs:
test-opensearch-spec:
runs-on: ubuntu-latest
env:
OPENSEARCH_VERSION: 2.12.0
OPENSEARCH_PASSWORD: myStrongPassword123!
OPENSEARCH_URL: https://localhost:9200
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install Dependencies
run: npm install

- name: Run OpenSearch Cluster
working-directory: .github/opensearch-cluster
run: |
docker-compose up -d
sleep 60
- name: Run Tests
run: npm run test:spec
146 changes: 146 additions & 0 deletions json_schemas/test_story.schema.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
$schema: http://json-schema.org/draft-07/schema#

type: object
properties:
$schema:
type: string
skip:
type: boolean
description: If true, the story will be skipped.
default: false
description:
type: string
prologues:
type: array
items:
$ref: '#/definitions/SupplementalChapter'
epilogues:
type: array
items:
$ref: '#/definitions/SupplementalChapter'
chapters:
type: array
items:
$ref: '#/definitions/Chapter'
minItems: 1
required: [ description, chapters]
additionalProperties: false

definitions:
Chapter:
type: object
allOf:
- $ref: '#/definitions/ChapterRequest'
- properties:
synopsis:
type: string
description: A brief description of the chapter.
response:
$ref: '#/definitions/ExpectedResponse'
required: [ synopsis ]
additionalProperties: false

ReadChapter:
allOf:
- $ref: '#/definitions/Chapter'
- type: object
properties:
response:
$ref: '#/definitions/ActualResponse'
required: [ response ]
additionalProperties: false

SupplementalChapter:
allOf:
- $ref: '#/definitions/ChapterRequest'
- type: object
properties:
status:
description: Array of success HTTP status codes. Default to [200, 201].
type: array
default: [200, 201]
items:
type: integer
additionalProperties: false

ChapterRequest:
type: object
properties:
path:
type: string
method:
type: string
enum: [ GET, PUT, POST, DELETE, PATCH, HEAD, OPTIONS ]
parameters:
type: object
additionalProperties:
$ref: '#/definitions/Parameter'
request_body:
$ref: '#/definitions/RequestBody'
required: [ path, method ]
additionalProperties: false


RequestBody:
type: object
properties:
content_type:
type: string
default: application/json
payload:
$ref: '#/definitions/Payload'
required: [ payload ]
additionalProperties: false

ExpectedResponse:
type: object
properties:
status:
type: integer
description: The expected HTTP status code. Default to 200.
default: 200
content_type:
type: string
default: application/json
payload:
$ref: '#/definitions/Payload'
required: [ status ]
additionalProperties: false

ActualResponse:
type: object
properties:
status:
type: integer
content_type:
type: string
payload:
$ref: '#/definitions/Payload'
message:
type: string
description: Error message for non 2XX responses.
error:
type: object
description: Error object.
required: [ status, content_type, payload ]
additionalProperties: false

Payload:
anyOf:
- type: object
- type: array
- type: string
- type: number
- type: boolean

Parameter:
anyOf:
- type: array
items:
oneOf:
- type: string
- type: number
- type: boolean
- type: string
- type: number
- type: boolean
Loading

0 comments on commit 078326f

Please sign in to comment.