Skip to content

Commit

Permalink
First packaged basho_bench
Browse files Browse the repository at this point in the history
Through the effort to make smaller package, several changes to the
code and dependent modules were done:

- dependent modules updated; lager, mochiweb and getopt
- some dependent modules removed; erlcql, velvet, casbench
- deprecate R15

Andalso, there are some kludge to enable package install with node_package;

- not using escriptize but just a proxy script installed
- unnecessary directories like log, data created
- unnecessary user and group named basho-bench created for this
- not pinning dependent module versions yet
  • Loading branch information
kuenishi committed Nov 6, 2014
1 parent cde4190 commit 02da072
Show file tree
Hide file tree
Showing 14 changed files with 187 additions and 300 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
ebin/
deps/
tests/
basho_bench
/basho_bench
/rel/basho_bench
package
.rebar
*~
#*#

12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@ REPO ?= basho_bench

PKG_REVISION ?= $(shell git describe --tags)
PKG_VERSION ?= $(shell git describe --tags | tr - .)
PKG_ID = bashobench-$(PKG_VERSION)
PKG_ID = basho-bench-$(PKG_VERSION)
PKG_BUILD = 1
BASE_DIR = $(shell pwd)
ERLANG_BIN = $(shell dirname $(shell which erl))
REBAR ?= $(BASE_DIR)/rebar
OVERLAY_VARS ?=


.PHONY: deps

rel: deps compile
./rebar skip_deps=true escriptize

all: deps compile
./rebar skip_deps=true escriptize

.PHONY: deps compile rel

rel: deps compile
cd rel && ../rebar generate skip_deps=true $(OVERLAY_VARS)

deps:
./rebar get-deps

Expand Down
16 changes: 8 additions & 8 deletions pkg.vars.config
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,21 @@
%%
%% Packaging
%%
{package_name, "bashobench"}.
{package_install_name, "bashobench"}.
{package_install_user, "bashobench"}.
{package_install_group, "bashobench"}.
{package_name, "basho-bench"}.
{package_install_name, "basho_bench"}.
{package_install_user, "basho-bench"}.
{package_install_group, "basho-bench"}.
{package_install_user_desc, "Basho-bench user"}.
{package_shortdesc, "Bashobench benchmarking tool"}.
{package_shortdesc, "Basho benchmarking tool"}.
{package_desc, "Benchmarking tool"}.
{package_commands, {list, [[{name, "bashobench"}]]}}.
{package_commands, {list, [[{name, "basho_bench"}]]}}.
{package_patch_dir, "basho-patches"}.
{bin_or_sbin, "bin"}.
{license_type, "OSS"}.
{copyright, "2013 Basho Technologies, Inc"}.
{copyright, "2014 Basho Technologies, Inc"}.
{vendor_name, "Basho Technologies, Inc"}.
{vendor_url, "http://basho.com"}.
{vendor_contact_name, "Basho Package Maintainer"}.
{vendor_contact_email, "packaging@basho.com"}.
{license_full_text, "This software is provided under license from Basho Technologies."}.
{solaris_pkgname, "BASHObashobench"}.
{solaris_pkgname, "BASHObasho-bench"}.
22 changes: 7 additions & 15 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{require_otp_vsn, "R16|17"}.

{deps,
[
Expand All @@ -8,32 +9,23 @@
%% increments. If someone wants to take advantage of a
%% new folsom feature, that desire + float incr must be
%% weighed.
{node_package, "1.2.2", {git, "git://github.com/basho/node_package", {tag, "1.2.2"}}},
{node_package, "2.0.*", {git, "git://github.com/basho/node_package", {tag, "2.0.0"}}},
{folsom, ".*", {git, "git://github.com/basho/folsom.git", {branch, "boundary-0.7.1+basho-bench-float"}}},
{lager, "2.*", {git, "git://github.com/basho/lager", {tag, "2.0.3"}}},
{lager, "2.*", {git, "git://github.com/basho/lager", {tag, "2.1.0"}}},
{ibrowse, ".*",
{git, "git://github.com/cmullaparthi/ibrowse.git", {tag, "v3.0.4"}}},
{casbench, "0.1",
{git, "git://github.com/basho/casbench",
"95ed55b494551577870984aeb1e0f683631a326f"}},
{erlcql, ".*",
{git, "git://github.com/rpt/erlcql.git",
{branch, "master"}}},
{riakc, ".*",
{git, "git://github.com/basho/riak-erlang-client", {branch, "develop"}}},
{mochiweb, "1.5.1*",
{git, "git://github.com/basho/mochiweb", {tag, "1.5.1p6"}}},
{velvet, "1.*",
{git, "git://github.com/basho/velvet",
"4bb0fd664ff065c4082ca8dd2e0683e920537d15"}},
{mochiweb, "2.9.*",
{git, "git://github.com/basho/mochiweb", {tag, "v2.9.0"}}},
{getopt, ".*",
{git, "git://github.com/jcomellas/getopt", {tag, "v0.4"}}}
{git, "git://github.com/jcomellas/getopt", {tag, "v0.8.2"}}}
]}.

