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

Added unit tests (in branch riak_core_3) #8

Open
wants to merge 4 commits into
base: riak_core_3
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
23 changes: 23 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
language: elixir

matrix:
include:
- elixir: 1.4.5
otp_release: 18.3
- elixir: 1.4.5
otp_release: 19.3
- elixir: 1.5.2
otp_release: 18.3
- elixir: 1.5.2
otp_release: 19.3
- elixir: 1.5.2
otp_release: 20.3
- elixir: 1.6.5
otp_release: 20.3
- elixir: 1.6.5
otp_release: 21.0

env:
- MIX_ENV=test
script:
- mix test --no-start
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[![Build Status](https://travis-ci.org/pmenhart/no_slides.svg??branch=riak_core_3)](https://travis-ci.org/pmenhart/no_slides)


# NoSlides example application

Example application for the talk at [NoSlidesConf][0]. This application is a sample application with some functionalities available on riak_core.

## Erlang, Elixir, Rebar3 version

On this branch I start to use [asdf][4] and as you can find [here](./.tool-versions) I compile everything with:

```
Expand All @@ -22,6 +26,26 @@ mix deps.get
mix compile
```

Run the unit test that executes the riak_core ring onseveral slave nodes in a cluster. Nodes are configured in `config/test.exs`. To prevent running RiakCore on the master node (which is harmless, but clutters the logs), invoke with:
```shell
mix test --no-start
```

### Comments on Erlang/Elixir compatibility
(pmenhart, 2018-06-05) Hack to make the project working with erlang 20.3.6 and elixir 1.6.5:
* After `mix deps.get`, I had to comment out "warnings_as_errors" in `deps/riak_ensemble/rebar.config` and in `deps/riak_core/rebar.config`.
* Note this project is using `{:riak_core, "~> 3.0.9", hex: :riak_core_ng}`. Later riak_core_ng commits introduced gen_fsm_compat, which fails
with newer Elixir+rebar3 because of "missing erl_vsn" issue: rebar_erl_vsn is a pre-compile hook in rebar.config of gen_fsm_compat and few other projects.
Error seems to be caused by Mix not handling rebar3 hooks properly. See e.g. https://github.com/elixir-lang/elixir/issues/7733 and https://github.com/Kyorai/riak_core/issues/23
* This issue is not specific to erl_vsn. For example, the forked https://github.com/gpad/cuttlefish (as used in mix.exs here) differs from the official version only by rebar.config commenting out:
```
% {provider_hooks, [{post, [{compile, {default, escriptize}}]}]}.
```

(pmenhart, 2018-07-11) Rebar3 was fixed, use version 3.6.1 or up.
`{:riak_core, "~> 3.1.1", hex: :riak_core_ng}` compiles (with gen_fsm_compat) without problems mentioned above.
However, the forked version of cuttlefish is still needed.

## How to start a single node
If you want run a single node you can execute in this way:

Expand Down
8 changes: 8 additions & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
use Mix.Config

config :no_slides,
nodes: [
{"[email protected]", 8198, 8199},
{"[email protected]", 8298, 8299},
{"[email protected]", 8398, 8399}
]
1 change: 1 addition & 0 deletions lib/no_slides/coverage_fsm.ex
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ defmodule NoSlides.CoverageFsm do
NoSlides.Service,
NoSlides.VNode_master,
timeout,
:riak_core_coverage_plan, # specific for riak_core_ng
%{from: from, req_id: req_id, args: args}
}
end
Expand Down
2 changes: 1 addition & 1 deletion lib/no_slides/get_fsm_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule NoSlides.GetFsmSupervisor do
Supervisor.start_link(__MODULE__, [], [name: __MODULE__])
end

def init(arg) do
def init(_arg) do
children = [
worker(NoSlides.GetFsm, [], restart: :temporary)
]
Expand Down
10 changes: 5 additions & 5 deletions lib/no_slides/service.ex
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ defmodule NoSlides.Service do
end
end

def ring_status() do
{:ok, ring} = :riak_core_ring_manager.get_my_ring
:riak_core_ring.pretty_print(ring, [:legend])
end

def keys do
req_id = NoSlides.CoverageFsmSupervisor.start_fsm(:keys)
wait_result(req_id)
Expand All @@ -84,6 +79,11 @@ defmodule NoSlides.Service do
wait_result(req_id)
end

def clear do
req_id = NoSlides.CoverageFsmSupervisor.start_fsm(:clear)
wait_result(req_id)
end

defp wait_result(req_id, timeout\\5000) do
receive do
{^req_id, {:ok, keys}} ->
Expand Down
6 changes: 6 additions & 0 deletions lib/no_slides/v_node.ex
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,12 @@ defmodule NoSlides.VNode do
{:reply, {ref_id, Map.values(state.data)}, state}
end

def handle_coverage({:clear, _, _} = req, _key_spaces, {_, ref_id, _} = sender, state) do
Logger.debug "[handle_coverage] VNODE req: #{inspect req} sender: #{inspect sender}"
new_state = Map.put(state, :data, %{})
{:reply, {ref_id, %{}}, new_state}
end

def handle_exit(pid, reason, state) do
Logger.debug "[handle_exit] self: #{inspect self()} - pid: #{inspect pid} - reason: #{inspect reason} - state: #{inspect state}"
{:noreply, state}
Expand Down
2 changes: 1 addition & 1 deletion lib/no_slides/write_fsm_supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defmodule NoSlides.WriteFsmSupervisor do
Supervisor.start_link(__MODULE__, [], [name: __MODULE__])
end

def init(arg) do
def init(_arg) do
children = [
worker(NoSlides.WriteFsm, [], restart: :temporary)
]
Expand Down
7 changes: 6 additions & 1 deletion mix.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ defmodule NoSlides.Mixfile do
[app: :no_slides,
version: "0.1.0",
elixir: "~> 1.3",
elixirc_paths: elixirc_paths(Mix.env),
build_embedded: Mix.env == :prod,
start_permanent: Mix.env == :prod,
deps: deps()]
Expand All @@ -18,6 +19,10 @@ defmodule NoSlides.Mixfile do
mod: {NoSlides, []}]
end

