当前位置: 首页 > 软件库 > Web应用开发 > >

node-chaos-monkey

Extremly naughty chaos monkey for Node.js
授权协议 MIT License
开发语言 JavaScript
所属分类 Web应用开发
软件类型 开源软件
地区 不详
投 递 者 屠坚壁
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Extremely naughty Node.js chaos monkey

Caution: Alpha mode, we're now stabilizing the functionality and enhancing the docs. Consider contributing or visiting again soon


Don't go to production without 10 minutes of application-level chaos testing

"A software QA engineer walks into a bar

He orders a beer. Orders 0 beers. Orders 99999999999 beers. Orders a lizard. Orders -1 beers. Orders a ueicbksjdhd.

First real customer walks in and asks where the bathroom is. The bar bursts into flames, killing everyone."

Credit @brenankeller

Functional bugs are just a subset of the bad things that happen in production. In reality, unplanned chaos will affect your application reliability. How? your process will crash, the event loop might get blocked, many exceptions will not get caught, some unknowns will slow your API, other unknowns will increase your error rate. To name a few. Unlike most chaos tools, our project is focused on application-level chaos and specifically bad things that happen in Node.js applications.

Deploy like a pro by spending as little as 10 minutes on Chaos Testing:

1. Simulate some bad things (e.g. event loop is blocked, error rate is inclining)

2. Approach your APIs to ensure they function correctly

3. Ensure your monitoring systems became aware of the situation

We can seamlessly perform the two first tasks for you using our nit UI or command line

3 min start

Great for quick experiments, some pranks (damage) won't be available

A. Install: npm install node-chaos-monkey

B. Add a flag to start command: node -r node-chaos-monkey {your start file.js}

C. Trigger chaos using API or UI:

  • Browse to http/s://{host}/chaos and trigger some chaos
  • Invoke the API POST: http/s://{host}/chaos/random

This will trigger a random chaos, multiple pranks will get executed (e.g. memory overload, uncaught exceptions). Follow the log or the UI to see whatg happened and whether your app stayed resillience

5 min start (full functionality)

A. Install: npm install node-chaos-monkey

B. Add a reference in your code:

Require this package at the very beginning of your app, before registering other routes

const ChaosMonkey = require('chaos-monkey');
//pass in a reference to express app so the monkey can generate damage also within Express routes. This param is optional //but without it some pranks won't be available
ChaosMonkey.initialize(your-express-app);

C. Trigger chaos using API or UI:

  • Browse to http/s://{host}/chaos and trigger some chaos
  • Invoke the API POST: http/s://{host}/chaos/random

API and full documentation

1. Get list of available pranks

Method: GET

Address: http://localhost:8081/chaos/pranks-pool

Sent body: Empty

Return:[ { "name": "500-error-on-route", "file": "500-error-on-route", "active": false, "properties": { "urls": [ "/api/products", "/anyurl" ] }, "schedule": { "type": "immediate-schedule", "fadeOutInMS": 10000 } } ]

2. Activate a prank

Method: POST

Address: http://localhost:8081/chaos/pranks-activity

Sent body:`{"name": "500-error-on-route","file": "500-error-on-route","active": false,"properties": {"urls": ["/api/products", "/anyurl"]},"schedule": {"type": "immediate-schedule","fadeOutInMS": 10000}}

Return:`

3. Web socket: subscribe to prank

Method: WS

Address: http://localhost:8081

Event schema:

{name: '500-error-on-route', friendlyName: 'API returned a 500 status error', 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: 'The process has crashed', success: 'Yes' }

Example:`

<script src=" https://cdnjs.cloudflare.com/ajax/libs/socket.io/2.0.4/socket.io.js"></script>
<Script>
    var socket = io('http://localhost:8081');
    var isOkToEmit = true;

    console.log('after')
    socket.on('new-prank-activity', function (data) {
        console.log(`A new prank just ran ${data}`);
    });
</Script>
`
 相关资料
  • Chaos 是一个基于 Linux 平台, reactor 模式的网络事件库, 目前仅支持 TCP 传输协议, 仅在 x86_64下编译, 并遵循3-clause BSD 开源协议. 在使用上, 可以说它很像 boost asio, 可能是由于我对 boost asio 的接口设计很有爱吧, 而且对于 boost asio 在异步编程方面的思想, 我个人也比较认同, 但至今我也没有仔细阅读过 bo

  • Chaos Mesh 是一个云原生的混沌工程(Chaos Engineering)平台,可在 Kubernetes 环境中进行混沌测试。 Chaos Mesh 主要包含两大组件: Chaos Operator:核心组件 Chaos Dashboard:可视化面板,显示混沌实验对系统在线服务的影响 Chaos Operator 以一种可管理的方式将故障注入到应用程序和 Kubernetes 基础结构

  • Chaos Monkey,该工具可以随机关闭亚马逊云平台虚拟机,帮助工程师识别网络弱点。由 Netflix 发布。

  • Kubernetes Pod Chaos Monkey This repository contains a Dockerfile and associated Kubernetes configuration for a Deployment that will randomly delete pods in a given namespace. This is implemented in B

  • Node是kubernetes集群的工作节点,可以是物理机也可以是虚拟机。 Node的状态 Node包括如下状态信息: Address HostName:可以被kubelet中的--hostname-override参数替代。 ExternalIP:可以被集群外部路由到的IP地址。 InternalIP:集群内部使用的IP,集群外部无法访问。 Condition OutOfDisk:磁盘空间不足时

  • node 负责 peer node 子命令。