Skip to content

Commit dcbe3ad

Browse files
committedNov 10, 2014
Merge pull request #145 from basho/ku-node-package-rebased
Node-package integration to build debs and rpms
2 parents 3e330c5 + 8c0b3dc commit dcbe3ad

13 files changed

+246
-18
lines changed
 

‎.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
ebin/
22
deps/
33
tests/
4-
basho_bench
4+
/basho_bench
5+
/rel/basho_bench
6+
package
7+
.rebar
58
*~
69
#*#
710

‎Makefile

+44-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,23 @@
1-
.PHONY: deps
1+
REPO ?= basho_bench
2+
3+
PKG_REVISION ?= $(shell git describe --tags)
4+
PKG_VERSION ?= $(shell git describe --tags | tr - .)
5+
PKG_ID = basho-bench-$(PKG_VERSION)
6+
PKG_BUILD = 1
7+
BASE_DIR = $(shell pwd)
8+
ERLANG_BIN = $(shell dirname $(shell which erl))
9+
REBAR ?= $(BASE_DIR)/rebar
10+
OVERLAY_VARS ?=
11+
212

313
all: deps compile
414
./rebar skip_deps=true escriptize
515

16+
.PHONY: deps compile rel
17+
18+
rel: deps compile
19+
cd rel && ../rebar generate skip_deps=true $(OVERLAY_VARS)
20+
621
deps:
722
./rebar get-deps
823

@@ -33,3 +48,31 @@ JOBS := $(addprefix job,${TARGETS})
3348

