Permalink
Browse files

Merge pull request #124 from basho/feature/pulse-makefile-target

Add a Makefile target for pulse tests
  • Loading branch information...
2 parents a7c06a3 + a2d683a commit 1db995d38d083fa9ce35886861b3f6edd0c0aac1 @slfritchie slfritchie committed Dec 12, 2013
View
@@ -2,22 +2,25 @@ REPO ?= bitcask
BITCASK_TAG = $(shell git describe --tags)
REVISION ?= $(shell echo $(BITCASK_TAG) | sed -e 's/^$(REPO)-//')
PKG_VERSION ?= $(shell echo $(REVISION) | tr - .)
+BASE_DIR = $(shell pwd)
REBAR_BIN := $(shell which rebar)
ifeq ($(REBAR_BIN),)
REBAR_BIN = ./rebar
endif
+PULSE_TESTS = bitcask_pulse
+
.PHONY: rel deps package pkgclean
all: deps compile
compile:
- $(REBAR_BIN) compile
+ $(REBAR_BIN) compile
deps:
$(REBAR_BIN) get-deps
-clean:
+clean:
$(REBAR_BIN) clean
test: deps compile eunit_erlang eunit_nif
@@ -28,6 +31,23 @@ eunit_erlang:
eunit_nif:
IOMODE="nif" $(REBAR_BIN) skip_deps=true eunit
+NOW = $(shell date +%s)
+COUNTER = $(PWD)/$(NOW).current_counterexample.eqc
+EQCINFO = $(PWD)/$(NOW).eqc-info
+
+pulse:
+ @rm -rf $(BASE_DIR)/.eunit
+ BITCASK_PULSE=1 $(REBAR_BIN) clean compile
+ env BITCASK_PULSE=1 $(REBAR_BIN) -D PULSE eunit skip_deps=true suites=$(PULSE_TESTS) ; \
+ if [ $$? -ne 0 ]; then \
+ echo PULSE test FAILED; \
+ cp ./.eunit/current_counterexample.eqc $(COUNTER); \
+ cp ./.eunit/.eqc-info $(EQCINFO); \
+ echo See files $(COUNTER) and $(EQCINFO); \
+ exit 1; \
+ else \
+ exit 0; \
+ fi
# Release tarball creation
# Generates a tarball that includes all the deps sources so no checkouts are necessary
@@ -47,7 +67,7 @@ buildtar = mkdir distdir && \
mkdir ../$(BITCASK_TAG)/deps && \
make deps; \
for dep in deps/*; do cd $${dep} && $(call archive,$${dep},../../../$(BITCASK_TAG)); cd ../..; done
-
+
distdir:
$(if $(BITCASK_TAG), $(call buildtar), $(error "You can't generate a release tarball from a non-tagged revision. Run 'git checkout <tag>', then 'make dist'"))
View
BIN rebar
Binary file not shown.
View
@@ -17,66 +17,6 @@
%% OS X Snow Leopard flags for 32-bit
{"darwin10.*-32$", "CFLAGS", "-m32"},
{"darwin10.*-32$", "LDFLAGS", "-arch i386"}
-
- %% Patching the nif(s) to run w. PULSE
- %% , {"CFLAGS", "$CFLAGS -DPULSE"}
- ]}.
-
-{eunit_compile_opts, [
- %% Uncomment the following options to enable pulse testing. Note that
- %% this will (currently) break all tests that do NOT use Pulse. As such,
- %% this is most useful when used w/ rebar like so:
- %% ./rebar compile eunit apps=bitcask suite=bitcask_eqc
- %%
- %% Also uncomment the nif-patching in the port_envs option above!
- %%
- %% NOTE1: You'll have to do a "clean" to ensure everything gets compiled w/
- %% the new flags!
- %% NOTE2: You'll need a recent (1.25.2+) version of PULSE to run the tests
- %% and a copy of the pulsified OTP componentes (pulse_gen, etc...)
- %%
- %% {d, 'PULSE'},
- %%
- %% {pulse_no_side_effect,[{erlang,display,1}]},
- %% {pulse_side_effect,
- %% [ {bitcask_nifs, keydir_new, 0}
- %% , {bitcask_nifs, keydir_new, 1}
- %% , {bitcask_nifs, keydir_mark_ready, 1}
- %% , {bitcask_nifs, keydir_put_int, 8}
- %% , {bitcask_nifs, keydir_get_int, 3}
- %% , {bitcask_nifs, keydir_remove, 2}
- %% , {bitcask_nifs, keydir_remove_int, 5}
- %% , {bitcask_nifs, keydir_copy, 1}
- %% , {bitcask_nifs, keydir_itr_int, 4}
- %% , {bitcask_nifs, keydir_itr_next_int, 1}
- %% , {bitcask_nifs, keydir_itr_release, 1}
- %% , {bitcask_nifs, keydir_info, 1}
- %% , {bitcask_nifs, keydir_release, 1}
- %%
- %% , {bitcask_nifs, lock_acquire, 2}
- %% , {bitcask_nifs, lock_release, 1}
- %% , {bitcask_nifs, lock_readdata, 1}
- %% , {bitcask_nifs, lock_writedata, 2}
- %%
- %% , {bitcask_nifs, file_open, 2}
- %% , {bitcask_nifs, file_close, 1}
- %% , {bitcask_nifs, file_sync, 1}
- %% , {bitcask_nifs, file_pread, 3}
- %% , {bitcask_nifs, file_pwrite, 3}
- %% , {bitcask_nifs, file_read, 2}
- %% , {bitcask_nifs, file_write, 2}
- %% , {bitcask_nifs, file_seekbof, 1}
- %%
- %% , {bitcask_time, tstamp, 0}
- %%
- %% , {file, '_', '_'}
- %% , {filelib, '_', '_'}
- %% , {os, '_', '_'} ]},
- %%
- %% {pulse_replace_module,
- %% [ {gen_server, pulse_gen_server}
- %% , {application, pulse_application}
- %% , {supervisor, pulse_supervisor} ]}
- ]}.
+ ]}.
{eunit_opts, [verbose]}.
View
@@ -0,0 +1,72 @@
+PulseBuild = case os:getenv("BITCASK_PULSE") of
+ false ->
+ false;
+ _ ->
+ true
+ end,
+case PulseBuild of
+ true ->
+ PulseOpts =
+ [{pulse_no_side_effect,[{erlang,display,1}]},
+ {pulse_side_effect,
+ [ {bitcask_nifs, keydir_new, 0}
+ , {bitcask_nifs, keydir_new, 1}
+ , {bitcask_nifs, keydir_mark_ready, 1}
+ , {bitcask_nifs, keydir_put_int, 8}
+ , {bitcask_nifs, keydir_get_int, 2}
+ , {bitcask_nifs, keydir_remove, 2}
+ , {bitcask_nifs, keydir_remove_int, 5}
+ , {bitcask_nifs, keydir_copy, 1}
+ , {bitcask_nifs, keydir_itr_int, 4}
+ , {bitcask_nifs, keydir_itr_next_int, 1}
+ , {bitcask_nifs, keydir_itr_release, 1}
+ , {bitcask_nifs, keydir_info, 1}
+ , {bitcask_nifs, keydir_release, 1}
+
+ , {bitcask_nifs, lock_acquire, 2}
+ , {bitcask_nifs, lock_release, 1}
+ , {bitcask_nifs, lock_readdata, 1}
+ , {bitcask_nifs, lock_writedata, 2}
+
+ , {bitcask_nifs, file_open, 2}
+ , {bitcask_nifs, file_close, 1}
+ , {bitcask_nifs, file_sync, 1}
+ , {bitcask_nifs, file_pread, 3}
+ , {bitcask_nifs, file_pwrite, 3}
+ , {bitcask_nifs, file_read, 2}
+ , {bitcask_nifs, file_write, 2}
+ , {bitcask_nifs, file_seekbof, 1}
+
+ , {bitcask_time, tstamp, 0}
+
+ , {file, '_', '_'}
+ , {filelib, '_', '_'}
+ , {os, '_', '_'} ]},
+
+ {pulse_replace_module,
+ [ {gen_server, pulse_gen_server}
+ , {application, pulse_application}
+ , {supervisor, pulse_supervisor} ]}
+ ],
+ PulseCFlags = [{"CFLAGS", "$CFLAGS -DPULSE"}],
+ UpdConfig = case lists:keysearch(eunit_compile_opts, 1, CONFIG) of
+ {value, {eunit_compile_opts, Opts}} ->
+ lists:keyreplace(eunit_compile_opts,
+ 1,
+ CONFIG,
+ {eunit_compile_opts, Opts ++ PulseOpts});
+ _ ->
+ [{eunit_compile_opts, PulseOpts} | CONFIG]
+ end,
+ case lists:keysearch(port_env, 1, UpdConfig) of
+ {value, {port_env, PortEnv}} ->
+ lists:keyreplace(port_env,
+ 1,
+ UpdConfig,
+ {port_env, PortEnv ++ PulseCFlags});
+ _ ->
+ [{port_env, PulseCFlags} | UpdConfig]
+ end;
+ false ->
+ CONFIG
+end.
@@ -1,8 +1,8 @@
-%%% File : bitcask_eqc.erl
+%%% File : bitcask_pulse.erl
%%% Author : Ulf Norell, Hans Svensson
%%% Description : Bitcask stress testing
%%% Created : 19 Mar 2012 by Ulf Norell
--module(bitcask_eqc).
+-module(bitcask_pulse).
%% The while module is ifdef:ed, rebar should set PULSE
-ifdef(PULSE).
@@ -12,7 +12,7 @@
-include_lib("eqc/include/eqc.hrl").
-include_lib("eqc/include/eqc_statem.hrl").
--include("../../include/bitcask.hrl").
+-include("bitcask.hrl").
-include_lib("eunit/include/eunit.hrl").
@@ -251,7 +251,7 @@ start_node(Verbose) ->
_ -> ok
end,
stop_node(),
- {ok, _} = slave:start(host(), slave_name(), "-pa ../../../ebin " ++
+ {ok, _} = slave:start(host(), slave_name(), "-pa ../ebin " ++
lists:append(["-detached" || not Verbose ])),
ok.
@@ -355,10 +355,20 @@ prop_pulse(LocalOrSlave, Verbose) ->
%% A EUnit wrapper for the QuickCheck property
prop_pulse_test_() ->
- {timeout, 1000000,
+ Timeout = case os:getenv("PULSE_TIME") of
+ false -> 60;
+ Val -> list_to_integer(Val)
+ end,
+ ExtraTO = case os:getenv("PULSE_SHRINK_TIME") of
+ false -> 0;
+ Val2 -> list_to_integer(Val2)
+ end,
+ io:format(user, "prop_pulse_test time: ~p + ~p seconds\n",
+ [Timeout, ExtraTO]),
+ {timeout, (Timeout*1000) + 30,
fun() ->
copy_bitcask_app(),
- ?assert(eqc:quickcheck(eqc:testing_time(60,?QC_OUT(prop_pulse()))))
+ ?assert(eqc:quickcheck(eqc:testing_time(Timeout,?QC_OUT(prop_pulse()))))
end}.
%% Needed since rebar fails miserably in setting up the .eunit test directory
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 1db995d

Please sign in to comment.