Extremely Naughty Node.js Chaos Monkey

Mar 12, 2024 | Programming

Chaos Monkey
Build Status
Coverage Status
Pranks Count

Caution!

This project is currently in Alpha mode as we work on stabilizing the functionality and enhancing the documentation. We encourage contributions, or feel free to visit us again soon!

Introduction to Chaos Testing

If you’re about to push your Node.js application into production, remember: don’t skip your chaos testing! A software QA engineer equipped with a wild imagination can simulate “unplanned chaos” at a bar. Orders aren’t just for beers; they can also be for wild requests like “99999999999 beers” or even a “lizard.” In such a chaotic setup, things could flare up quickly, leading to unpredictable consequences, just like in your application.

Why Chaos Testing is Crucial?

Functional bugs are merely a fraction of the unpredictability your application might endure. Chaos testing focuses on those unexpected calamities that impact your application reliability. For instance:

  • Your process may crash unexpectedly.
  • The event loop could get blocked.
  • Many exceptions might go uncaught.
  • Unknown issues can slow down your API.
  • Other obscure factors can increase your error rate.

Unlike other chaos tools, our focus is on application-level chaos, particularly for Node.js applications, ensuring a productive deployment experience.

Deploy Like a Pro: Chaos Testing Steps

You can achieve effective chaos testing in just 10 minutes:

  1. Simulate some unfortunate events (e.g., blocked event loops, increased error rates).
  2. Approach your APIs to ensure they function correctly.
  3. Ensure your monitoring systems recognize the chaos situation.

Our tool is here to assist you with the first two tasks through a nit UI or command line interface!

Minimal Start (3 min)

Perfect for quick experiments, but be mindful that some fun (or damage) options won’t be available.

  1. Install: npm install node-chaos-monkey
  2. Add a flag to the start command:
    node -r node-chaos-monkey your-start-file.js
  3. Trigger chaos using API or UI:

Full Functionality (5 min)

For a complete feature set, follow these steps:

  1. Install: npm install node-chaos-monkey
  2. Add a reference in your code:
    const ChaosMonkey = require('chaos-monkey');

    Pass a reference to your express app to let the monkey generate damage within Express routes:

    ChaosMonkey.initialize(your-express-app);
  3. Trigger chaos using API or UI:

API and Documentation

For comprehensive understanding:

  1. Get list of available pranks
    Method: GET
    Address: http://localhost:8081/chaos/pranks-pool
    Sent body: Empty
    Return: [...]
  2. Activate a prank
    Method: POST
    Address: http://localhost:8081/chaos/pranks-activity
    Sent body: { name: '500-error-on-route', active: false, properties: {...} }
  3. Web socket: Subscribe to prank
    Method: WS
    Address: http://localhost:8081
    Event schema: {...}

Troubleshooting Tips

If you encounter issues during operation:

  • Ensure you have the correct code dependencies installed.
  • Verify that your API endpoints are correctly configured and accessible.
  • Monitor your server logs for potential error messages that can guide you.
  • Restart your application after making code changes to apply any updates.

For more insights, updates, or to collaborate on AI development projects, stay connected with fxis.ai.

Conclusion

At fxis.ai, we believe that such advancements are crucial for the future of AI, as they enable more comprehensive and effective solutions. Our team is continually exploring new methodologies to push the envelope in artificial intelligence, ensuring that our clients benefit from the latest technological innovations.

Stay Informed with the Newest F(x) Insights and Blogs

Tech News and Blog Highlights, Straight to Your Inbox