2012-10-10 22:14:06 +00:00
|
|
|
%% -------------------------------------------------------------------
|
|
|
|
%%
|
|
|
|
%% 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.
|
|
|
|
%%
|
|
|
|
%% -------------------------------------------------------------------
|
2012-08-24 14:08:04 +00:00
|
|
|
-module(riaknostic_rt).
|
2012-09-07 23:49:36 +00:00
|
|
|
-export([confirm/0]).
|
2012-08-31 14:53:05 +00:00
|
|
|
-include_lib("eunit/include/eunit.hrl").
|
2012-08-24 14:08:04 +00:00
|
|
|
|
|
|
|
%% Change when a new release comes out.
|
|
|
|
-define(RIAKNOSTIC_URL, "https://github.com/basho/riaknostic/downloads/riaknostic-1.0.2.tar.gz").
|
|
|
|
|
2012-09-07 23:49:36 +00:00
|
|
|
confirm() ->
|
2012-08-24 14:08:04 +00:00
|
|
|
%% Build a small cluster
|
|
|
|
[Node1, _Node2] = rt:build_cluster(2, []),
|
|
|
|
|
|
|
|
%% Since we don't have command output matching yet, we'll just
|
|
|
|
%% print it to the console and hope for the best.
|
|
|
|
lager:info("1. Check download message"),
|
2012-08-31 14:53:05 +00:00
|
|
|
{ok, RiaknosticOut1} = rt:admin(Node1, ["diag"]),
|
2012-09-07 23:45:47 +00:00
|
|
|
?assert(rt:str(RiaknosticOut1, "is not present!")),
|
2012-08-31 14:53:05 +00:00
|
|
|
%%dut.cmd_output_match('Riak diagnostics utility is not present')
|
|
|
|
|
2012-08-24 14:08:04 +00:00
|
|
|
%% Install
|
|
|
|
lager:info("2a. Install Riaknostic"),
|
|
|
|
{ok, LibDir} = rpc:call(Node1, application, get_env, [riak_core, platform_lib_dir]),
|
|
|
|
Cmd = io_lib:format("sh -c \"cd ~s && curl -O -L ~s && tar xzf ~s\"", [LibDir, ?RIAKNOSTIC_URL, filename:basename(?RIAKNOSTIC_URL)]),
|
|
|
|
lager:info("Running command: ~s", [Cmd]),
|
|
|
|
lager:debug("~p~n", [rpc:call(Node1, os, cmd, [Cmd])]),
|
|
|
|
|
|
|
|
%% Execute
|
|
|
|
lager:info("2b. Check Riaknostic executes"),
|
2012-08-31 14:53:05 +00:00
|
|
|
{ok, RiaknosticOut2b} = rt:admin(Node1, ["diag"]),
|
2012-09-07 23:45:47 +00:00
|
|
|
?assertNot(rt:str(RiaknosticOut2b, "is not present!")),
|
|
|
|
?assertNot(rt:str(RiaknosticOut2b, "[debug]")),
|
2012-08-24 14:08:04 +00:00
|
|
|
|
|
|
|
%% Check usage message
|
|
|
|
lager:info("3. Run Riaknostic usage message"),
|
2012-08-31 14:53:05 +00:00
|
|
|
{ok, RiaknosticOut3} = rt:admin(Node1, ["diag", "--help"]),
|
2012-09-07 23:45:47 +00:00
|
|
|
?assert(rt:str(RiaknosticOut3, "Usage: riak-admin")),
|
2012-08-24 14:08:04 +00:00
|
|
|
|
|
|
|
%% Check commands list
|
|
|
|
lager:info("4. Run Riaknostic commands list message"),
|
2012-08-31 14:53:05 +00:00
|
|
|
{ok, RiaknosticOut4} = rt:admin(Node1, ["diag", "--list"]),
|
2012-09-07 23:45:47 +00:00
|
|
|
?assert(rt:str(RiaknosticOut4, "Available diagnostic checks")),
|
|
|
|
?assert(rt:str(RiaknosticOut4, " disk ")),
|
|
|
|
?assert(rt:str(RiaknosticOut4, " dumps ")),
|
|
|
|
?assert(rt:str(RiaknosticOut4, " memory_use ")),
|
|
|
|
?assert(rt:str(RiaknosticOut4, " nodes_connected")),
|
|
|
|
?assert(rt:str(RiaknosticOut4, " ring_membership")),
|
|
|
|
?assert(rt:str(RiaknosticOut4, " ring_preflists ")),
|
|
|
|
?assert(rt:str(RiaknosticOut4, " ring_size ")),
|
|
|
|
?assert(rt:str(RiaknosticOut4, " search ")),
|
2012-08-24 14:08:04 +00:00
|
|
|
|
|
|
|
%% Check log levels
|
|
|
|
lager:info("5. Run Riaknostic with a different log level"),
|
2012-08-31 14:53:05 +00:00
|
|
|
{ok, RiaknosticOut5} = rt:admin(Node1, ["diag", "--level", "debug"]),
|
2012-09-07 23:45:47 +00:00
|
|
|
?assert(rt:str(RiaknosticOut5, "[debug]")),
|
2012-08-24 14:08:04 +00:00
|
|
|
|
|
|
|
%% Check node conn failure when stopped
|
|
|
|
lager:info("6. Riaknostic warns of node connection failure when stopped"),
|
|
|
|
rt:stop(Node1),
|
2012-08-31 14:53:05 +00:00
|
|
|
{ok, RiaknosticOut6} = rt:admin(Node1, ["diag"]),
|
2012-09-07 23:45:47 +00:00
|
|
|
?assert(rt:str(RiaknosticOut6, "[warning] Could not connect")),
|
2012-08-24 14:08:04 +00:00
|
|
|
|
|
|
|
%% Check node connection when started
|
|
|
|
lager:info("7. Riaknostic connects to node when running"),
|
|
|
|
rt:start(Node1),
|
2012-08-31 14:53:05 +00:00
|
|
|
{ok, RiaknosticOut7} = rt:admin(Node1, ["diag", "--level", "debug"]),
|
2012-09-07 23:45:47 +00:00
|
|
|
?assert(rt:str(RiaknosticOut7, "[debug] Not connected")),
|
|
|
|
?assert(rt:str(RiaknosticOut7, "[debug] Connected to local Riak node")),
|
2012-08-24 14:08:04 +00:00
|
|
|
|
|
|
|
%% Done!
|
|
|
|
lager:info("Test riaknostic: PASS"),
|
2012-08-31 14:53:05 +00:00
|
|
|
pass.
|