3449
all_results: ${JOBS} ; echo "$@ successfully generated."
3550
${JOBS}: job%: ; Rscript --vanilla priv/summary.r -i tests/$*
51+
52+
##
53+
## Packaging targets
54+
##
55+
.PHONY: package
56+
export PKG_VERSION PKG_ID PKG_BUILD BASE_DIR ERLANG_BIN REBAR OVERLAY_VARS RELEASE
57+
58+
package.src: deps
59+
mkdir -p package
60+
rm -rf package/$(PKG_ID)
61+
git archive --format=tar --prefix=$(PKG_ID)/ $(PKG_REVISION)| (cd package && tar -xf -)
62+
${MAKE} -C package/$(PKG_ID) deps
63+
for dep in package/$(PKG_ID)/deps/*; do \
64+
echo "Processing dep: $${dep}"; \
65+
mkdir -p $${dep}/priv; \
66+
git --git-dir=$${dep}/.git describe --always --tags >$${dep}/priv/vsn.git; \
67+
done
68+
find package/$(PKG_ID) -depth -name ".git" -exec rm -rf {} \;
69+
tar -C package -czf package/$(PKG_ID).tar.gz $(PKG_ID)
70+
71+
dist: package.src
72+
cp package/$(PKG_ID).tar.gz .
73+
74+
package: package.src
75+
${MAKE} -C package -f $(PKG_ID)/deps/node_package/Makefile
76+
77+
pkgclean: distclean
78+
rm -rf package

‎pkg.vars.config

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
2+
%% ex: ts=4 sw=4 et
3+
4+
%%
5+
%% Packaging
6+
%%
7+
{package_name, "basho-bench"}.
8+
{package_install_name, "basho_bench"}.
9+
{package_install_user, "basho-bench"}.
10+
{package_install_group, "basho-bench"}.
11+
{package_install_user_desc, "Basho-bench user"}.
12+
{package_shortdesc, "Basho benchmarking tool"}.
13+
{package_desc, "Benchmarking tool"}.
14+
{package_commands, {list, [[{name, "basho_bench"}]]}}.
15+
{package_patch_dir, "basho-patches"}.
16+
{bin_or_sbin, "bin"}.
17+
{license_type, "OSS"}.
18+
{copyright, "2014 Basho Technologies, Inc"}.
19+
{vendor_name, "Basho Technologies, Inc"}.
20+
{vendor_url, "http://basho.com"}.
21+
{vendor_contact_name, "Basho Package Maintainer"}.
22+
{vendor_contact_email, "packaging@basho.com"}.
23+
{license_full_text, "This software is provided under license from Basho Technologies."}.
24+
{solaris_pkgname, "BASHObasho-bench"}.

‎rebar

38.8 KB
Binary file not shown.

‎rebar.config

+12-13
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{require_otp_vsn, "R15|R16|17"}.
12

23
{deps,
34
[
@@ -8,32 +9,30 @@
89
%% increments. If someone wants to take advantage of a
910
%% new folsom feature, that desire + float incr must be
1011
%% weighed.
12+
{node_package, "2.0.*", {git, "git://github.com/basho/node_package", {tag, "2.0.0"}}},
1113
{folsom, ".*", {git, "git://github.com/basho/folsom.git", {branch, "boundary-0.7.1+basho-bench-float"}}},
12-
13-
{lager, "2.*", {git, "git://github.com/basho/lager", {tag, "2.0.3"}}},
14+
{lager, "2.*", {git, "git://github.com/basho/lager", {tag, "2.1.0"}}},
1415
{ibrowse, ".*",
1516
{git, "git://github.com/cmullaparthi/ibrowse.git", {tag, "v3.0.4"}}},
17+
{riakc, ".*",
18+
{git, "git://github.com/basho/riak-erlang-client", {branch, "develop"}}},
19+
{mochiweb, "2.9.*",
20+
{git, "git://github.com/basho/mochiweb", {tag, "v2.9.0"}}},
21+
{getopt, ".*",
22+
{git, "git://github.com/jcomellas/getopt", {tag, "v0.8.2"}}},
23+
1624
{casbench, "0.1",
1725
{git, "git://github.com/basho/casbench",
1826
"95ed55b494551577870984aeb1e0f683631a326f"}},
1927
{erlcql, ".*",
2028
{git, "git://github.com/rpt/erlcql.git",
21-
{branch, "master"}}},
22-
{riakc, ".*",
23-
{git, "git://github.com/basho/riak-erlang-client", {branch, "develop"}}},
24-
{mochiweb, "1.5.1*",
25-
{git, "git://github.com/basho/mochiweb", {tag, "1.5.1p6"}}},
26-
{velvet, "1.*",
27-
{git, "git://github.com/basho/velvet",
28-
"4bb0fd664ff065c4082ca8dd2e0683e920537d15"}},
29-
{getopt, ".*",
30-
{git, "git://github.com/jcomellas/getopt", {tag, "v0.4"}}}
29+
{branch, "master"}}}
3130
]}.
3231

3332
{erl_opts, [{src_dirs, [src]},
3433
{parse_transform, lager_transform}]}.
3534

36-
{escript_incl_apps, [lager, getopt, bear, folsom, ibrowse, riakc, riak_pb, mochiweb, protobuffs, velvet, goldrush]}.
35+
{escript_incl_apps, [node_package, lager, getopt, bear, folsom, ibrowse, riakc, mochiweb, protobuffs, goldrush]}.
3736

3837
{escript_emu_args, "%%! +K true -rsh ssh\n"}.
3938
%% Use this for the Java client bench driver

‎rel/files/basho_bench

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# Pull environment for this install
4+
. "{{runner_base_dir}}/lib/env.sh"
5+
6+
# Make sure CWD is set to runner run dir
7+
cd $RUNNER_BASE_DIR/lib/basho_bench*/ebin
8+
9+
ERL_LIBS=$RUNNER_BASE_DIR $ERTS_PATH/escript basho_bench.beam "$@"