{erl_opts, [{src_dirs, [src]},
{parse_transform, lager_transform}]}.

{escript_incl_apps, [node_package, lager, getopt, bear, folsom, ibrowse, riakc, mochiweb, protobuffs, velvet, goldrush]}.
{escript_incl_apps, [node_package, lager, getopt, bear, folsom, ibrowse, riakc, mochiweb, protobuffs, goldrush]}.

{escript_emu_args, "%%! +K true -rsh ssh\n"}.
%% Use this for the Java client bench driver
Expand Down
9 changes: 9 additions & 0 deletions rel/files/basho_bench
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh

# Pull environment for this install
. "{{runner_base_dir}}/lib/env.sh"

# Make sure CWD is set to runner run dir
cd $RUNNER_BASE_DIR/lib/basho_bench*/ebin

ERL_LIBS=$RUNNER_BASE_DIR $ERTS_PATH/escript basho_bench.beam "$@"
44 changes: 44 additions & 0 deletions rel/files/install_upgrade.escript
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env escript
%%! -noshell -noinput
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et

-define(TIMEOUT, 60000).
-define(INFO(Fmt,Args), io:format(Fmt,Args)).

main([NodeName, Cookie, ReleasePackage]) ->
TargetNode = start_distribution(NodeName, Cookie),
{ok, Vsn} = rpc:call(TargetNode, release_handler, unpack_release,
[ReleasePackage], ?TIMEOUT),
?INFO("Unpacked Release ~p~n", [Vsn]),
{ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
check_install_release, [Vsn], ?TIMEOUT),
{ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
install_release, [Vsn], ?TIMEOUT),
?INFO("Installed Release ~p~n", [Vsn]),
ok = rpc:call(TargetNode, release_handler, make_permanent, [Vsn], ?TIMEOUT),
?INFO("Made Release ~p Permanent~n", [Vsn]);
main(_) ->
init:stop(1).

start_distribution(NodeName, Cookie) ->
MyNode = make_script_node(NodeName),
{ok, _Pid} = net_kernel:start([MyNode, shortnames]),
erlang:set_cookie(node(), list_to_atom(Cookie)),
TargetNode = make_target_node(NodeName),
case {net_kernel:hidden_connect_node(TargetNode),
net_adm:ping(TargetNode)} of
{true, pong} ->
ok;
{_, pang} ->
io:format("Node ~p not responding to pings.\n", [TargetNode]),
init:stop(1)
end,
TargetNode.

make_target_node(Node) ->
[_, Host] = string:tokens(atom_to_list(node()), "@"),
list_to_atom(lists:concat([Node, "@", Host])).

make_script_node(Node) ->
list_to_atom(lists:concat([Node, "_upgrader_", os:getpid()])).
19 changes: 19 additions & 0 deletions rel/files/vm.args
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Name of the node
-name healthb@127.0.0.1

## Cookie for distributed erlang
-setcookie healthb

## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
## (Disabled by default..use with caution!)
##-heart

## Enable kernel poll and a few async threads
##+K true
##+A 5

## Increase number of concurrent ports/sockets
##-env ERL_MAX_PORTS 4096

