Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc doc changes #22

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .formatter.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Used by "mix format"
[
inputs: ["{mix,.formatter}.exs", "{config,lib,test}/**/*.{ex,exs}"]
]
25 changes: 15 additions & 10 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,27 +1,32 @@
# The directory Mix will write compiled artifacts to.
_build/
/_build/

# If you run "mix test --cover", coverage assets end up here.
cover/
/cover/

# The directory Mix downloads your dependencies sources to.
deps/
/deps/

# Where 3rd-party dependencies like ExDoc output generated docs.
doc/
# Where third-party dependencies like ExDoc output generated docs.
/doc/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# chaperon load test results
results/
# Ignore package tarball (built via "mix hex.build").
chaperon-*.tar

# vs code plugin
.elixir_ls/
# Temporary files, for example, from tests.
/tmp/

.vscode
# Chaperon load test results.
results/

# Misc.
.DS_Store
4 changes: 2 additions & 2 deletions LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)
# The MIT License (MIT)

Copyright (c) 2016-2019 Christopher Bertels
Copyright (c) 2016 Christopher Bertels

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
22 changes: 18 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Chaperon

[![Module Version](https://img.shields.io/hexpm/v/chaperon.svg)](https://hex.pm/packages/chaperon)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/chaperon/)
[![Total Download](https://img.shields.io/hexpm/dt/chaperon.svg)](https://hex.pm/packages/chaperon)
[![License](https://img.shields.io/hexpm/l/chaperon.svg)](https://github.com/polleverywhere/chaperon/blob/master/LICENSE.md)
[![Last Updated](https://img.shields.io/github/last-commit/polleverywhere/chaperon.svg)](https://github.com/yyy/chaperon/commits/master)

## HTTP Service Performance Testing Framework

This is a framework / library & tool for doing load and performance tests on web services.
Expand Down Expand Up @@ -45,16 +51,24 @@ Then enter the following code into any worker's iex shell to connect it to the m
iex> Chaperon.connect_to_master :"[email protected]"
```

Pick one of the nodes as your master node and connect to it from the worker nodes (see above).
Before starting up the child nodes make sure you've given them the same VM cookie and config to point to the master node.
Pick one of the nodes as your master node and connect to it from the worker nodes (see above).
Before starting up the child nodes make sure you've given them the same VM cookie and config to point to the master node.
The master node can be identical to the worker nodes, the only difference being that it kicks off the load test and distributes the workload across all worker nodes. When a worker node is done with running a scenario / session task, it sends the results back to the master, which then merges all results to give the final metrics for display / output.


## Is this ready for production use?

Chaperon is being used at [Poll Everywhere](https://polleverywhere.com) and was written for load testing our infrastructure and polling services.
It has been used to simulate over 100k concurrent vote participant sessions on a 4 node cluster.
It currently is still on a pre 1.0 version. A 1.0 release is not planned yet as the main focus is to get rid of any potential bugs, refine the public API and internal implementation code until we're confident that everything works as expected.
It has been used to simulate over 100k concurrent vote participant sessions on a 4 node cluster.
It currently is still on a pre 1.0 version. A 1.0 release is not planned yet as the main focus is to get rid of any potential bugs, refine the public API and internal implementation code until we're confident that everything works as expected.
That doesn't mean it shouldn't be used in its current stage, though.

If you'd like to try out Chaperon, please give it a try. Any feedback, bug reports or patches are welcome.


## Copyright and License

Copyright (c) 2016 Christopher Bertels

This work is free. You can redistribute it and/or modify it under the
terms of the MIT License. See the [LICENSE.md](./LICENSE.md) file for more details.
31 changes: 23 additions & 8 deletions lib/chaperon.ex
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,30 @@ defmodule Chaperon do
at the end.

- `lt_mod` LoadTest module to be executed

- `options` List of options to be used. Valid values are:
- `:print_results` If set to `true`, will print all action results.
- `:export` Can be set to any module implementing the `Chaperon.Exporter` behaviour.
Defaults to `Chaperon.Export.CSV`. When using `Chaperon.Export.S3` it defaults to the CSV export format.
You can use another export format by wrapping it in a tuple, like so: `{Chaperon.Export.S3, Chaperon.Export.JSON}`

- `:export` Can be set to any module implementing the `Chaperon.Exporter`
behaviour.

Defaults to `Chaperon.Export.CSV`. When using `Chaperon.Export.S3` it
defaults to the CSV export format.

You can use another export format by wrapping it in a tuple, like so:
`{Chaperon.Export.S3, Chaperon.Export.JSON}`

- `:output` Can be set to a file path

- `:tag` Can be set to be used when using the default export filename.
Allows adding a custom 'tag' string as a prefix to the generated result
output filename.

- `:metrics` Filtering options for metrics
Valid filters:
- (metric) -> boolean
- [metric_type]
- (metric) -> boolean
- [metric_type]

## Example

alias Chaperon.Export.JSON
Expand All @@ -84,13 +95,16 @@ defmodule Chaperon do
# Outputs metrics in JSON format to metrics.json file
Chaperon.run_load_test MyLoadTest, export: JSON, output: "metrics.json"

# Outputs metrics in CCSV format to "results/<date>/MyLoadTest/master-<timestamp>.csv"
# Outputs metrics in CCSV format to
# "results/<date>/MyLoadTest/master-<timestamp>.csv"
Chaperon.run_load_test MyLoadTest, tag: "master"

# Outputs metrics in JSON format to "results/<date>/MyLoadTest/master-<timestamp>.json"
# Outputs metrics in JSON format to
# "results/<date>/MyLoadTest/master-<timestamp>.json"
Chaperon.run_load_test MyLoadTest, export: JSON, tag: "master"

# Tracks only calls in MyScenario (can take any function that returns `true` or `false`)
# Tracks only calls in MyScenario (can take any function that returns
# `true` or `false`)
Chaperon.run_load_test MyLoadTest, tag: "master", metrics: fn
{:call, {MyScenario, _}} ->
true
Expand All @@ -105,6 +119,7 @@ defmodule Chaperon do
:post,
:my_custom_metric
]

"""
def run_load_test(lt_mod, options \\ []) do
timeout = Chaperon.LoadTest.timeout(lt_mod)
Expand Down
2 changes: 1 addition & 1 deletion lib/chaperon/action/websocket.ex
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ defmodule Chaperon.Action.WebSocket do
Returns a `Chaperon.WebSocket.SendMessage` action with a given `message` and
`options`.
"""
@spec send(any(), Keword.t()) :: %WebSocket.SendMessage{}
@spec send(any(), Keyword.t()) :: %WebSocket.SendMessage{}
def send(message, options \\ []) do
%WebSocket.SendMessage{
message: message,
Expand Down
2 changes: 1 addition & 1 deletion lib/chaperon/action/websocket/client.ex
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ defmodule Chaperon.Action.WebSocket.Client do
end

def recv_message(pid, timeout \\ nil) do
# ask for next frame frmo WebSockex process and then await response
# ask for next frame from WebSockex process and then await response
send(pid, {:next_frame, self()})

case timeout do
Expand Down
5 changes: 3 additions & 2 deletions lib/chaperon/scenario.ex
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ defmodule Chaperon.Scenario do
next scenario in the list. Makes it easy to define a new scenario as a
pipeline of a list of existing scenarios.

Example usage:
## Example

alias Chaperon.Scenario
alias MyScenarios.{A, B, C}
Expand All @@ -54,6 +54,7 @@ defmodule Chaperon.Scenario do
Scenario.Sequence,
Scenario.Sequence.config_for([A, B, C])
)

"""

alias Chaperon.Session
Expand Down Expand Up @@ -233,7 +234,7 @@ defmodule Chaperon.Scenario do

@doc """
Cleans up any resources after the Scenario was run (if needed).
Can be overriden.
Can be overridden.

If `scenario`'s implementation module defines a `teardown/1` callback function,
calls it with `session` to clean up resources as needed.
Expand Down
44 changes: 22 additions & 22 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
defmodule Chaperon.Mixfile do
use Mix.Project

@source_url "https://github.com/polleverywhere/chaperon"
@version "0.3.1"

def project do
[
app: :chaperon,
version: "0.3.1",
version: @version,
elixir: "~> 1.6",
build_embedded: Mix.env() == :prod,
start_permanent: Mix.env() == :prod,
deps: deps(),
docs: docs(),
package: package(),
description: "An Elixir based HTTP load & performance testing framework",
dialyzer: [
plt_add_deps: :apps_direct,
plt_add_apps: [
Expand All @@ -26,17 +29,9 @@ defmodule Chaperon.Mixfile do
# skip unkown function warnings
remove_defaults: [:unknown]
],
# docs
source_url: "https://github.com/polleverywhere/chaperon",
docs: [
extras: ["README.md"]
]
]
end

# Configuration for the OTP application
#
# Type "mix help compile.app" for more information
def application do
[
extra_applications: [
Expand All @@ -49,34 +44,26 @@ defmodule Chaperon.Mixfile do

defp package do
[
description: "An Elixir based HTTP load & performance testing framework",
name: "chaperon",
files: [
"lib",
"docs",
"examples",
"mix.exs",
"README*",
"LICENSE"
"LICENSE.md"
],
maintainers: [
"Christopher Bertels"
],
licenses: ["MIT"],
links: %{
"GitHub" => "https://github.com/polleverywhere/chaperon"
"GitHub" => @source_url
}
]
end

# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
#
# Or git/path repositories:
#
# {:mydep, git: "https://github.com/elixir-lang/mydep.git", tag: "0.1.0"}
#
# Type "mix help deps" for more examples and options
defp deps do
[
{:httpoison, "~> 1.5"},
Expand All @@ -94,8 +81,21 @@ defmodule Chaperon.Mixfile do
{:ex_aws, "~> 2.0"},
{:ex_aws_s3, "~> 2.0"},
{:dialyxir, "~> 0.5", only: [:dev], runtime: false},
{:ex_doc, "~> 0.21.1", only: :dev},
{:ex_doc, ">= 0.0.0", only: :dev, runtime: false},
{:credo, "~> 1.1", only: [:dev, :test], runtime: false}
]
end

defp docs do
[
extras: [
"LICENSE.md": [title: "License"],
"README.md": [title: "Overview"],
],
main: "readme",
source_url: @source_url,
source_ref: "v#{@version}",
formatters: ["html"]
]
end
end
Loading