WIP -- continue to fix tests in wterl
This commit is contained in:
parent
5ac006630e
commit
3b41805a71
2 changed files with 58 additions and 28 deletions
|
@ -175,7 +175,7 @@ ASYNC_NIF_DECL(
|
||||||
ASYNC_NIF_REPLY(enif_make_badarg(env));
|
ASYNC_NIF_REPLY(enif_make_badarg(env));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fprintf(stderr, "c: %s\ns: %s\n", (char *)config.data, (char *)session_config.data); fflush(stderr);
|
//fprintf(stderr, "c: %s\ns: %s\n", (char *)config.data, (char *)session_config.data); fflush(stderr);
|
||||||
int rc = wiredtiger_open(args->homedir, NULL, config.data[0] != 0 ? (const char*)config.data : NULL, &conn);
|
int rc = wiredtiger_open(args->homedir, NULL, config.data[0] != 0 ? (const char*)config.data : NULL, &conn);
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
WterlConnHandle *conn_handle = enif_alloc_resource(wterl_conn_RESOURCE, sizeof(WterlConnHandle));
|
WterlConnHandle *conn_handle = enif_alloc_resource(wterl_conn_RESOURCE, sizeof(WterlConnHandle));
|
||||||
|
|
|
@ -52,6 +52,7 @@
|
||||||
salvage/3,
|
salvage/3,
|
||||||
truncate/2,
|
truncate/2,
|
||||||
truncate/3,
|
truncate/3,
|
||||||
|
truncate/4,
|
||||||
truncate/5,
|
truncate/5,
|
||||||
upgrade/2,
|
upgrade/2,
|
||||||
upgrade/3,
|
upgrade/3,
|
||||||
|
@ -211,11 +212,14 @@ checkpoint_nif(_AsyncRef, _Ref, _Config) ->
|
||||||
|
|
||||||
-spec truncate(connection(), string()) -> ok | {error, term()}.
|
-spec truncate(connection(), string()) -> ok | {error, term()}.
|
||||||
-spec truncate(connection(), string(), config_list()) -> ok | {error, term()}.
|
-spec truncate(connection(), string(), config_list()) -> ok | {error, term()}.
|
||||||
-spec truncate(connection(), string(), cursor() | first, cursor() | last, config()) -> ok | {error, term()}.
|
-spec truncate(connection(), string(), binary() | first, binary() | last) -> ok | {error, term()}.
|
||||||
|
-spec truncate(connection(), string(), binary() | first, binary() | last, config()) -> ok | {error, term()}.
|
||||||
truncate(Ref, Name) ->
|
truncate(Ref, Name) ->
|
||||||
truncate(Ref, Name, first, last, []).
|
truncate(Ref, Name, first, last, []).
|
||||||
truncate(Ref, Name, Config) ->
|
truncate(Ref, Name, Config) ->
|
||||||
truncate(Ref, Name, first, last, Config).
|
truncate(Ref, Name, first, last, Config).
|
||||||
|
truncate(Ref, Name, Start, Stop) ->
|
||||||
|
truncate(Ref, Name, Start, Stop, []).
|
||||||
truncate(Ref, Name, Start, Stop, Config) ->
|
truncate(Ref, Name, Start, Stop, Config) ->
|
||||||
?ASYNC_NIF_CALL(fun truncate_nif/6, [Ref, Name, Start, Stop, config_to_bin(Config)]).
|
?ASYNC_NIF_CALL(fun truncate_nif/6, [Ref, Name, Start, Stop, config_to_bin(Config)]).
|
||||||
|
|
||||||
|
@ -535,19 +539,19 @@ conn_test_() ->
|
||||||
{"create, verify, drop a table(btree)",
|
{"create, verify, drop a table(btree)",
|
||||||
fun() ->
|
fun() ->
|
||||||
ConnRef = open_test_table(ConnRef),
|
ConnRef = open_test_table(ConnRef),
|
||||||
?assertMatch(ok, verify(ConnRef, "table:test"))
|
?assertMatch(ok, verify(ConnRef, "table:test")),
|
||||||
?assertMatch(ok, drop(ConnRef, "table:test"))
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
end},
|
end},
|
||||||
{"create, test verify, drop a table(lsm)",
|
{"create, test verify, drop a table(lsm)",
|
||||||
fun() ->
|
fun() ->
|
||||||
ConnRef = open_test_table(ConnRef, "lsm"),
|
ConnRef = open_test_table(ConnRef, "lsm"),
|
||||||
?assertMatch(ok, verify(ConnRef, "lsm:test"))
|
?assertMatch(ok, verify(ConnRef, "lsm:test")),
|
||||||
?assertMatch(ok, drop(ConnRef, "lsm:test"))
|
?assertMatch(ok, drop(ConnRef, "lsm:test"))
|
||||||
end},
|
end},
|
||||||
{"create, verify, drop a table(btree, snappy)",
|
{"create, verify, drop a table(btree, snappy)",
|
||||||
fun() ->
|
fun() ->
|
||||||
ConnRef = open_test_table(ConnRef, "table", [{block_compressor, "snappy"}]),
|
ConnRef = open_test_table(ConnRef, "table", [{block_compressor, "snappy"}]),
|
||||||
?assertMatch(ok, verify(ConnRef, "table:test"))
|
?assertMatch(ok, verify(ConnRef, "table:test")),
|
||||||
?assertMatch(ok, drop(ConnRef, "table:test"))
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
end}]}
|
end}]}
|
||||||
end}.
|
end}.
|
||||||
|
@ -559,6 +563,7 @@ insert_delete_test() ->
|
||||||
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:test", <<"a">>)),
|
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:test", <<"a">>)),
|
||||||
?assertMatch(ok, delete(ConnRef, "table:test", <<"a">>)),
|
?assertMatch(ok, delete(ConnRef, "table:test", <<"a">>)),
|
||||||
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)),
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)),
|
||||||
|
?assertMatch(ok, drop(ConnRef, "table:test")),
|
||||||
ok = connection_close(ConnRef).
|
ok = connection_close(ConnRef).
|
||||||
|
|
||||||
init_test_table() ->
|
init_test_table() ->
|
||||||
|
@ -568,56 +573,81 @@ init_test_table() ->
|
||||||
?assertMatch(ok, put(ConnRef, "table:test", <<"b">>, <<"banana">>)),
|
?assertMatch(ok, put(ConnRef, "table:test", <<"b">>, <<"banana">>)),
|
||||||
?assertMatch(ok, put(ConnRef, "table:test", <<"c">>, <<"cherry">>)),
|
?assertMatch(ok, put(ConnRef, "table:test", <<"c">>, <<"cherry">>)),
|
||||||
?assertMatch(ok, put(ConnRef, "table:test", <<"d">>, <<"date">>)),
|
?assertMatch(ok, put(ConnRef, "table:test", <<"d">>, <<"date">>)),
|
||||||
|
?assertMatch(ok, put(ConnRef, "table:test", <<"e">>, <<"elephant">>)),
|
||||||
|
?assertMatch(ok, put(ConnRef, "table:test", <<"f">>, <<"forest">>)),
|
||||||
?assertMatch(ok, put(ConnRef, "table:test", <<"g">>, <<"gooseberry">>)),
|
?assertMatch(ok, put(ConnRef, "table:test", <<"g">>, <<"gooseberry">>)),
|
||||||
ConnRef.
|
ConnRef.
|
||||||
|
|
||||||
stop_test_table(ConnRef) ->
|
stop_test_table(ConnRef) ->
|
||||||
?assertMatch(ok, connection_close(ConnRef)).
|
?assertMatch(ok, connection_close(ConnRef)).
|
||||||
|
|
||||||
various_session_test_() ->
|
various_test_() ->
|
||||||
{setup,
|
{setup,
|
||||||
fun init_test_table/0,
|
fun init_test_table/0,
|
||||||
fun stop_test_table/1,
|
fun stop_test_table/1,
|
||||||
fun(ConnRef) ->
|
fun(ConnRef) ->
|
||||||
{inorder,
|
{inorder,
|
||||||
[{"session verify",
|
[{"verify",
|
||||||
fun() ->
|
fun() ->
|
||||||
?assertMatch(ok, verify(ConnRef, "table:test")),
|
?assertMatch(ok, verify(ConnRef, "table:test")),
|
||||||
?assertMatch({ok, <<"apple">>},
|
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:test", <<"a">>)),
|
||||||
get(ConnRef, "table:test", <<"a">>))
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
end},
|
end},
|
||||||
{"session checkpoint",
|
{"checkpoint",
|
||||||
fun() ->
|
fun() ->
|
||||||
?assertMatch(ok, checkpoint(ConnRef, [{target, ["\"table:test\""]}])),
|
?assertMatch(ok, checkpoint(ConnRef, [{target, ["\"table:test\""]}])),
|
||||||
?assertMatch({ok, <<"apple">>},
|
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:test", <<"a">>)),
|
||||||
get(ConnRef, "table:test", <<"a">>))
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
end},
|
end},
|
||||||
{"session salvage",
|
{"salvage",
|
||||||
fun() ->
|
fun() ->
|
||||||
ok = salvage(ConnRef, "table:test"),
|
ok = salvage(ConnRef, "table:test"),
|
||||||
{ok, <<"apple">>} = get(ConnRef, "table:test", <<"a">>)
|
{ok, <<"apple">>} = get(ConnRef, "table:test", <<"a">>),
|
||||||
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
end},
|
end},
|
||||||
{"session upgrade",
|
{"upgrade",
|
||||||
fun() ->
|
fun() ->
|
||||||
?assertMatch(ok, upgrade(ConnRef, "table:test")),
|
?assertMatch(ok, upgrade(ConnRef, "table:test")),
|
||||||
?assertMatch({ok, <<"apple">>},
|
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:test", <<"a">>)),
|
||||||
get(ConnRef, "table:test", <<"a">>))
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
end},
|
end},
|
||||||
{"session rename",
|
{"rename",
|
||||||
fun() ->
|
fun() ->
|
||||||
?assertMatch(ok,
|
?assertMatch(ok, rename(ConnRef, "table:test", "table:new")),
|
||||||
rename(ConnRef, "table:test", "table:new")),
|
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:new", <<"a">>)),
|
||||||
?assertMatch({ok, <<"apple">>},
|
?assertMatch(ok, rename(ConnRef, "table:new", "table:test")),
|
||||||
get(ConnRef, "table:new", <<"a">>)),
|
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:test", <<"a">>)),
|
||||||
?assertMatch(ok,
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
rename(ConnRef, "table:new", "table:test")),
|
|
||||||
?assertMatch({ok, <<"apple">>},
|
|
||||||
get(ConnRef, "table:test", <<"a">>))
|
|
||||||
end},
|
end},
|
||||||
{"session truncate",
|
{"truncate",
|
||||||
fun() ->
|
fun() ->
|
||||||
?assertMatch(ok, truncate(ConnRef, "table:test")),
|
?assertMatch(ok, truncate(ConnRef, "table:test")),
|
||||||
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>))
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)),
|
||||||
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
|
end},
|
||||||
|
{"truncate range, found",
|
||||||
|
fun() ->
|
||||||
|
?assertMatch(ok, truncate(ConnRef, "table:test", <<"b">>, last)),
|
||||||
|
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:test", <<"a">>)),
|
||||||
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
|
end},
|
||||||
|
{"truncate range, not_found",
|
||||||
|
fun() ->
|
||||||
|
?assertMatch(ok, truncate(ConnRef, "table:test", first, <<"b">>)),
|
||||||
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"a">>)),
|
||||||
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
|
end},
|
||||||
|
{"truncate range, middle",
|
||||||
|
fun() ->
|
||||||
|
?assertMatch(ok, truncate(ConnRef, "table:test", <<"b">>, <<"f">>)),
|
||||||
|
?assertMatch({ok, <<"apple">>}, get(ConnRef, "table:test", <<"a">>)),
|
||||||
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"b">>)),
|
||||||
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"c">>)),
|
||||||
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"d">>)),
|
||||||
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"e">>)),
|
||||||
|
?assertMatch(not_found, get(ConnRef, "table:test", <<"f">>)),
|
||||||
|
?assertMatch({ok, <<"gooseberry">>}, get(ConnRef, "table:test", <<"g">>)),
|
||||||
|
?assertMatch(ok, drop(ConnRef, "table:test"))
|
||||||
end}]}
|
end}]}
|
||||||
end}.
|
end}.
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue