machi/test/machi_projection_store_test.erl

66 lines
2.1 KiB
Erlang
Raw Normal View History

%% -------------------------------------------------------------------
%%
%% Copyright (c) 2007-2015 Basho Technologies, Inc. All Rights Reserved.
%%
%% 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.
%%
%% -------------------------------------------------------------------
-module(machi_projection_store_test).
-ifdef(TEST).
-ifndef(PULSE).
-compile(export_all).
-define(PS, machi_projection_store).
-include("machi_projection.hrl").
smoke_test() ->
{ok, SupPid} = machi_flu_sup:start_link(),
PortBase = 64820,
Dir = "./data.a",
Os = [{ignore_stability_time, true}, {active_mode, false}],
os:cmd("rm -rf " ++ Dir),
{ok,Yo}=machi_flu_psup:start_flu_package(a, PortBase, "./data.a", Os),
try
P1 = machi_projection:new(1, a, [], [], [], [], []),
ok = ?PS:write(a_pstore, public, P1),
{error, written} = ?PS:write(a_pstore, public, P1),
2015-08-25 10:31:05 +00:00
Pbad = P1#projection_v1{epoch_number=99238}, % break checksum
{error, bad_arg} = ?PS:write(a_pstore, public, Pbad),
ok = ?PS:write(a_pstore, private, P1),
2015-08-25 10:42:33 +00:00
P1a = machi_projection:update_checksum(P1#projection_v1{dbg=[diff_yo]}),
{error, written} = ?PS:write(a_pstore, private, P1a),
P1b = P1#projection_v1{dbg2=[version_b]},
ok = ?PS:write(a_pstore, private, P1b),
P1c = P1#projection_v1{dbg2=[version_c]},
ok = ?PS:write(a_pstore, private, P1c),
2015-08-25 10:42:33 +00:00
{error, written} = ?PS:write(a_pstore, private, P1a),
ok
after
machi_flu_psup:stop_flu_package(a),
exit(SupPid, normal),
timer:sleep(10)
end.
-endif. % !PULSE
-endif. % TEST