Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add chaos mesh api description and table schema #635

Merged
merged 39 commits into from
Sep 20, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
fda8558
feat: add chaos mesh api description and table schema
keren-finkelstein-payu-gpo Sep 14, 2023
49f1c83
feat: add chaos mesh api crud
keren-finkelstein-payu-gpo Sep 15, 2023
b1942f1
feat: add chaos mesh api crud - review fixes
keren-finkelstein-payu-gpo Sep 18, 2023
e4441c0
feat: put endpoint for chaos-experiments
keren-finkelstein-payu-gpo Sep 18, 2023
d2d086c
ci: update packages
keren-finkelstein-payu-gpo Sep 18, 2023
c627d47
ci: update packages
keren-finkelstein-payu-gpo Sep 18, 2023
c674470
ci: update packages
keren-finkelstein-payu-gpo Sep 18, 2023
019b893
ci: update packages
keren-finkelstein-payu-gpo Sep 18, 2023
e226e5a
ci: update packages
keren-finkelstein-payu-gpo Sep 18, 2023
487cfb6
ci: update packages
keren-finkelstein-payu-gpo Sep 18, 2023
c5aacc8
ci: update packages
keren-finkelstein-payu-gpo Sep 18, 2023
a1cff84
Update dockerRun.sh
kerenfi Sep 19, 2023
e7301c0
ci: update packages
keren-finkelstein-payu-gpo Sep 19, 2023
0787483
ci: update packages
keren-finkelstein-payu-gpo Sep 19, 2023
cfa675a
ci: update packages
keren-finkelstein-payu-gpo Sep 19, 2023
f3130cc
ci: set allow fail on the sqlite integration tests
keren-finkelstein-payu-gpo Sep 19, 2023
9484c0a
ci: set allow fail on the sqlite integration tests
keren-finkelstein-payu-gpo Sep 19, 2023
436f79e
ci: set allow fail on the sqlite integration tests
keren-finkelstein-payu-gpo Sep 19, 2023
8519811
ci: set allow fail on the sqlite integration tests
keren-finkelstein-payu-gpo Sep 19, 2023
d800e84
ci: set allow fail on the sqlite integration tests - 12
keren-finkelstein-payu-gpo Sep 19, 2023
ea4b1e7
ci: set allow fail on the sqlite integration tests - 12
keren-finkelstein-payu-gpo Sep 19, 2023
4a2bf54
Merge branch 'chaos-experiments-api' of github.com:Zooz/predator into…
keren-finkelstein-payu-gpo Sep 19, 2023
e636a9f
ci: set allow fail on the sqlite integration tests - 12
keren-finkelstein-payu-gpo Sep 19, 2023
ffc783c
test: skip integration tests of chaos experiments
keren-finkelstein-payu-gpo Sep 19, 2023
c9fe4c2
test: skip integration tests of chaos experiments
keren-finkelstein-payu-gpo Sep 19, 2023
099996f
test: skip integration tests of chaos experiments
keren-finkelstein-payu-gpo Sep 19, 2023
373cb9b
test: skip integration tests of chaos experiments
keren-finkelstein-payu-gpo Sep 19, 2023
5ce214b
test: try node 12
keren-finkelstein-payu-gpo Sep 19, 2023
af898d4
test: try node 12
keren-finkelstein-payu-gpo Sep 19, 2023
a46978e
test: try node 12
keren-finkelstein-payu-gpo Sep 19, 2023
eda83bf
test: try node 12
keren-finkelstein-payu-gpo Sep 19, 2023
31cd76a
test: try node 12
keren-finkelstein-payu-gpo Sep 19, 2023
bd1d84e
test: try node 12
keren-finkelstein-payu-gpo Sep 19, 2023
1c15d87
test: try node 12
keren-finkelstein-payu-gpo Sep 19, 2023
d91d7e3
test: try node 12 - streaming using mysql
keren-finkelstein-payu-gpo Sep 19, 2023
40a8105
test: try node 12 - streaming using mysql
keren-finkelstein-payu-gpo Sep 19, 2023
7383f3d
test: try node 12 - streaming using remove allow failure sqlite with k8s
keren-finkelstein-payu-gpo Sep 19, 2023
574ad4f
test: try node 12 - streaming using remove allow failure sqlite with k8s
keren-finkelstein-payu-gpo Sep 19, 2023
1c4a0f1
test: try node 12 - streaming using remove allow failure sqlite with k8s
keren-finkelstein-payu-gpo Sep 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
262 changes: 262 additions & 0 deletions docs/openapi3.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ tags:
- name: Webhooks
description: |
This resource allows you to configure webhooks.
- name: Chaos Experiments
description: |
This resource allows you to add chaos mesh experiments as part of the running job
x-tagGroups:
- name: Reference
tags:
Expand Down Expand Up @@ -1890,6 +1893,185 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/upload_file_response'
/v1/chaos-experiments:
parameters:
- $ref: '#/components/parameters/context_id'
post:
operationId: create-chaos-experiment
tags:
- Chaos Experiments
summary: Create chaos file
description: >-
Create a chaos experiment.
responses:
'201':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/chaosExperiment'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
'422':
description: Unprocessable entity
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/chaosExperiment'
description: The chaos experiment to create
required: true
get:
operationId: retrieve-all-choos-experiments
tags:
- Chaos Experiments
summary: Retrieve all chaos experiments
description: Retrieve all chaos experiments
parameters:
- in: query
name: from
description: From which result to start retrieve data - pagination
required: false
schema:
type: integer
minimum: 0
default: 0
- in: query
name: limit
description: Max results to return from this query ( Limit to 100 )
required: false
schema:
type: integer
maximum: 200
default: 100
- in: query
name: template
description: filter to get templates only
required: false
schema:
type: boolean
example: true
- in: query
name: exclude
description: fields to exclude from response
required: false
schema:
type: array
items:
type: string
enum:
- kubeObject
responses:
'200':
description: Success
content:
application/json:
schema:
type: array
items:
$ref: '#/components/schemas/chaosExperiment'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
/v1/chaos-experiments/{experiment_id}:
parameters:
- $ref: '#/components/parameters/context_id'
get:
operationId: retrieve-chaos-experiment
tags:
- Chaos Experiments
summary: Retrieve chaos experiment
description: Retrieve a specific chaos experiment.
parameters:
- in: path
name: experiment_id
description: The id of the experiment to retrieve.
required: true
schema:
type: string
responses:
'200':
description: Success
content:
application/json:
schema:
$ref: '#/components/schemas/chaosExperiment'
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
'404':
description: Not found
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
delete:
operationId: delete-chaos-experiment
tags:
- Chaos Experiments
summary: Delete chaos experiment
description: Delete a specific chaos experiment
parameters:
- in: path
name: experiment_id
description: The id of the experiment to retrieve.
required: true
schema:
type: string
responses:
'204':
description: Success
'400':
description: Bad request
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
'409':
description: Conflict
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'
'500':
description: Internal server error
content:
application/json:
schema:
$ref: '#/components/schemas/error_response'

