mirror of
https://github.com/valitydev/dominant.git
synced 2024-11-06 02:25:17 +00:00
ED-190/deps: Update dmt_client (#163)
* ED-190/deps: Update dmt_client * ED-190/fix: Fix tests * ED-190/deps: Update dmt_client and update usage * ED-190/fix formatting
This commit is contained in:
parent
50446a3873
commit
c25af1f5a6
@ -15,7 +15,7 @@
|
|||||||
0},
|
0},
|
||||||
{<<"dmt_client">>,
|
{<<"dmt_client">>,
|
||||||
{git,"git@github.com:rbkmoney/dmt_client.git",
|
{git,"git@github.com:rbkmoney/dmt_client.git",
|
||||||
{ref,"37f376e239a2182cbb2a7a052797e99955edbaad"}},
|
{ref,"3f66402843ffeb488010f707a193858cb09325e0"}},
|
||||||
0},
|
0},
|
||||||
{<<"dmt_core">>,
|
{<<"dmt_core">>,
|
||||||
{git,"git@github.com:rbkmoney/dmt_core.git",
|
{git,"git@github.com:rbkmoney/dmt_core.git",
|
||||||
|
@ -150,7 +150,7 @@ end_per_group(_, _C) ->
|
|||||||
|
|
||||||
-spec init_per_testcase(test_case_name(), config()) -> config().
|
-spec init_per_testcase(test_case_name(), config()) -> config().
|
||||||
init_per_testcase(_, C) ->
|
init_per_testcase(_, C) ->
|
||||||
%% added because dmt_client:checkout({head, #'Head'{}})
|
%% added because dmt_client:checkout(latest)
|
||||||
%% could return old version from cache overwise
|
%% could return old version from cache overwise
|
||||||
{ok, _Version} = dmt_client_cache:update(),
|
{ok, _Version} = dmt_client_cache:update(),
|
||||||
C.
|
C.
|
||||||
@ -167,13 +167,13 @@ insert(_C) ->
|
|||||||
ID = next_id(),
|
ID = next_id(),
|
||||||
Object = fixture_domain_object(ID, <<"InsertFixture">>),
|
Object = fixture_domain_object(ID, <<"InsertFixture">>),
|
||||||
Ref = fixture_object_ref(ID),
|
Ref = fixture_object_ref(ID),
|
||||||
#'ObjectNotFound'{} = (catch dmt_client:checkout_object({head, #'Head'{}}, Ref)),
|
#'ObjectNotFound'{} = (catch dmt_client:checkout_object(Ref)),
|
||||||
#'Snapshot'{version = Version1} = dmt_client:checkout({head, #'Head'{}}),
|
#'Snapshot'{version = Version1} = dmt_client:checkout(latest),
|
||||||
Version2 = dmt_client:commit(Version1, #'Commit'{ops = [{insert, #'InsertOp'{object = Object}}]}),
|
Version2 = dmt_client:commit(Version1, #'Commit'{ops = [{insert, #'InsertOp'{object = Object}}]}),
|
||||||
_ = dmt_client_cache:update(),
|
_ = dmt_client_cache:update(),
|
||||||
#'VersionedObject'{object = Object} = dmt_client:checkout_object({head, #'Head'{}}, Ref),
|
Object = dmt_client:checkout_object(Ref),
|
||||||
#'ObjectNotFound'{} = (catch dmt_client:checkout_object({version, Version1}, Ref)),
|
#'ObjectNotFound'{} = (catch dmt_client:checkout_object(Version1, Ref)),
|
||||||
#'VersionedObject'{object = Object} = dmt_client:checkout_object({version, Version2}, Ref).
|
Object = dmt_client:checkout_object(Version2, Ref).
|
||||||
|
|
||||||
-spec update(term()) -> term().
|
-spec update(term()) -> term().
|
||||||
update(_C) ->
|
update(_C) ->
|
||||||
@ -181,27 +181,26 @@ update(_C) ->
|
|||||||
Object1 = fixture_domain_object(ID, <<"UpdateFixture1">>),
|
Object1 = fixture_domain_object(ID, <<"UpdateFixture1">>),
|
||||||
Object2 = fixture_domain_object(ID, <<"UpdateFixture2">>),
|
Object2 = fixture_domain_object(ID, <<"UpdateFixture2">>),
|
||||||
Ref = fixture_object_ref(ID),
|
Ref = fixture_object_ref(ID),
|
||||||
#'Snapshot'{version = Version0} = dmt_client:checkout({head, #'Head'{}}),
|
#'Snapshot'{version = Version0} = dmt_client:checkout(latest),
|
||||||
Version1 = dmt_client:commit(Version0, #'Commit'{ops = [{insert, #'InsertOp'{object = Object1}}]}),
|
Version1 = dmt_client:commit(Version0, #'Commit'{ops = [{insert, #'InsertOp'{object = Object1}}]}),
|
||||||
Version2 = dmt_client:commit(
|
Version2 = dmt_client:commit(
|
||||||
Version1,
|
Version1,
|
||||||
#'Commit'{ops = [{update, #'UpdateOp'{old_object = Object1, new_object = Object2}}]}
|
#'Commit'{ops = [{update, #'UpdateOp'{old_object = Object1, new_object = Object2}}]}
|
||||||
),
|
),
|
||||||
_ = dmt_client_cache:update(),
|
_ = dmt_client_cache:update(),
|
||||||
#'VersionedObject'{object = Object1} = dmt_client:checkout_object({version, Version1}, Ref),
|
Object1 = dmt_client:checkout_object(Version1, Ref),
|
||||||
#'VersionedObject'{object = Object2} = dmt_client:checkout_object({version, Version2}, Ref).
|
Object2 = dmt_client:checkout_object(Version2, Ref).
|
||||||
|
|
||||||
-spec delete(term()) -> term().
|
-spec delete(term()) -> term().
|
||||||
delete(_C) ->
|
delete(_C) ->
|
||||||
ID = next_id(),
|
ID = next_id(),
|
||||||
Object = fixture_domain_object(ID, <<"DeleteFixture">>),
|
Object = fixture_domain_object(ID, <<"DeleteFixture">>),
|
||||||
Ref = fixture_object_ref(ID),
|
Ref = fixture_object_ref(ID),
|
||||||
#'Snapshot'{version = Version0} = dmt_client:checkout({head, #'Head'{}}),
|
#'Snapshot'{version = Version0} = dmt_client:checkout(latest),
|
||||||
Version1 = dmt_client:commit(Version0, #'Commit'{ops = [{insert, #'InsertOp'{object = Object}}]}),
|
Version1 = dmt_client:commit(Version0, #'Commit'{ops = [{insert, #'InsertOp'{object = Object}}]}),
|
||||||
Version2 = dmt_client:commit(Version1, #'Commit'{ops = [{remove, #'RemoveOp'{object = Object}}]}),
|
Version2 = dmt_client:commit(Version1, #'Commit'{ops = [{remove, #'RemoveOp'{object = Object}}]}),
|
||||||
_ = dmt_client_cache:update(),
|
Object = dmt_client:checkout_object(Version1, Ref),
|
||||||
#'VersionedObject'{object = Object} = dmt_client:checkout_object({version, Version1}, Ref),
|
#'ObjectNotFound'{} = (catch dmt_client:checkout_object(Version2, Ref)).
|
||||||
#'ObjectNotFound'{} = (catch dmt_client:checkout_object({version, Version2}, Ref)).
|
|
||||||
|
|
||||||
-spec pull_commit(term()) -> term().
|
-spec pull_commit(term()) -> term().
|
||||||
pull_commit(_C) ->
|
pull_commit(_C) ->
|
||||||
@ -222,12 +221,11 @@ retry_commit(_C) ->
|
|||||||
}}
|
}}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
#'Snapshot'{version = Version1} = dmt_client:checkout({head, #'Head'{}}),
|
#'Snapshot'{version = Version1} = dmt_client:checkout(latest),
|
||||||
Version2 = dmt_client:commit(Version1, Commit1),
|
Version2 = dmt_client:commit(Version1, Commit1),
|
||||||
Version2 = Version1 + 1,
|
Version2 = Version1 + 1,
|
||||||
Version2 = dmt_client:commit(Version1, Commit1),
|
Version2 = dmt_client:commit(Version1, Commit1),
|
||||||
_ = dmt_client_cache:update(),
|
#'Snapshot'{version = Version2} = dmt_client:checkout(latest),
|
||||||
#'Snapshot'{version = Version2} = dmt_client:checkout({head, #'Head'{}}),
|
|
||||||
Commit2 = #'Commit'{
|
Commit2 = #'Commit'{
|
||||||
ops = [
|
ops = [
|
||||||
{insert, #'InsertOp'{
|
{insert, #'InsertOp'{
|
||||||
@ -238,12 +236,11 @@ retry_commit(_C) ->
|
|||||||
Version3 = dmt_client:commit(Version2, Commit2),
|
Version3 = dmt_client:commit(Version2, Commit2),
|
||||||
Version3 = Version2 + 1,
|
Version3 = Version2 + 1,
|
||||||
Version2 = dmt_client:commit(Version1, Commit1),
|
Version2 = dmt_client:commit(Version1, Commit1),
|
||||||
_ = dmt_client_cache:update(),
|
#'Snapshot'{version = Version3} = dmt_client:checkout(latest).
|
||||||
#'Snapshot'{version = Version3} = dmt_client:checkout({head, #'Head'{}}).
|
|
||||||
|
|
||||||
-spec migration_success(term()) -> term().
|
-spec migration_success(term()) -> term().
|
||||||
migration_success(_C) ->
|
migration_success(_C) ->
|
||||||
#'Snapshot'{version = VersionV3} = dmt_client:checkout({head, #'Head'{}}),
|
#'Snapshot'{version = VersionV3} = dmt_client:checkout(latest),
|
||||||
true = VersionV3 > 0,
|
true = VersionV3 > 0,
|
||||||
VersionV4 = wait_for_migration(VersionV3, 20, 1000),
|
VersionV4 = wait_for_migration(VersionV3, 20, 1000),
|
||||||
VersionV4 = VersionV3 + 1.
|
VersionV4 = VersionV3 + 1.
|
||||||
@ -264,7 +261,7 @@ wait_for_migration(_, _, _) ->
|
|||||||
|
|
||||||
-spec conflict(term()) -> term().
|
-spec conflict(term()) -> term().
|
||||||
conflict(_C) ->
|
conflict(_C) ->
|
||||||
#'Snapshot'{version = Version1} = dmt_client:checkout({head, #'Head'{}}),
|
#'Snapshot'{version = Version1} = dmt_client:checkout(latest),
|
||||||
_ = ?assertThrow(
|
_ = ?assertThrow(
|
||||||
#'OperationConflict'{
|
#'OperationConflict'{
|
||||||
conflict =
|
conflict =
|
||||||
@ -284,7 +281,7 @@ conflict(_C) ->
|
|||||||
|
|
||||||
-spec nonexistent(term()) -> term().
|
-spec nonexistent(term()) -> term().
|
||||||
nonexistent(_C) ->
|
nonexistent(_C) ->
|
||||||
#'Snapshot'{version = Version1} = dmt_client:checkout({head, #'Head'{}}),
|
#'Snapshot'{version = Version1} = dmt_client:checkout(latest),
|
||||||
_ = ?assertThrow(
|
_ = ?assertThrow(
|
||||||
#'OperationInvalid'{
|
#'OperationInvalid'{
|
||||||
errors = [
|
errors = [
|
||||||
@ -295,16 +292,12 @@ nonexistent(_C) ->
|
|||||||
| _
|
| _
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
dmt_client:commit(Version1, #'Commit'{
|
dmt_client:insert(Version1, criterion_w_refs(42, [43, 44, 45]))
|
||||||
ops = [
|
|
||||||
{insert, #'InsertOp'{object = criterion_w_refs(42, [43, 44, 45])}}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
).
|
).
|
||||||
|
|
||||||
-spec reference_cycles(term()) -> term().
|
-spec reference_cycles(term()) -> term().
|
||||||
reference_cycles(_C) ->
|
reference_cycles(_C) ->
|
||||||
#'Snapshot'{version = Version1} = dmt_client:checkout({head, #'Head'{}}),
|
#'Snapshot'{version = Version1} = dmt_client:checkout(latest),
|
||||||
_ = ?assertThrow(
|
_ = ?assertThrow(
|
||||||
#'OperationInvalid'{
|
#'OperationInvalid'{
|
||||||
errors = [
|
errors = [
|
||||||
@ -320,14 +313,15 @@ reference_cycles(_C) ->
|
|||||||
}}
|
}}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
dmt_client:commit(Version1, #'Commit'{
|
dmt_client:insert(
|
||||||
ops = [
|
Version1,
|
||||||
{insert, #'InsertOp'{object = criterion_w_refs(1, [2])}},
|
[
|
||||||
{insert, #'InsertOp'{object = criterion_w_refs(2, [3])}},
|
criterion_w_refs(1, [2]),
|
||||||
{insert, #'InsertOp'{object = criterion_w_refs(3, [4, 1])}},
|
criterion_w_refs(2, [3]),
|
||||||
{insert, #'InsertOp'{object = criterion_w_refs(4, [1, 2])}}
|
criterion_w_refs(3, [4, 1]),
|
||||||
|
criterion_w_refs(4, [1, 2])
|
||||||
]
|
]
|
||||||
})
|
)
|
||||||
).
|
).
|
||||||
|
|
||||||
next_id() ->
|
next_id() ->
|
||||||
|
@ -489,24 +489,21 @@ next_id() ->
|
|||||||
erlang:system_time(micro_seconds) band 16#7FFFFFFF.
|
erlang:system_time(micro_seconds) band 16#7FFFFFFF.
|
||||||
|
|
||||||
insert(Object) ->
|
insert(Object) ->
|
||||||
{ok, Version} = dmt_client_cache:update(),
|
dmt_client:commit(#'Commit'{ops = [{insert, #'InsertOp'{object = Object}}]}).
|
||||||
dmt_client:commit(Version, #'Commit'{ops = [{insert, #'InsertOp'{object = Object}}]}).
|
|
||||||
|
|
||||||
update(Object0, Object1) ->
|
update(Object0, Object1) ->
|
||||||
{ok, Version} = dmt_client_cache:update(),
|
dmt_client:commit(#'Commit'{
|
||||||
dmt_client:commit(Version, #'Commit'{
|
|
||||||
ops = [
|
ops = [
|
||||||
{update, #'UpdateOp'{old_object = Object0, new_object = Object1}}
|
{update, #'UpdateOp'{old_object = Object0, new_object = Object1}}
|
||||||
]
|
]
|
||||||
}).
|
}).
|
||||||
|
|
||||||
remove(Object) ->
|
remove(Object) ->
|
||||||
{ok, Version} = dmt_client_cache:update(),
|
dmt_client:commit(#'Commit'{ops = [{remove, #'RemoveOp'{object = Object}}]}).
|
||||||
dmt_client:commit(Version, #'Commit'{ops = [{remove, #'RemoveOp'{object = Object}}]}).
|
|
||||||
|
|
||||||
checkout(Ref, Version) ->
|
checkout(Ref, Version) ->
|
||||||
try dmt_client:checkout_object({version, Version}, Ref) of
|
try dmt_client:checkout_object(Version, Ref) of
|
||||||
#'VersionedObject'{object = {_Tag, Object}} ->
|
{_Tag, Object} ->
|
||||||
Object
|
Object
|
||||||
catch
|
catch
|
||||||
throw:#'ObjectNotFound'{} ->
|
throw:#'ObjectNotFound'{} ->
|
||||||
|
Loading…
Reference in New Issue
Block a user