Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
yosukehara committed Nov 26, 2015
1 parent 93e4f76 commit 8076548
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions test/leo_cache_api_tests.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%%
%% Leo Cache
%%
%% Copyright (c) 2012-2014 Rakuten, Inc.
%% Copyright (c) 2012-2015 Rakuten, Inc.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
Expand Down Expand Up @@ -54,15 +54,14 @@ teardown(_) ->
suite_1_(_) ->
Options = [{?PROP_RAM_CACHE_NAME, ?DEF_PROP_RAM_CACHE},
{?PROP_RAM_CACHE_WORKERS, 2},
{?PROP_RAM_CACHE_SIZE, 1024 * 1024 * 16}, %% at least need 1MB
{?PROP_RAM_CACHE_SIZE, 1024 * 1024 * 16},
{?PROP_DISC_CACHE_NAME, ?DEF_PROP_DISC_CACHE},
{?PROP_DISC_CACHE_WORKERS, 0},
{?PROP_DISC_CACHE_SIZE, 0},
{?PROP_DISC_CACHE_THRESHOLD_LEN, 1001},
{?PROP_DISC_CACHE_DATA_DIR, ?DEF_PROP_DISC_CACHE_DATA_DIR},
{?PROP_DISC_CACHE_JOURNAL_DIR, ?DEF_PROP_DISC_CACHE_JOURNAL_DIR}
],
?debugVal(Options),
leo_cache_api:start(Options),

Key1 = <<"photo/image/hawaii-0.png">>,
Expand Down Expand Up @@ -91,6 +90,15 @@ suite_1_(_) ->
?assertEqual(1, H),
?assertEqual(1, R),
?assertEqual(true, (S >= 128)),

%% leo_cache's ets has no records.
ets:delete_all_objects(?ETS_CACHE_SERVER_INFO),
_TestKey = <<"path/to/object">>,
ok = leo_cache_api:put(_TestKey, <<>>),
not_found = leo_cache_api:get(_TestKey),
ok = leo_cache_api:delete(_TestKey),
{ok,{stats,0,0,0,0,0,0}} = leo_cache_api:stats(),

leo_cache_api:stop(),
ok.

Expand All @@ -99,7 +107,7 @@ suite_2_(_) ->
%% Launch Server
Options = [{?PROP_RAM_CACHE_NAME, ?DEF_PROP_RAM_CACHE},
{?PROP_RAM_CACHE_WORKERS, 2},
{?PROP_RAM_CACHE_SIZE, 1024 * 1024 * 4}, %% at least need 1MB
{?PROP_RAM_CACHE_SIZE, 1024 * 1024 * 4},
{?PROP_DISC_CACHE_NAME, ?DEF_PROP_DISC_CACHE},
{?PROP_DISC_CACHE_WORKERS, 2},
{?PROP_DISC_CACHE_SIZE, 1024 * 1024 * 16},
Expand Down Expand Up @@ -136,9 +144,9 @@ suite_2_(_) ->
ok = leo_cache_api:put(Ref, BinKey, Chunk),
ok = leo_cache_api:put(Ref, BinKey, Chunk),
CM = #cache_meta{
md5 = 1,
mtime = 123,
content_type = "image/jpeg"},
md5 = 1,
mtime = 123,
content_type = "image/jpeg"},
ok = leo_cache_api:put_end_tran(Ref, BinKey, CM, true),

{ok, CS3} = leo_cache_api:stats(),
Expand Down

0 comments on commit 8076548

Please sign in to comment.