Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

MB-100: provide api for testrunner for messing with memcached

I.e. because it currently relies on ns_port_sup which is now dead.

This also creates special erlang module explicitly dedicated for all
kinds of tricks testrunner or any other testsuite wishes to perform on
guts of ns_server. But in a clean, controlled and explicitly
ns_server-supported way.

Change-Id: I8f3597f1e9f681f6df481be55f8f2b9f3f70f570
Reviewed-on: http://review.couchbase.org/25475
Tested-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
Reviewed-by: Aliaksey Kandratsenka <alkondratenko@gmail.com>
  • Loading branch information...
commit 414e30498e530753d3ebec9e50e551b19533a1ba 1 parent 759135b
@alk alk authored alk committed
View
8 deps/ns_babysitter/src/ns_child_ports_sup.erl
@@ -23,7 +23,7 @@
-export([init/1, launch_port/1, terminate_port/1,
restart_port/1, restart_port_by_name/1,
- current_ports/0]).
+ current_ports/0, find_port/1]).
-include("ns_common.hrl").
@@ -42,11 +42,15 @@ send_command(PortName, Command) ->
{T, E}
end.
-do_send_command(PortName, Command) ->
+find_port(PortName) ->
Childs = supervisor:which_children(?MODULE),
[Pid] = [Pid || {{Name, _, _, _}, Pid, _, _} <- Childs,
Pid =/= undefined,
Name =:= PortName],
+ Pid.
+
+do_send_command(PortName, Command) ->
+ Pid = find_port(PortName),
Pid ! {send_to_port, Command}.
-spec set_dynamic_children([any()]) -> pid().
View
21 src/ns_server_testrunner_api.erl
@@ -0,0 +1,21 @@
+-module(ns_server_testrunner_api).
+
+-compile(export_all).
+
+restart_memcached(Timeout) ->
+ {ok, _} = rpc:call(ns_server:get_babysitter_node(), ns_child_ports_sup, restart_port_by_name, [memcached], Timeout).
+
+kill_memcached(Timeout) ->
+ Pid = rpc:call(ns_server:get_babysitter_node(), ns_child_ports_sup, find_port, [memcached]),
+ Pid ! {send_to_port, <<"die!\n">>},
+ ok = misc:wait_for_process(Pid, Timeout).
+
+eval_string(String) ->
+ {value, Value, _} = eshell:eval(String, erl_eval:new_bindings()),
+ Value.
+
+%% without this API we're forced to rpc call into erlang:apply and
+%% pass erl_eval-wrapped function literals which doesn't work across
+%% different erlang versions
+eval_string_multi(String, Nodes, Timeout) ->
+ rpc:call(Nodes, ns_server_testrunner_api, eval_string, String, Timeout).
Please sign in to comment.
Something went wrong with that request. Please try again.