## Tweak GC to run more often
##-env ERL_FULLSWEEP_AFTER 10
63 changes: 63 additions & 0 deletions rel/reltool.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
%% -*- mode: erlang -*-
%% ex: ft=erlang
{sys, [
{lib_dirs, ["../deps"]},
{erts, [{mod_cond, derived}, {app_file, strip}]},
{app_file, strip},
{rel, "basho_bench", "0.10.0",
[
kernel,
stdlib,
bear,
lager,
folsom,
goldrush,
riakc,
ibrowse,
mochiweb
]},
{rel, "start_clean", "",
[
kernel,
stdlib
]},
{boot_rel, "basho_bench"},
{profile, embedded},
{incl_cond, derived},
{excl_archive_filters, [".*"]}, %% Do not archive built libs
{excl_sys_filters, ["^bin/(?!start_clean.boot)",
"^erts.*/bin/(dialyzer|typer)",
"^erts.*/(doc|info|include|lib|man|src)"]},
{excl_app_filters, ["\.gitignore"]},
{app, basho_bench, [{mod_cond, app}, {incl_cond, include}, {lib_dir, ".."}]},
{app, hipe, [{incl_cond, exclude}]}
]}.

{target_dir, "basho_bench"}.
{overlay_vars, "vars.config"}.

{overlay, [
{template, "../deps/node_package/priv/base/env.sh",
"lib/env.sh"},
{mkdir, "data/b_b"},

%% Copy base files for starting and interacting w/ node
{copy, "../deps/node_package/priv/base/erl",
"{{erts_vsn}}/bin/erl"},
{copy, "../deps/node_package/priv/base/nodetool",
"{{erts_vsn}}/bin/nodetool"},
{template, "../deps/node_package/priv/base/env.sh",
"lib/env.sh"},
{copy, "files/vm.args", "etc/vm.args"},

{template, "files/basho_bench", "bin/basho_bench"},

{copy, "../examples/cs.config.sample", "etc/cs.config"},
{copy, "../examples/riakc_pb.config", "etc/riakc_pb.config"},
{copy, "../examples/httpraw.config", "etc/httpraw.config"},
{copy, "../examples/http.config", "etc/http.config"},
{copy, "../examples/null_test.config", "etc/null_test.config"}

%%{copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"},

]}.
20 changes: 20 additions & 0 deletions rel/vars.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ts=4 sw=4 et

%% Platform-specific installation paths
{platform_bin_dir, "./bin"}.
{platform_data_dir, "./data"}.
{platform_etc_dir, "./etc"}.
{platform_lib_dir, "./lib"}.
{platform_log_dir, "./log"}.

%%
{data_dir, "{{target_dir}}/data"}.
{runner_script_dir, "\`cd \\`dirname $0\\` && /bin/pwd\`"}.
{runner_base_dir, "{{runner_script_dir}}/.."}.
{runner_etc_dir, "$RUNNER_BASE_DIR/etc"}.
{runner_log_dir, "$RUNNER_BASE_DIR/log"}.
{runner_lib_dir, "$RUNNER_BASE_DIR/lib"}.
{runner_patch_dir, "$RUNNER_BASE_DIR/lib/basho-patches"}.
{pipe_dir, "/tmp/$RUNNER_BASE_DIR/"}.
{runner_user, ""}.
2 changes: 1 addition & 1 deletion src/basho_bench.app.src
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{application, basho_bench,
[{description, "Riak Benchmarking Suite"},
{vsn, "0.9"},
{vsn, git},
{modules, []},
{registered, [ basho_bench_sup ]},
{applications, [kernel,
Expand Down
2 changes: 1 addition & 1 deletion src/basho_bench.erl
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ setup_distributed_work() ->
[pool:attach(SlaveName) || SlaveName <- SlaveNames],
CodePaths = code:get_path(),
rpc:multicall(SlaveNames, code, set_path, [CodePaths]),
Apps = [lager, basho_bench, getopt, bear, folsom, ibrowse, riakc, riak_pb, mochiweb, protobuffs, velvet, goldrush],
Apps = [lager, basho_bench, getopt, bear, folsom, ibrowse, riakc, riak_pb, mochiweb, protobuffs, goldrush],
[distribute_app(App) || App <- Apps].


Expand Down
Loading

0 comments on commit 02da072

Please sign in to comment.