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 DSLdefmoduleInfradouseMonkeyScript.Scripting.Infraname"app-server"do# The host is used to access the server for command and control (SSH)hostsdomain: "hackthenorth.com"service"mysql",port: 5432service"nginx",port: 80endmonkeyscript_finish()end# Include test and monkeyscript networking librariesuseExUnit.CaseimportMonkeyScript.Scripts.Networking# Our custom code to restart the systemsdefrestart_worker(...)do...end# Our monkey script resiliency tests, in the form of standard unit teststest"can still hit homepage if mysql is down"doblock_port(Infra,"app-server",service: "mysql")doasserttrue==ping(Infra,"app-server")endendtest"web worker restarts if mysql is down"doblock_port(Infra,"app-server",service: "mysql")dorestart_worker(Infra,"app-server"):timer.sleep(:timer.seconds(10))asserttrue==ping(Infra,"app-server")endendiptablesping
If available in Hex, the package can be installed
by adding monkey_script to your list of dependencies in mix.exs:
defdepsdo[{:monkey_script,"~> 0.1.0"}]endDocumentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/monkey_script.