Skip to content

Automated resiliency tests -- a framework inspired by Chaos Monkey

Notifications You must be signed in to change notification settings

lgo/monkey-script

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

MonkeyScript

MonkeyScript is a framework to help you write automated resiliency tests. It provides you an easy way describe scenarios for a fleet of servers, which can be run automatically.

# First, we define our infrastructure using the Infra DSL
defmodule Infra do
  use MonkeyScript.Scripting.Infra

  name "app-server" do
    # The host is used to access the server for command and control (SSH)
    hosts domain: "hackthenorth.com"

    service "mysql", port: 5432
    service "nginx", port: 80
  end

  monkeyscript_finish()
end

# Include test and monkeyscript networking libraries
use ExUnit.Case
import MonkeyScript.Scripts.Networking

# Our custom code to restart the systems
def restart_worker(...) do
  ...
end

# Our monkey script resiliency tests, in the form of standard unit tests
test "can still hit homepage if mysql is down" do
  block_port(Infra, "app-server", service: "mysql") do
    assert true == ping(Infra, "app-server")
  end
end

test "web worker restarts if mysql is down" do
  block_port(Infra, "app-server", service: "mysql") do
    restart_worker(Infra, "app-server")
    :timer.sleep(:timer.seconds(10))
    assert true == ping(Infra, "app-server")
  end
end

Prereqs

  • iptables
  • ping

Installation

If available in Hex, the package can be installed by adding monkey_script to your list of dependencies in mix.exs:

def deps do
  [{:monkey_script, "~> 0.1.0"}]
end

Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/monkey_script.

About

Automated resiliency tests -- a framework inspired by Chaos Monkey

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages