riak_test/tests/pipe_verify_examples.erl
Alex Berghage 5c5931b567 Added explicit wait_for_service riak_pipe on pipe* tests...
... which didn't call the 2-arity version of deploy_nodes. NB
the /2 version implicitly waits on whatever services are specified.
2015-04-06 10:36:06 -05:00

61 lines
2.0 KiB
Erlang

%% -------------------------------------------------------------------
%%
%% Copyright (c) 2012 Basho Technologies, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License. You may obtain
%% a copy of the License at
%%
%% http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied. See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%% -------------------------------------------------------------------
%% @doc Verify that the riak_pipe example use functions work.
-module(pipe_verify_examples).
-export([confirm/0]).
-include_lib("eunit/include/eunit.hrl").
-define(NODE_COUNT, 3).
confirm() ->
lager:info("Build ~b node cluster", [?NODE_COUNT]),
Nodes = rt:build_cluster(?NODE_COUNT),
[rt:wait_for_service(Node, riak_pipe) || Node <- Nodes],
verify_example(Nodes),
verify_example_transform(Nodes),
verify_example_reduce(Nodes),
rt_pipe:assert_no_zombies(Nodes),
lager:info("~s: PASS", [atom_to_list(?MODULE)]),
pass.
verify_example([RN|_]) ->
lager:info("Run riak_pipe:example/0"),
?assertMatch({eoi, [{empty_pass, "hello"}], _Trc},
rpc:call(RN, riak_pipe, example, [])).
verify_example_transform([RN|_]) ->
lager:info("Run riak_pipe:example_transform/0"),
?assertEqual({eoi, [{"generic transform", 55}], []},
rpc:call(RN, riak_pipe, example_transform, [])).
verify_example_reduce([RN|_]) ->
lager:info("Run riak_pipe:example_reduce/0"),
{eoi, Res, []} = rpc:call(RN, riak_pipe, example_reduce, []),
?assertEqual([{"sum reduce", {a, [55]}},
{"sum reduce", {b, [155]}}],
lists:sort(Res)).