dstest.config({
substrate = "docker",
seed = 456,
weights = {
pause = 0.5,
kill = 0.5,
},
step_delay = 200,
})
local s = dstest.setup({
image = "kennethreitz/httpbin",
ports = { 80 },
})
local info = dstest.inspect(s)
dstest.info(string.format("Initial state: %s, pid=%s, ip=%s",
info.state, tostring(info.pid), tostring(info.ip)))
local result = dstest.step()
dstest.info(string.format("Injected fault: %s", result.fault))
info = dstest.inspect(s)
dstest.info(string.format("After fault: state=%s, pid=%s",
info.state, tostring(info.pid)))
dstest.clear(s)
local ok, resp = pcall(dstest.http, s, "GET", "/get")
if ok and resp.status == 200 then
dstest.info("Container recovered successfully")
else
dstest.warn("Container not yet recovered")
end
info = dstest.inspect(s)
dstest.info(string.format("Final state: %s", info.state))
dstest.clear(s)
dstest.info("inspect example complete")