‎rel/files/install_upgrade.escript

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#!/usr/bin/env escript
2+
%%! -noshell -noinput
3+
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
4+
%% ex: ft=erlang ts=4 sw=4 et
5+
6+
-define(TIMEOUT, 60000).
7+
-define(INFO(Fmt,Args), io:format(Fmt,Args)).
8+
9+
main([NodeName, Cookie, ReleasePackage]) ->
10+
TargetNode = start_distribution(NodeName, Cookie),
11+
{ok, Vsn} = rpc:call(TargetNode, release_handler, unpack_release,
12+
[ReleasePackage], ?TIMEOUT),
13+
?INFO("Unpacked Release ~p~n", [Vsn]),
14+
{ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
15+
check_install_release, [Vsn], ?TIMEOUT),
16+
{ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
17+
install_release, [Vsn], ?TIMEOUT),
18+
?INFO("Installed Release ~p~n", [Vsn]),
19+
ok = rpc:call(TargetNode, release_handler, make_permanent, [Vsn], ?TIMEOUT),
20+
?INFO("Made Release ~p Permanent~n", [Vsn]);
21+
main(_) ->
22+
init:stop(1).
23+
24+
start_distribution(NodeName, Cookie) ->
25+
MyNode = make_script_node(NodeName),
26+
{ok, _Pid} = net_kernel:start([MyNode, shortnames]),
27+
erlang:set_cookie(node(), list_to_atom(Cookie)),
28+
TargetNode = make_target_node(NodeName),
29+
case {net_kernel:hidden_connect_node(TargetNode),
30+
net_adm:ping(TargetNode)} of
31+
{true, pong} ->
32+
ok;
33+
{_, pang} ->
34+
io:format("Node ~p not responding to pings.\n", [TargetNode]),
35+
init:stop(1)
36+
end,
37+
TargetNode.
38+
39+
make_target_node(Node) ->
40+
[_, Host] = string:tokens(atom_to_list(node()), "@"),
41+
list_to_atom(lists:concat([Node, "@", Host])).
42+
43+
make_script_node(Node) ->
44+
list_to_atom(lists:concat([Node, "_upgrader_", os:getpid()])).

‎rel/files/vm.args

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
## Name of the node
2+
-name healthb@127.0.0.1
3+
4+
## Cookie for distributed erlang
5+
-setcookie healthb
6+
7+
## Heartbeat management; auto-restarts VM if it dies or becomes unresponsive
8+
## (Disabled by default..use with caution!)
9+
##-heart
10+
11+
## Enable kernel poll and a few async threads
12+
##+K true
13+
##+A 5
14+
15+
## Increase number of concurrent ports/sockets
16+
##-env ERL_MAX_PORTS 4096
17+
18+
## Tweak GC to run more often
19+
##-env ERL_FULLSWEEP_AFTER 10

