Skip to content

Commit

Permalink
Genric message
Browse files Browse the repository at this point in the history
  • Loading branch information
goldbergyoni committed Apr 5, 2019
1 parent 49ea5d8 commit 8e5a056
Show file tree
Hide file tree
Showing 7 changed files with 187 additions and 166 deletions.
2 changes: 1 addition & 1 deletion entry-points/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class API {
if (prankToEmit.name === "blocked-event-loop" || prankToEmit.name === "memory-load" || prankToEmit.name === "uncaught-exception" || prankToEmit.name === "cpu-load") {
socket.broadcast.emit('new-prank-activity', prankToEmit);
}
}, 1000);
}, 2000);


socket.on('disconnect', function () {
Expand Down
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const API = require('./entry-points/api');
const ChaosControl = require('./chaos-control');

console.log('Chaos monkey starting point');
module.exports.initialize = (expressApp) => {
return {
api: new API(expressApp),
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"test:manual": "npm run build:ui && nodemon ./tests/manual-testing-with-simple-web-app/index.js",
"test:manual": "nodemon ./tests/manual-testing-with-simple-web-app/index.js",
"start": "node ./index.js",
"start:dev": "npm run build:ui && nodemon ./index.js",
"start:dev": "concurrently \"npm run build:ui\" \"npm start --prefix tests/manual-testing-with-simple-web-app\" \"nodemon\"",
"build:ui": "npm install --prefix ui && npm run build --prefix ui",
"serve": "concurrently \"npm run build:ui\" \"npm run start\"",
"start:app": "npm run build:ui && npm run start"
Expand Down
332 changes: 180 additions & 152 deletions pranks/pranks-definition.js
Original file line number Diff line number Diff line change
@@ -1,155 +1,183 @@
class PranksDefinition{
getAll() {
const result = [{
name: "500-error-on-route",
friendlyName: "API route returns 500 error",
file: "500-error-on-route",
active: true,
properties: {
urls: ["/api/products", "/anyurl"]
class PranksDefinition {
getAll() {
const result = [{
name: "500-error-on-route",
friendlyName: "API route returns 500 error",
file: "500-error-on-route",
active: true,
properties: [{
name: "url",
description: "Which route should return 500 error",
defaultValue: "/api/products",
type: "string"
}],
schedule: {
type: "immediate-schedule",
fadeOutInMS: 10000
},
description: 'Our monkey intercepts HTTP routes and return errors on your behalf',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, error should appear in log',
reality: 'This feature is not implemented yet',
success: 'Yes'
},
{
name: "Process-exit",
friendlyName: "Process exit",
file: "process-exit",
active: true,
properties: [{
name: "exitCode",
description: "What should be the process quit exit code",
defaultValue: 1,
type: "number"
}],
schedule: {
type: "immediate-schedule",
fadeOutInMS: 10000
},
description: 'Our monkey kills the process',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, a new process should be instantiated',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "uncaught-exception",
friendlyName: "Uncaught exception",
file: "uncaught-exception",
active: true,
properties: [{
name: "message",
Description: "What message should the error include",
defaultValue: "Uncaught exception was thrown by the chaos monkey",
type: "string"
}],
schedule: {
type: "one-time-schedule",
delay: 12000
},
description: 'Our monkey Throws an uncaught exception into the void',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, process should stay alive or new one should get instantiated',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "unhandled-rejection",
friendlyName: "Unhandled promise rejection",
file: "unhandled-rejection",
active: true,
properties: [{
name: "message",
Description: "What message should the error include",
defaultValue: "Uncaught exception was thrown by the chaos monkey",
type: "string"
}],
schedule: {
type: "one-time-schedule",
delay: 10000
},
description: 'Our monkey Throws an uncaught promise rejection into the void',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, process should stay alive or new one should get instantiated',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "memory-load",
friendlyName: "Memory is overloaded",
file: "memory-load",
active: true,
properties: [{
name: "maxMemorySizeInMB",
Description: "How much memory should be used by the chaos monkey",
defaultValue: 2000,
type: "number"
}],
schedule: {
type: "one-time-schedule",
delay: 1000,
fadeOutInMS: 30000
},
description: 'Our monkey constantly increases the RAM, if no limit was specified the entire allowed 1.7GB will be used',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "cpu-load",
friendlyName: "Busy CPU",
file: "cpu-load",
active: true,
properties: {},
schedule: {
type: "peaks",
sleepTimeBetweenPeaksInMS: 3000,
pickLengthInMS: 10000,
forHowLong: 8000
},
description: 'Our monkey constantly keeps the CPU busy (without blocking the event loop)',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "blocked-event-loop",
friendlyName: "Blocked event loop",
file: "blocked-event-loop",
active: true,
properties: {},
schedule: {
type: "peaks",
sleepTimeBetweenPeaksInMS: 3000,
pickLengthInMS: 10000,
forHowLong: 8000
},
description: 'Our monkey constantly blocks the event loop',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "broken-http-integration",
friendlyName: "Broken Integration",
file: "broken-http-integration",
active: true,
properties:
[{
name: "url",
Description: "What is the URL of the external service that should be mocked",
defaultValue: "http://localhost/otherservice/",
type: "string"
},
schedule: {
type: "immediate-schedule",
fadeOutInMS: 10000
},
description: 'Our monkey intercepts HTTP routes and return errors on your behalf',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, error should appear in log',
reality: 'This feature is not implemented yet',
success: 'Yes'
},
{
name: "Process-exit",
friendlyName: "Process exit",
file: "process-exit",
active: true,
properties: {
exitCode: 1
},
schedule: {
type: "immediate-schedule",
fadeOutInMS: 10000
},
description: 'Our monkey kills the process',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, a new process should be instantiated',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "uncaught-exception",
friendlyName: "Uncaught exception",
file: "uncaught-exception",
active: true,
properties: {
message: "Uncaught exception was thrown by the chaos monkey"
},
schedule: {
type: "one-time-schedule",
delay: 12000
},
description: 'Our monkey Throws an uncaught exception into the void',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, process should stay alive or new one should get instantiated',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "unhandled-rejection",
friendlyName: "Unhandled promise rejection",
file: "unhandled-rejection",
active: true,
properties: {
message: "Uncaught rejection was thrown by the chaos monkey"
},
schedule: {
type: "one-time-schedule",
delay: 10000
},
description: 'Our monkey Throws an uncaught promise rejection into the void',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, process should stay alive or new one should get instantiated',
reality: 'This feature is not implemented yet',
success: 'No'
{
name: "httpStatus",
Description: "What HTTP status should the mocked URL return",
defaultValue: "500",
type: "number"
}
],
schedule: {
type: "peaks",
sleepTimeBetweenPeaksInMS: 3000,
pickLengthInMS: 10000,
forHowLong: 8000
},
{
name: "memory-load",
friendlyName: "Memory is overloaded",
file: "memory-load",
active: true,
properties: {
maxMemorySizeInMB: 10
},
schedule: {
type: "one-time-schedule",
delay: 1000,
fadeOutInMS: 30000
},
description: 'Our monkey constantly increases the RAM, if no limit was specified the entire allowed 1.7GB will be used',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "cpu-load",
friendlyName: "Busy CPU",
file: "cpu-load",
active: true,
properties: {},
schedule: {
type: "peaks",
sleepTimeBetweenPeaksInMS: 3000,
pickLengthInMS: 10000,
forHowLong: 8000
},
description: 'Our monkey constantly keeps the CPU busy (without blocking the event loop)',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "blocked-event-loop",
friendlyName: "Blocked event loop",
file: "blocked-event-loop",
active: true,
properties: {},
schedule: {
type: "peaks",
sleepTimeBetweenPeaksInMS: 3000,
pickLengthInMS: 10000,
forHowLong: 8000
},
description: 'Our monkey constantly blocks the event loop',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify',
reality: 'This feature is not implemented yet',
success: 'No'
},
{
name: "broken-http-integration",
friendlyName: "Broken Integration",
file: "broken-http-integration",
active: true,
properties: {},
schedule: {
type: "peaks",
sleepTimeBetweenPeaksInMS: 3000,
pickLengthInMS: 10000,
forHowLong: 8000
},
description: 'Our monkey intercepts HTTP calls and return random HTTP erros on their behalf',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, code should find alternate routes to achieve a decent UX',
reality: 'This feature is not implemented yet',
success: 'No'
}
];

return result;
}

}
description: 'Our monkey intercepts HTTP calls and return random HTTP erros on their behalf',
lastHappened: new Date(),
expectations: 'Your monitoring system should notify, code should find alternate routes to achieve a decent UX',
reality: 'This feature is not implemented yet',
success: 'No'
}
];

return result;
}

}

module.exports = PranksDefinition;
module.exports = PranksDefinition;
11 changes: 1 addition & 10 deletions tests/manual-testing-with-simple-web-app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const port = process.env.PORT || 8080;
app.listen(port);

//I wish I could use also a command line -> chaos-monkey -f app.js --test-command='npm test' -r report.html
console.log("Demo web app is now starting")
ChaosMonkey.initialize(app);

var router = express.Router();
Expand All @@ -23,14 +24,4 @@ router.get("/api/products", (req, res) => {
});


process.on("uncaughtException", error => {
console.log(`Uncaught error is now handled error`);
console.log(error);
});

process.on("unhandledRejection", (reason, p) => {
console.log(`Uncaught promise is now handled error`);
console.log(p);
});

app.use(router);
2 changes: 1 addition & 1 deletion ui/src/components/ChaosTest/ChooseChaos.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ChooseChaos extends Component {
makeCall() {
this.interval = setInterval(() => {
this.props.store.callApi('http://localhost:8081/chaos/pranks-pool');
}, 500);
}, 2000);
}

selectPrank = prank => {
Expand Down
Loading

0 comments on commit 8e5a056

Please sign in to comment.