# Specifies which paths to compile per environment.
defp elixirc_paths(:test), do: ["lib", "test/support"]
defp elixirc_paths(_), do: ["lib"]

# Dependencies can be Hex packages:
#
# {:mydep, "~> 0.3.0"}
Expand All @@ -29,7 +34,7 @@ defmodule NoSlides.Mixfile do
# Type "mix help deps" for more examples and options
defp deps do
[
{:riak_core, "~> 3.0.9", hex: :riak_core_ng},
{:riak_core, "~> 3.1.1", hex: :riak_core_ng},
{:cuttlefish, git: "https://github.com/gpad/cuttlefish", branch: "develop", override: true},
{:poolboy, "~> 1.5.1", override: true},
]
Expand Down
23 changes: 13 additions & 10 deletions mix.lock
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
%{"basho_stats": {:hex, :basho_stats, "1.0.3", "7e1174151509c64fcc1934120ed32295e14f84daae7f84926ba2c8d3700d146c", [:rebar3], [], "hexpm"},
"bear": {:hex, :bear, "0.8.5", "e95fca1627cd9e15baf93ce0a52aff16917baf325f0ee65b88cd715376cd2344", [:rebar3], [], "hexpm"},
%{
"basho_stats": {:hex, :basho_stats, "1.0.3", "7e1174151509c64fcc1934120ed32295e14f84daae7f84926ba2c8d3700d146c", [:rebar3], [], "hexpm"},
"bear": {:hex, :bear, "0.8.7", "16264309ae5d005d03718a5c82641fcc259c9e8f09adeb6fd79ca4271168656f", [:rebar3], [], "hexpm"},
"blume": {:hex, :blume, "0.1.1", "cfb4f43688690ba81c6a79f54e4678cfd5fdedab692f277ae740ae4a3897360d", [:rebar3], [], "hexpm"},
"chash": {:hex, :chash, "0.1.2", "af02484f2640c653c4b9a8557a14ca0704989dbedb27e7ccbc442f1903a3bca7", [:rebar3], [], "hexpm"},
"clique": {:hex, :clique, "0.3.10", "29ecba7ec61ded866197164d33f61d1cbf892ed85fc933673d7e50d0689d34fb", [:rebar3], [{:cuttlefish, "~>2.0.12", [hex: :cuttlefish, repo: "hexpm", optional: false]}], "hexpm"},
"clique": {:hex, :clique, "0.3.12", "3d8d5ca3c60787ad13562bea18d34149ba8915ad08214ede91d50657198b4dc3", [:rebar3], [{:cuttlefish, "~>2.1.0", [hex: :cuttlefish, repo: "hexpm", optional: false]}], "hexpm"},
"cuttlefish": {:git, "https://github.com/gpad/cuttlefish", "674619a3e0ff3915209137d2216d9b279f723ebe", [branch: "develop"]},
"edown": {:hex, :edown, "0.8.1", "7333b6f6b7bbc736c263e9ceb8261667d7c8f7d92e251829f1a9fe8f24e7b694", [:rebar3], [], "hexpm"},
"eleveldb": {:hex, :eleveldb, "2.2.20", "1fff63a5055bbf4bf821f797ef76065882b193f5e8095f95fcd9287187773b58", [:rebar3], [], "hexpm"},
"exometer_core": {:hex, :basho_exometer_core, "1.0.2", "dc4bc9b0b47edee0c053b16ac5b9c692e662c7e1513ffc96f4d928bc3328d65f", [:rebar3], [{:folsom, "~>0.8.3", [hex: :folsom, repo: "hexpm", optional: false]}, {:lager, "~>3.2.0", [hex: :lager, repo: "hexpm", optional: false]}, {:parse_trans, "~>2.9.0", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:setup, "~>1.7.0", [hex: :setup, repo: "hexpm", optional: false]}], "hexpm"},
"folsom": {:hex, :folsom, "0.8.5", "94a027b56fe84feed264f9b33cb4c6ac9a801fad84b87dbda0836ce83c3b8d69", [:rebar3], [{:bear, "0.8.5", [hex: :bear, repo: "hexpm", optional: false]}], "hexpm"},
"exometer_core": {:hex, :basho_exometer_core, "1.0.3", "e801bc203558d75645529b55429c4f3d161073a4332a020570bcadd35ddcc279", [:rebar3], [{:folsom, "~>0.8.3", [hex: :folsom, repo: "hexpm", optional: false]}, {:lager, "~>3.6.0", [hex: :lager, repo: "hexpm", optional: false]}, {:parse_trans, "~>2.9.0", [hex: :parse_trans, repo: "hexpm", optional: false]}, {:setup, "~>1.7.0", [hex: :setup, repo: "hexpm", optional: false]}], "hexpm"},
"folsom": {:hex, :folsom, "0.8.7", "a885f0aeee4c84270954c88a55a5a473d6b2c7493e32ffdc5765412dd555a951", [:rebar3], [{:bear, "0.8.7", [hex: :bear, repo: "hexpm", optional: false]}], "hexpm"},
"gen_fsm_compat": {:hex, :gen_fsm_compat, "0.3.0", "5903549f67d595f58a7101154cbe0fdd46955fbfbe40813f1e53c23a970ff5f4", [:rebar3], [], "hexpm"},
"getopt": {:hex, :getopt, "1.0.1", "c73a9fa687b217f2ff79f68a3b637711bb1936e712b521d8ce466b29cbf7808a", [:rebar3], [], "hexpm"},
"goldrush": {:hex, :goldrush, "0.1.9", "f06e5d5f1277da5c413e84d5a2924174182fb108dabb39d5ec548b27424cd106", [:rebar3], [], "hexpm"},
"jam": {:hex, :jam, "1.0.0", "ed9b180f2f3a775e6a47ac490954976802f0638c19a393f3e86d4ba4cf890582", [:rebar3], [], "hexpm"},
"lager": {:hex, :lager, "3.2.4", "a6deb74dae7927f46bd13255268308ef03eb206ec784a94eaf7c1c0f3b811615", [:rebar3], [{:goldrush, "0.1.9", [hex: :goldrush, repo: "hexpm", optional: false]}], "hexpm"},
"lager": {:hex, :lager, "3.6.3", "fe78951d174616273f87f0dbc3374d1430b1952e5efc4e1c995592d30a207294", [:rebar3], [{:goldrush, "0.1.9", [hex: :goldrush, repo: "hexpm", optional: false]}], "hexpm"},
"parse_trans": {:hex, :parse_trans, "2.9.0", "3f5f7b402928fb9fd200c891e635de909045d1efac40ce3f924d3892898f85eb", [:rebar], [{:edown, "> 0.0.0", [hex: :edown, repo: "hexpm", optional: false]}], "hexpm"},
"pbkdf2": {:hex, :pbkdf2, "2.0.0", "11c23279fded5c0027ab3996cfae77805521d7ef4babde2bd7ec04a9086cf499", [:rebar3], [], "hexpm"},
"poolboy": {:hex, :poolboy, "1.5.1", "6b46163901cfd0a1b43d692657ed9d7e599853b3b21b95ae5ae0a777cf9b6ca8", [:rebar], [], "hexpm"},
"riak_core": {:hex, :riak_core_ng, "3.0.9", "f6e27fb67c9cb9a3fb7aef38ec1bb5633624d7b78e32e73fe7a0045f3514f032", [:rebar3], [{:basho_stats, "~>1.0.3", [hex: :basho_stats, repo: "hexpm", optional: false]}, {:blume, "~>0.1.0", [hex: :blume, repo: "hexpm", optional: false]}, {:chash, "~>0.1.1", [hex: :chash, repo: "hexpm", optional: false]}, {:clique, "~>0.3.9", [hex: :clique, repo: "hexpm", optional: false]}, {:cuttlefish, "~>2.0.12", [hex: :cuttlefish, repo: "hexpm", optional: false]}, {:eleveldb, "~>2.2.20", [hex: :eleveldb, repo: "hexpm", optional: false]}, {:exometer_core, "~>1.0.2", [hex: :basho_exometer_core, repo: "hexpm", optional: false]}, {:folsom, "~>0.8.5", [hex: :folsom, repo: "hexpm", optional: false]}, {:goldrush, "~>0.1.8", [hex: :goldrush, repo: "hexpm", optional: false]}, {:jam, "~>1.0.0", [hex: :jam, repo: "hexpm", optional: false]}, {:lager, "~>3.2.4", [hex: :lager, repo: "hexpm", optional: false]}, {:pbkdf2, "~>2.0.0", [hex: :pbkdf2, repo: "hexpm", optional: false]}, {:poolboy, "~>0.8.2", [hex: :basho_poolboy, repo: "hexpm", optional: false]}, {:riak_ensemble, "~>2.4.0", [hex: :riak_ensemble_ng, repo: "hexpm", optional: false]}, {:riak_sysmon, "~>2.1.3", [hex: :riak_sysmon, repo: "hexpm", optional: false]}], "hexpm"},
"riak_ensemble": {:hex, :riak_ensemble_ng, "2.4.0", "6570463bf09f1200c003de298c5d6615c418d3bf0a2df5caf469a9df2558059a", [:rebar3], [{:lager, "~>3.2.1", [hex: :lager, repo: "hexpm", optional: false]}], "hexpm"},
"riak_sysmon": {:hex, :riak_sysmon, "2.1.5", "2331bbcaebe73ea7b2449f4c765827142476cc73d7d86999b4209ee005694d6b", [:rebar3], [], "hexpm"},
"setup": {:hex, :setup, "1.7.0", "15df8e57c6df9755e22bfb1aef0c640bd97e9889396fdfb2a85a5536a9043674", [:rebar3], [], "hexpm"}}
"riak_core": {:hex, :riak_core_ng, "3.1.1", "098ceef293f9f232e724dd8745916f2e4ce0f14cb8edd1653e8425a14f0dd0b6", [:rebar3], [{:basho_stats, "~>1.0.3", [hex: :basho_stats, repo: "hexpm", optional: false]}, {:blume, "~>0.1.0", [hex: :blume, repo: "hexpm", optional: false]}, {:chash, "~>0.1.1", [hex: :chash, repo: "hexpm", optional: false]}, {:clique, "~>0.3.11", [hex: :clique, repo: "hexpm", optional: false]}, {:cuttlefish, "~>2.1.4", [hex: :cuttlefish, repo: "hexpm", optional: false]}, {:eleveldb, "~>2.2.20", [hex: :eleveldb, repo: "hexpm", optional: false]}, {:exometer_core, "~>1.0.3", [hex: :basho_exometer_core, repo: "hexpm", optional: false]}, {:folsom, "~>0.8.7", [hex: :folsom, repo: "hexpm", optional: false]}, {:gen_fsm_compat, "~>0.3.0", [hex: :gen_fsm_compat, repo: "hexpm", optional: false]}, {:goldrush, "~>0.1.8", [hex: :goldrush, repo: "hexpm", optional: false]}, {:lager, "~>3.6.0", [hex: :lager, repo: "hexpm", optional: false]}, {:pbkdf2, "~>2.0.0", [hex: :pbkdf2, repo: "hexpm", optional: false]}, {:poolboy, "~>0.8.4", [hex: :basho_poolboy, repo: "hexpm", optional: false]}, {:riak_ensemble, "~>2.4.4", [hex: :riak_ensemble_ng, repo: "hexpm", optional: false]}, {:riak_sysmon, "~>2.1.7", [hex: :riak_sysmon, repo: "hexpm", optional: false]}], "hexpm"},
"riak_ensemble": {:hex, :riak_ensemble_ng, "2.4.4", "f9e04052f4a7faad20f008dff18d34d3552513000410ce9c5941b4f7361741e8", [:rebar3], [{:gen_fsm_compat, "~>0.3.0", [hex: :gen_fsm_compat, repo: "hexpm", optional: false]}, {:lager, "~>3.6.0", [hex: :lager, repo: "hexpm", optional: false]}], "hexpm"},
"riak_sysmon": {:hex, :riak_sysmon, "2.1.7", "af420df0f7569e1f12bcd465745164cb6189eb93f118d5cdb3f90feb3f8bf47d", [:rebar3], [{:lager, "~>3.6.0", [hex: :lager, repo: "hexpm", optional: false]}], "hexpm"},
"setup": {:hex, :setup, "1.7.0", "15df8e57c6df9755e22bfb1aef0c640bd97e9889396fdfb2a85a5536a9043674", [:rebar3], [], "hexpm"},
}
Loading