‎rel/reltool.config

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
%% -*- mode: erlang -*-
2+
%% ex: ft=erlang
3+
{sys, [
4+
{lib_dirs, ["../deps"]},
5+
{erts, [{mod_cond, derived}, {app_file, strip}]},
6+
{app_file, strip},
7+
{rel, "basho_bench", "0.10.0",
8+
[
9+
kernel,
10+
stdlib,
11+
bear,
12+
lager,
13+
folsom,
14+
goldrush,
15+
riakc,
16+
ibrowse,
17+
mochiweb
18+
]},
19+
{rel, "start_clean", "",
20+
[
21+
kernel,
22+
stdlib
23+
]},
24+
{boot_rel, "basho_bench"},
25+
{profile, embedded},
26+
{incl_cond, derived},
27+
{excl_archive_filters, [".*"]}, %% Do not archive built libs
28+
{excl_sys_filters, ["^bin/(?!start_clean.boot)",
29+
"^erts.*/bin/(dialyzer|typer)",
30+
"^erts.*/(doc|info|include|lib|man|src)"]},
31+
{excl_app_filters, ["\.gitignore"]},
32+
{app, basho_bench, [{mod_cond, app}, {incl_cond, include}, {lib_dir, ".."}]},
33+
{app, hipe, [{incl_cond, exclude}]}
34+
]}.
35+
36+
{target_dir, "basho_bench"}.
37+
{overlay_vars, "vars.config"}.
38+
39+
{overlay, [
40+
{template, "../deps/node_package/priv/base/env.sh",
41+
"lib/env.sh"},
42+
{mkdir, "data/b_b"},
43+
44+
%% Copy base files for starting and interacting w/ node
45+
{copy, "../deps/node_package/priv/base/erl",
46+
"{{erts_vsn}}/bin/erl"},
47+
{copy, "../deps/node_package/priv/base/nodetool",
48+
"{{erts_vsn}}/bin/nodetool"},
49+
{template, "../deps/node_package/priv/base/env.sh",
50+
"lib/env.sh"},
51+
{copy, "files/vm.args", "etc/vm.args"},
52+
53+
{template, "files/basho_bench", "bin/basho_bench"},
54+
55+
{copy, "../examples/cs.config.sample", "etc/cs.config"},
56+
{copy, "../examples/riakc_pb.config", "etc/riakc_pb.config"},
57+
{copy, "../examples/httpraw.config", "etc/httpraw.config"},
58+
{copy, "../examples/http.config", "etc/http.config"},
59+
{copy, "../examples/null_test.config", "etc/null_test.config"}
60+
61+
%%{copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"},
62+
63+
]}.

‎rel/vars.config

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
%% -*- tab-width: 4;erlang-indent-level: 4;indent-tabs-mode: nil -*-
2+
%% ex: ts=4 sw=4 et
3+
4+
%% Platform-specific installation paths
5+
{platform_bin_dir, "./bin"}.
6+
{platform_data_dir, "./data"}.
7+
{platform_etc_dir, "./etc"}.
8+
{platform_lib_dir, "./lib"}.
9+
{platform_log_dir, "./log"}.
10+
11+
%%
12+
{data_dir, "{{target_dir}}/data"}.
13+
{runner_script_dir, "\`cd \\`dirname $0\\` && /bin/pwd\`"}.
14+
{runner_base_dir, "{{runner_script_dir}}/.."}.
15+
{runner_etc_dir, "$RUNNER_BASE_DIR/etc"}.
16+
{runner_log_dir, "$RUNNER_BASE_DIR/log"}.
17+
{runner_lib_dir, "$RUNNER_BASE_DIR/lib"}.
18+
{runner_patch_dir, "$RUNNER_BASE_DIR/lib/basho-patches"}.
19+
{pipe_dir, "/tmp/$RUNNER_BASE_DIR/"}.
20+
{runner_user, ""}.

‎src/basho_bench.app.src

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{application, basho_bench,
22
[{description, "Riak Benchmarking Suite"},
3-
{vsn, "0.9"},
3+
{vsn, git},
44
{modules, []},
55
{registered, [ basho_bench_sup ]},
66
{applications, [kernel,

‎src/basho_bench.erl

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ setup_distributed_work() ->
307307
[pool:attach(SlaveName) || SlaveName <- SlaveNames],
308308
CodePaths = code:get_path(),
309309
rpc:multicall(SlaveNames, code, set_path, [CodePaths]),
310-
Apps = [lager, basho_bench, getopt, bear, folsom, ibrowse, riakc, riak_pb, mochiweb, protobuffs, velvet, goldrush],
310+
Apps = [lager, basho_bench, getopt, bear, folsom, ibrowse, riakc, riak_pb, mochiweb, protobuffs, goldrush],
311311
[distribute_app(App) || App <- Apps].
312312

313313

‎src/basho_bench_driver_cs.erl

+5-1
Original file line numberDiff line numberDiff line change
@@ -569,11 +569,15 @@ auth_sig(AccessKey, SecretKey, Method, ContentType, Date, Headers, Resource) ->
569569
CanonizedAmzHeaders,
570570
Resource
571571
],
572-
Signature = base64:encode(stanchion_utils:sha_mac(SecretKey, StringToSign)),
572+
Signature = base64:encode(sha_mac(SecretKey, StringToSign)),
573573
["AWS ", AccessKey, $:, Signature].
574574

575575
%% CS utilities
576576

577+
%% @doc copied from stanchion_utils
578+
sha_mac(KeyData, STS) ->
579+
crypto:hmac(sha, KeyData, STS).
580+
577581
setup_user_and_bucket(State) ->
578582
case basho_bench_config:get(cs_access_key, undefined) of
579583
undefined ->

0 commit comments

Comments
 (0)
Please sign in to comment.