components:
parameters:
context_id:
Expand Down Expand Up @@ -2956,3 +3138,83 @@ components:
url:
type: string
description: Webhook url to post events
chaosExperiment:
required:
- name
- kubeObject
properties:
id:
description: Unique experiment identifier
type: string
format: uuid
readOnly: true
name:
type: string
minLength: 1
description: The name of the experiment.
example: Custom javascript for logging
kubeObject:
$ref: '#/components/schemas/kubeObject'
updated_at:
type: string
format: date-time
description: The date and time that the procesor file was updated.
readOnly: true
created_at:
type: string
format: date-time
description: The date and time that the procesor file was created.
readOnly: true
kubeObject:
required:
- apiVersion
- kind
- metadata
- spec
properties:
apiVersion:
type: string
enum:
- "chaos-mesh.org/v1alpha1"
kind:
type: string
enum:
- 'dnschaos'
- 'PodChaos'
- 'AWSChaos'
- 'HTTPChaos'
- 'StressChaos'
description: A description of the experiment.
example: 'PodChaos'
metadata:
required:
- name
- namespace
properties:
namespace:
type: string
example: 'apps'
name:
type: string
example: "my-pod-chaos"
annotations:
type: object
additionalProperties:
type: string
namespace:
type: string
example: "apps"
name:
type: string
example: "my-pod-chaos"
spec:
type: object
example:
selector:
namespaces:
- apps
labelSelectors:
app: live-balances-api
mode: all
action: pod-kill
duration: 1m
4 changes: 3 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const testsRouter = require('./tests/routes/testsRoute.js');
const processorsRouter = require('./processors/routes/processorsRoute.js');
const filesRouter = require('./files/routes/filesRoute.js');
const webhooksRouter = require('./webhooks/routes/webhooksRouter');
const chaosExperimentsRouter = require('./chaos-experiments/routes/chaosExperimentsRoute');
const swaggerValidator = require('express-ajv-swagger-validation');
const database = require('./database/database');
const jobsManager = require('./jobs/models/jobManager');
Expand Down Expand Up @@ -72,7 +73,7 @@ module.exports = async () => {
app.use(httpContext.middleware);
app.use(contexts.middleware);

app.set('json replacer', (k, v) => (v === null ? undefined : v))
app.set('json replacer', (k, v) => (v === null ? undefined : v));

app.use('/health', healthRouter);
app.use('/v1/config', configRouter);
Expand All @@ -83,6 +84,7 @@ module.exports = async () => {
app.use('/v1/processors', processorsRouter);
app.use('/v1/files', filesRouter);
app.use('/v1/webhooks', webhooksRouter);
app.use('/v1/chaos-experiments', chaosExperimentsRouter);

app.use('/', function (req, res, next) {
res.redirect('/ui');
Expand Down
46 changes: 46 additions & 0 deletions src/chaos-experiments/controllers/chaosExperimentController.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
'use strict';
const processorManager = require('../models/chaosExperimentsManager');

module.exports.createChaosExperiment = function (req, res, next) {
return processorManager.createChaosExperiment(req.body)
.then(function (result) {
return res.status(201).json(result);
})
.catch(function (err) {
return next(err);
});
};

module.exports.getAllChaosExperiments = async function (req, res, next) {
let { query: { from = 0, limit = 100 } } = req;
let processors;
try {
from = parseInt(from);
limit = parseInt(limit);
processors = await processorManager.getAllChaosExperiments(from, limit, req.query.exclude);
return res.status(200).json(processors);
} catch (err) {
return next(err);
}
};

module.exports.getChaosExperimentById = async function (req, res, next) {
let chaosExperiment;
const { params: { experiment_id: experimentId } } = req;
try {
chaosExperiment = await processorManager.getChaosExperimentById(experimentId);
return res.status(200).json(chaosExperiment);
} catch (err) {
return next(err);
}
};

module.exports.deleteChaosExperiment = async function (req, res, next) {
const { params: { experiment_id: experimentId } } = req;
try {
await processorManager.deleteChaosExperiment(experimentId);
return res.status(204).json();
} catch (err) {
return next(err);
}
};
Loading