forked from gpad/no_slides
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Test with several slave nodes in a cluster (configured in config/test.exs). To prevent running RiakCore on the master node (harmless, but clutters the logs), invoke with `mix test --no-start` * Fixed a few warnings * Updated riak_core.schema Notes: * Running this project on Elixir 1.6.5 with Erlang 20.3.6. I had to comment out "warnings_as_errors" in `deps/riak_ensemble/rebar.config` and in `deps/riak_core/rebar.config` * This project uses riak_core_ng v3.0.9. 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 elixir-lang/elixir#7733 and Kyorai/riak_core#23 This issue is not specific to erl_vsn: for example, the forked https://github.com/gpad/cuttlefish (see mix.exs) differs from the official version only by rebar.config commenting out: % {provider_hooks, [{post, [{compile, {default, escriptize}}]}]}.
- Loading branch information
Showing
9 changed files
with
360 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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} | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,55 @@ | ||
defmodule NoSlidesTest do | ||
use ExUnit.Case | ||
alias NoSlides.RiakCluster | ||
|
||
doctest NoSlides | ||
|
||
test "the truth" do | ||
assert 1 + 1 == 2 | ||
# "setup_all" is called once per module before any test runs | ||
setup_all do | ||
# start the RiakCore cluster | ||
assert !Node.alive?() | ||
nodeNames = RiakCluster.start_test_nodes() | ||
assert Node.alive?() | ||
IO.inspect Node.list | ||
|
||
#IO.inspect NoSlides.Service.ring_status() # local, meaningless. Fails without RiakCore running, e.g. 'mix test --no-start' | ||
IO.inspect RiakCluster.ring_status(hd(nodeNames)) # remote call | ||
[nodes: nodeNames] | ||
end | ||
|
||
|
||
test "ping different nodes in a RiakCore cluster", context do | ||
nodeNames = context.nodes | ||
:pong = rc_command(hd(nodeNames), :ping) | ||
|
||
for _n <- 1..100 do | ||
i = :rand.uniform(length(nodeNames)) - 1 # index of node to use | ||
:pong = rc_command(Enum.at(nodeNames, i), :ping, [:rand.uniform(100_000_000)]) | ||
end | ||
end | ||
|
||
test "try key-value pairs in a RiakCore cluster", context do | ||
nodeNames = context.nodes | ||
first_node = hd(nodeNames) | ||
|
||
|
||
:ok = rc_command(first_node, :put, [:k1, :v1]) | ||
:ok = rc_command(first_node, :put, [:k2, :v2]) | ||
:ok = rc_command(first_node, :put, [:k3, :v3]) | ||
|
||
# get from any of the nodes | ||
for node <- nodeNames do | ||
:v1 = rc_command(node, :get, [:k1]) | ||
:v2 = rc_command(node, :get, [:k2]) | ||
:v3 = rc_command(node, :get, [:k3]) | ||
nil = rc_command(node, :get, [:k10]) | ||
end | ||
end | ||
|
||
defp rc_command(node, command) do rc_command(node, command, []) end | ||
|
||
defp rc_command(node, command, args) do | ||
:rpc.call(String.to_atom(node), NoSlides.Service, command, args) | ||
end | ||
|
||
end |
Oops, something went wrong.