diff --git a/.github/workflows/erlang-checks.yaml b/.github/workflows/erlang-checks.yaml index 79491c1..37614ec 100644 --- a/.github/workflows/erlang-checks.yaml +++ b/.github/workflows/erlang-checks.yaml @@ -3,10 +3,10 @@ name: Erlang CI Checks on: push: branches: - - 'master' - - 'epic/**' + - "master" + - "epic/**" pull_request: - branches: ['**'] + branches: ["**"] jobs: setup: @@ -30,7 +30,7 @@ jobs: run: name: Run checks needs: setup - uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.17 + uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1 with: otp-version: ${{ needs.setup.outputs.otp-version }} rebar-version: ${{ needs.setup.outputs.rebar-version }} diff --git a/.tool-versions b/.tool-versions new file mode 100644 index 0000000..b242499 --- /dev/null +++ b/.tool-versions @@ -0,0 +1 @@ +erlang 27.1.2 diff --git a/Makefile b/Makefile index 25c966b..0ffe029 100644 --- a/Makefile +++ b/Makefile @@ -15,7 +15,7 @@ DEV_IMAGE_TAG = $(TEST_CONTAINER_NAME)-dev DEV_IMAGE_ID = $(file < .image.dev) DOCKER ?= docker -DOCKERCOMPOSE ?= docker-compose +DOCKERCOMPOSE ?= docker compose DOCKERCOMPOSE_W_ENV = DEV_IMAGE_TAG=$(DEV_IMAGE_TAG) $(DOCKERCOMPOSE) -f compose.yaml -f compose.tracing.yaml REBAR ?= rebar3 TEST_CONTAINER_NAME ?= testrunner diff --git a/apps/party_management/src/pm_domain.erl b/apps/party_management/src/pm_domain.erl index 993b285..c226312 100644 --- a/apps/party_management/src/pm_domain.erl +++ b/apps/party_management/src/pm_domain.erl @@ -6,8 +6,7 @@ -module(pm_domain). --include_lib("damsel/include/dmsl_domain_thrift.hrl"). --include_lib("damsel/include/dmsl_domain_conf_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_conf_v2_thrift.hrl"). %% @@ -18,7 +17,7 @@ -export([insert/1]). -export([update/1]). --export([cleanup/0]). +-export([cleanup/1]). %% @@ -26,6 +25,7 @@ -type ref() :: dmsl_domain_thrift:'Reference'(). -type object() :: dmsl_domain_thrift:'DomainObject'(). -type data() :: _. +-type commit_response() :: dmsl_domain_conf_v2_thrift:'CommitResponse'(). -export_type([revision/0]). -export_type([ref/0]). @@ -34,87 +34,109 @@ -spec head() -> revision(). head() -> - dmt_client:get_last_version(). + dmt_client:get_latest_version(). -spec get(revision(), ref()) -> data() | no_return(). -get(Revision, Ref) -> +get(Revision0, Ref) -> + Revision1 = maybe_migrate_version(Revision0), try - extract_data(dmt_client:checkout_object(Revision, Ref)) + extract_data(dmt_client:checkout_object(Ref, Revision1)) catch - throw:#domain_conf_ObjectNotFound{} -> - error({object_not_found, {Revision, Ref}}) + throw:#domain_conf_v2_ObjectNotFound{} -> + error({object_not_found, {Revision1, Ref}}) end. -spec find(revision(), ref()) -> data() | notfound. -find(Revision, Ref) -> +find(Revision0, Ref) -> + Revision1 = maybe_migrate_version(Revision0), try - extract_data(dmt_client:checkout_object(Revision, Ref)) + extract_data(dmt_client:checkout_object(Ref, Revision1)) catch - throw:#domain_conf_ObjectNotFound{} -> + throw:#domain_conf_v2_ObjectNotFound{} -> notfound end. -spec exists(revision(), ref()) -> boolean(). -exists(Revision, Ref) -> +exists(Revision0, Ref) -> + Revision1 = maybe_migrate_version(Revision0), try - _ = dmt_client:checkout_object(Revision, Ref), + _ = dmt_client:checkout_object(Ref, Revision1), true catch - throw:#domain_conf_ObjectNotFound{} -> + throw:#domain_conf_v2_ObjectNotFound{} -> false end. -extract_data({_Tag, {_Name, _Ref, Data}}) -> +extract_data(#domain_conf_v2_VersionedObject{object = {_Tag, {_Name, _Ref, Data}}}) -> Data. --spec commit(revision(), dmt_client:commit()) -> revision() | no_return(). -commit(Revision, Commit) -> - dmt_client:commit(Revision, Commit). +-spec commit(revision(), [dmt_client:operation()], binary()) -> commit_response() | no_return(). +commit(Revision, Operations, AuthorID) -> + dmt_client:commit(Revision, Operations, AuthorID). --spec insert(object() | [object()]) -> revision() | no_return(). -insert(Object) when not is_list(Object) -> - insert([Object]); +-spec insert(object() | [object()]) -> {revision(), [ref()]} | no_return(). insert(Objects) -> - Commit = #'domain_conf_Commit'{ - ops = [ - {insert, #'domain_conf_InsertOp'{ - object = Object - }} - || Object <- Objects - ] - }, - commit(head(), Commit). + insert(Objects, generate_author()). + +-spec insert(object() | [object()], binary()) -> {revision(), [ref()]} | no_return(). +insert(Object, AuthorID) when not is_list(Object) -> + insert([Object], AuthorID); +insert(Objects, AuthorID) -> + Commit = [ + {insert, #domain_conf_v2_InsertOp{ + object = {Type, Object}, + force_ref = {Type, ForceRef} + }} + || {Type, {_ObjectName, ForceRef, Object}} <- Objects + ], + #domain_conf_v2_CommitResponse{version = Version, new_objects = NewObjects} = + commit(head(), Commit, AuthorID), + NewObjectsIDs = [ + {Tag, Ref} + || {Tag, {_ON, Ref, _Obj}} <- ordsets:to_list(NewObjects) + ], + {Version, NewObjectsIDs}. -spec update(object() | [object()]) -> revision() | no_return(). update(NewObject) when not is_list(NewObject) -> - update([NewObject]); -update(NewObjects) -> + update(NewObject, generate_author()). + +-spec update(object() | [object()], binary()) -> revision() | no_return(). +update(NewObject, AuthorID) when not is_list(NewObject) -> + update([NewObject], AuthorID); +update(NewObjects, AuthorID) -> Revision = head(), - Commit = #'domain_conf_Commit'{ - ops = [ - {update, #'domain_conf_UpdateOp'{ - old_object = {Tag, {ObjectName, Ref, OldData}}, - new_object = NewObject - }} - || NewObject = {Tag, {ObjectName, Ref, _Data}} <- NewObjects, - OldData <- [get(Revision, {Tag, Ref})] - ] - }, - commit(Revision, Commit). - --spec remove([object()]) -> revision() | no_return(). -remove(Objects) -> - Commit = #'domain_conf_Commit'{ - ops = [ - {remove, #'domain_conf_RemoveOp'{ - object = Object - }} - || Object <- Objects - ] - }, - commit(head(), Commit). - --spec cleanup() -> revision() | no_return(). -cleanup() -> - #'domain_conf_Snapshot'{domain = Domain} = dmt_client:checkout(latest), - remove(maps:values(Domain)). + Commit = [ + {update, #domain_conf_v2_UpdateOp{object = NewObject}} + || NewObject = {_Tag, {_ObjectName, _Ref, _Data}} <- NewObjects + ], + #domain_conf_v2_CommitResponse{version = Version} = commit(Revision, Commit, AuthorID), + Version. + +-spec remove([object()], binary()) -> revision() | no_return(). +remove(Objects, AuthorID) -> + Commit = [ + {remove, #domain_conf_v2_RemoveOp{ + ref = Ref + }} + || Ref <- Objects + ], + #domain_conf_v2_CommitResponse{version = Version} = commit(head(), Commit, AuthorID), + Version. + +-spec cleanup([ref()]) -> revision() | no_return(). +cleanup(Refs) -> + remove(Refs, generate_author()). + +generate_author() -> + Random = genlib:unique(), + Params = #domain_conf_v2_AuthorParams{email = Random, name = Random}, + #domain_conf_v2_Author{id = Id} = dmt_client:author_create(Params, #{}), + Id. + +maybe_migrate_version(N) when is_number(N) -> + N; +maybe_migrate_version({version, N}) -> + N; +maybe_migrate_version({head, _}) -> + head(). diff --git a/apps/party_management/test/pm_claim_committer_SUITE.erl b/apps/party_management/test/pm_claim_committer_SUITE.erl index e1cf837..28036a3 100644 --- a/apps/party_management/test/pm_claim_committer_SUITE.erl +++ b/apps/party_management/test/pm_claim_committer_SUITE.erl @@ -73,14 +73,16 @@ all() -> -spec init_per_suite(config()) -> config(). init_per_suite(C) -> {Apps, _Ret} = pm_ct_helper:start_apps([woody, scoper, dmt_client, party_management]), - _ = pm_domain:insert(construct_domain_fixture()), - PartyID = erlang:list_to_binary([?MODULE_STRING, ".", erlang:integer_to_list(erlang:system_time())]), + {_Rev, ObjIds} = pm_domain:insert(construct_domain_fixture()), + PartyID = erlang:list_to_binary([ + ?MODULE_STRING, ".", erlang:integer_to_list(erlang:system_time()) + ]), ApiClient = pm_ct_helper:create_client(), - [{apps, Apps}, {party_id, PartyID}, {api_client, ApiClient} | C]. + [{apps, Apps}, {party_id, PartyID}, {api_client, ApiClient}, {objects_ids, ObjIds} | C]. -spec end_per_suite(config()) -> _. end_per_suite(C) -> - _ = pm_domain:cleanup(), + _ = pm_domain:cleanup(cfg(objects_ids, C)), [application:stop(App) || App <- cfg(apps, C)]. %%% Tests @@ -197,8 +199,12 @@ contract_adjustment_creation(C) -> PartyID = cfg(party_id, C), ContractID = ?REAL_CONTRACT_ID1, ID = <<"ADJ1">>, - AdjustmentParams = #claimmgmt_ContractAdjustmentParams{template = #domain_ContractTemplateRef{id = 2}}, - Modifications = [?cm_contract_modification(ContractID, ?cm_adjustment_creation(ID, AdjustmentParams))], + AdjustmentParams = #claimmgmt_ContractAdjustmentParams{ + template = #domain_ContractTemplateRef{id = 2} + }, + Modifications = [ + ?cm_contract_modification(ContractID, ?cm_adjustment_creation(ID, AdjustmentParams)) + ], Claim = claim(Modifications, PartyID), ok = accept_claim(Claim, C), ok = commit_claim(Claim, C), @@ -304,14 +310,16 @@ shop_complex_modification(C) -> id = <<"ID">>, upper_boundary = 10000, %% Only needs to be set when TurnoverLimit is in dominant config, otherwise skip it - domain_revision = dmt_client:get_last_version() + domain_revision = dmt_client:get_latest_version() } ]), Modifications = [ ?cm_shop_modification(ShopID, {category_modification, NewCategory}), ?cm_shop_modification(ShopID, {details_modification, NewDetails}), ?cm_shop_modification(ShopID, {location_modification, NewLocation}), - ?cm_shop_modification(ShopID, {cash_register_modification_unit, CashRegisterModificationUnit}), + ?cm_shop_modification( + ShopID, {cash_register_modification_unit, CashRegisterModificationUnit} + ), ?cm_shop_modification(ShopID, {turnover_limits_modification, TurnoverLimits}) ], Claim = claim(Modifications, PartyID), @@ -336,10 +344,15 @@ invalid_cash_register_modification(C) -> description = <<"Updated shop description.">> }, AnotherShopID = <<"Totaly not the valid one">>, - Mod = ?cm_shop_modification(AnotherShopID, {cash_register_modification_unit, CashRegisterModificationUnit}), + Mod = ?cm_shop_modification( + AnotherShopID, {cash_register_modification_unit, CashRegisterModificationUnit} + ), Modifications = [?cm_shop_modification(?REAL_SHOP_ID, {details_modification, NewDetails}), Mod], Claim = claim(Modifications, PartyID), - {exception, ?cm_invalid_party_changeset(?cm_invalid_shop_not_exists(AnotherShopID), [{party_modification, Mod}])} = + {exception, + ?cm_invalid_party_changeset(?cm_invalid_shop_not_exists(AnotherShopID), [ + {party_modification, Mod} + ])} = accept_claim(Claim, C). -spec shop_contract_modification(config()) -> _. @@ -380,7 +393,9 @@ contractor_already_exists(C) -> Mod = ?cm_contractor_creation(ContractorID, ContractorParams), Claim = claim([Mod], PartyID), {exception, - ?cm_invalid_party_changeset(?cm_invalid_contractor_already_exists(ContractorID), [{party_modification, Mod}])} = + ?cm_invalid_party_changeset(?cm_invalid_contractor_already_exists(ContractorID), [ + {party_modification, Mod} + ])} = accept_claim(Claim, C). -spec contract_already_exists(config()) -> _. @@ -391,7 +406,9 @@ contract_already_exists(C) -> Mod = ?cm_contract_creation(ContractID, ContractParams), Claim = claim([Mod], PartyID), {exception, - ?cm_invalid_party_changeset(?cm_invalid_contract_already_exists(ContractID), [{party_modification, Mod}])} = + ?cm_invalid_party_changeset(?cm_invalid_contract_already_exists(ContractID), [ + {party_modification, Mod} + ])} = accept_claim(Claim, C). -spec contract_already_terminated(config()) -> _. @@ -402,9 +419,11 @@ contract_already_terminated(C) -> Mod = ?cm_contract_modification(ContractID, {termination, Reason}), Claim = claim([Mod], PartyID), {exception, - ?cm_invalid_party_changeset(?cm_invalid_contract_invalid_status_terminated(ContractID, _), [ - {party_modification, Mod} - ])} = + ?cm_invalid_party_changeset( + ?cm_invalid_contract_invalid_status_terminated(ContractID, _), [ + {party_modification, Mod} + ] + )} = accept_claim(Claim, C). -spec shop_already_exists(config()) -> _. @@ -428,7 +447,10 @@ shop_already_exists(C) -> ?cm_shop_account_creation(ShopID, ?cur(<<"RUB">>)) ], Claim = claim(Modifications, PartyID), - {exception, ?cm_invalid_party_changeset(?cm_invalid_shop_already_exists(ShopID), [{party_modification, Mod}])} = + {exception, + ?cm_invalid_party_changeset(?cm_invalid_shop_already_exists(ShopID), [ + {party_modification, Mod} + ])} = accept_claim(Claim, C). -spec wallet_account_creation(config()) -> _. @@ -492,7 +514,10 @@ claim(PartyModifications, PartyID) -> id = id(), party_id = PartyID, status = {pending, #claimmgmt_ClaimPending{}}, - changeset = [?cm_party_modification(id(), ts(), Mod, UserInfo) || Mod <- PartyModifications], + changeset = [ + ?cm_party_modification(id(), ts(), Mod, UserInfo) + || Mod <- PartyModifications + ], revision = 1, created_at = ts() }. diff --git a/apps/party_management/test/pm_ct_domain.erl b/apps/party_management/test/pm_ct_domain.erl index 79b781f..63e2523 100644 --- a/apps/party_management/test/pm_ct_domain.erl +++ b/apps/party_management/test/pm_ct_domain.erl @@ -1,9 +1,8 @@ -module(pm_ct_domain). --include_lib("damsel/include/dmsl_domain_conf_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_conf_v2_thrift.hrl"). -export([upsert/2]). --export([reset/1]). -export([commit/2]). -export([with/2]). @@ -13,56 +12,55 @@ -type revision() :: pm_domain:revision(). -type object() :: pm_domain:object(). --spec upsert(revision(), object() | [object()]) -> revision() | no_return(). +-spec upsert(revision(), object() | [object()]) -> {revision(), [pm_domain:ref()]} | no_return(). upsert(Revision, NewObject) when not is_list(NewObject) -> upsert(Revision, [NewObject]); upsert(Revision, NewObjects) -> - Commit = #'domain_conf_Commit'{ - ops = lists:foldl( - fun(NewObject = {Tag, {ObjectName, Ref, NewData}}, Ops) -> - case pm_domain:find(Revision, {Tag, Ref}) of - NewData -> - Ops; - notfound -> - [ - {insert, #'domain_conf_InsertOp'{ - object = NewObject - }} - | Ops - ]; - OldData -> - [ - {update, #'domain_conf_UpdateOp'{ - old_object = {Tag, {ObjectName, Ref, OldData}}, - new_object = NewObject - }} - | Ops - ] - end - end, - [], - NewObjects - ) - }, - ok = commit(Revision, Commit), - pm_domain:head(). + Commit = lists:foldl( + fun(NewObject = {Tag, {_ObjectName, Ref, NewData}}, Ops) -> + case pm_domain:find(Revision, {Tag, Ref}) of + NewData -> + Ops; + notfound -> + [ + {insert, #domain_conf_v2_InsertOp{ + object = {Tag, NewData}, + force_ref = {Tag, Ref} + }} + | Ops + ]; + _OldData -> + [ + {update, #domain_conf_v2_UpdateOp{object = NewObject}} + | Ops + ] + end + end, + [], + NewObjects + ), + commit(Revision, Commit). --spec reset(revision()) -> revision() | no_return(). -reset(ToRevision) -> - #'domain_conf_Snapshot'{domain = Domain} = dmt_client:checkout(ToRevision), - upsert(pm_domain:head(), maps:values(Domain)). +-spec commit(revision(), [dmt_client:operation()]) -> {revision(), [pm_domain:ref()]} | no_return(). +commit(Revision, Operations) -> + #domain_conf_v2_CommitResponse{version = Version, new_objects = NewObjects} = + dmt_client:commit(Revision, Operations, generate_author()), + NewObjectsIDs = [ + {Tag, Ref} + || {Tag, {_ON, Ref, _Obj}} <- ordsets:to_list(NewObjects) + ], + {Version, NewObjectsIDs}. --spec commit(revision(), dmt_client:commit()) -> ok | no_return(). -commit(Revision, Commit) -> - Revision = dmt_client:commit(Revision, Commit) - 1, - ok. - --spec with(object() | [object()], fun((revision()) -> R)) -> R | no_return(). +-spec with(object() | [object()], fun((revision()) -> _)) -> + {revision(), [pm_domain:ref()]} | no_return(). with(NewObjects, Fun) -> WasRevision = pm_domain:head(), - Revision = upsert(WasRevision, NewObjects), - try - Fun(Revision) - after - reset(WasRevision) - end. + {Version, NewObjectsIDs} = upsert(WasRevision, NewObjects), + _ = Fun(Version), + {Version, NewObjectsIDs}. + +generate_author() -> + Random = genlib:unique(), + Params = #domain_conf_v2_AuthorParams{email = Random, name = Random}, + #domain_conf_v2_Author{id = Id} = dmt_client:author_create(Params, #{}), + Id. diff --git a/apps/party_management/test/pm_ct_helper.erl b/apps/party_management/test/pm_ct_helper.erl index e8b2958..e30d28d 100644 --- a/apps/party_management/test/pm_ct_helper.erl +++ b/apps/party_management/test/pm_ct_helper.erl @@ -73,8 +73,9 @@ start_app(dmt_client = AppName) -> }} ]}, {service_urls, #{ - 'Repository' => <<"http://dominant:8022/v1/domain/repository">>, - 'RepositoryClient' => <<"http://dominant:8022/v1/domain/repository_client">> + 'Repository' => <<"http://dmt:8022/v1/domain/repository">>, + 'RepositoryClient' => <<"http://dmt:8022/v1/domain/repository_client">>, + 'AuthorManagement' => <<"http://dmt:8022/v1/domain/author">> }} ]), #{} @@ -195,7 +196,9 @@ make_party_params() -> } }. --spec create_battle_ready_shop(category(), currency(), contract_tpl(), payment_institution(), Client :: pid()) -> +-spec create_battle_ready_shop( + category(), currency(), contract_tpl(), payment_institution(), Client :: pid() +) -> shop_id(). create_battle_ready_shop(Category, Currency, TemplateRef, PaymentInstitutionRef, Client) -> ContractID = pm_utils:unique_id(), @@ -284,7 +287,9 @@ adjust_contract(ContractID, TemplateRef, Client) -> Client ). -ensure_claim_accepted(#payproc_Claim{id = ClaimID, revision = ClaimRevision, status = Status}, Client) -> +ensure_claim_accepted( + #payproc_Claim{id = ClaimID, revision = ClaimRevision, status = Status}, Client +) -> case Status of {accepted, _} -> ok; @@ -343,7 +348,8 @@ make_meta_ns() -> make_meta_data() -> make_meta_data(<<"NS-0">>). --spec make_meta_data(dmsl_domain_thrift:'PartyMetaNamespace'()) -> dmsl_domain_thrift:'PartyMetaData'(). +-spec make_meta_data(dmsl_domain_thrift:'PartyMetaNamespace'()) -> + dmsl_domain_thrift:'PartyMetaData'(). make_meta_data(NS) -> {obj, #{ {str, <<"NS">>} => {str, NS}, diff --git a/apps/party_management/test/pm_party_tests_SUITE.erl b/apps/party_management/test/pm_party_tests_SUITE.erl index f87f734..ce3b5cc 100644 --- a/apps/party_management/test/pm_party_tests_SUITE.erl +++ b/apps/party_management/test/pm_party_tests_SUITE.erl @@ -290,12 +290,12 @@ groups() -> -spec init_per_suite(config()) -> config(). init_per_suite(C) -> {Apps, _Ret} = pm_ct_helper:start_apps([woody, scoper, dmt_client, party_management]), - _ = pm_domain:insert(construct_domain_fixture()), - [{apps, Apps} | C]. + {_Rev, ObjIds} = pm_domain:insert(construct_domain_fixture()), + [{apps, Apps}, {objects_ids, ObjIds} | C]. -spec end_per_suite(config()) -> _. end_per_suite(C) -> - _ = pm_domain:cleanup(), + _ = pm_domain:cleanup(cfg(objects_ids, C)), [application:stop(App) || App <- cfg(apps, C)]. %% tests @@ -393,7 +393,9 @@ end_per_testcase(_Name, _C) -> -define(claim(ID), #payproc_Claim{id = ID}). -define(claim(ID, Status), #payproc_Claim{id = ID, status = Status}). --define(claim(ID, Status, Changeset), #payproc_Claim{id = ID, status = Status, changeset = Changeset}). +-define(claim(ID, Status, Changeset), #payproc_Claim{ + id = ID, status = Status, changeset = Changeset +}). -define(claim_not_found(), {exception, #payproc_ClaimNotFound{}} @@ -797,7 +799,9 @@ contract_adjustment_expiration(C) -> Revision ), AfterExpiration = pm_datetime:add_interval(pm_datetime:format_now(), {0, 1, 1}), - Terms = pm_party:get_terms(pm_client_party:get_contract(ContractID, Client), AfterExpiration, Revision), + Terms = pm_party:get_terms( + pm_client_party:get_contract(ContractID, Client), AfterExpiration, Revision + ), pm_context:cleanup(). compute_payment_institution_terms(C) -> @@ -1011,7 +1015,9 @@ shop_terms_retrieval(C) -> ShopID = ?REAL_SHOP_ID, Timestamp = pm_datetime:format_now(), VS = #payproc_ComputeShopTermsVarset{}, - TermSet1 = pm_client_party:compute_shop_terms(ShopID, Timestamp, {timestamp, Timestamp}, VS, Client), + TermSet1 = pm_client_party:compute_shop_terms( + ShopID, Timestamp, {timestamp, Timestamp}, VS, Client + ), ?assertMatch( #domain_TermSet{ payments = #domain_PaymentsServiceTerms{ @@ -1021,7 +1027,9 @@ shop_terms_retrieval(C) -> TermSet1 ), _ = pm_domain:update(construct_term_set_for_party(PartyID, {shop_is, ShopID})), - TermSet2 = pm_client_party:compute_shop_terms(ShopID, pm_datetime:format_now(), {timestamp, Timestamp}, VS, Client), + TermSet2 = pm_client_party:compute_shop_terms( + ShopID, pm_datetime:format_now(), {timestamp, Timestamp}, VS, Client + ), ?assertMatch( #domain_TermSet{ payments = #domain_PaymentsServiceTerms{ @@ -1033,7 +1041,9 @@ shop_terms_retrieval(C) -> shop_already_exists(C) -> Client = cfg(client, C), - Details = pm_ct_helper:make_shop_details(<<"THRlFT SHOP">>, <<"Hot. Fancy. Almost like thrift.">>), + Details = pm_ct_helper:make_shop_details( + <<"THRlFT SHOP">>, <<"Hot. Fancy. Almost like thrift.">> + ), ContractID = ?REAL_CONTRACT_ID, ShopID = ?REAL_SHOP_ID, Params = #payproc_ShopParams{ @@ -1043,7 +1053,9 @@ shop_already_exists(C) -> contract_id = ContractID }, Changeset = [?shop_modification(ShopID, {creation, Params})], - ?invalid_changeset(?invalid_shop(ShopID, {already_exists, _})) = pm_client_party:create_claim(Changeset, Client). + ?invalid_changeset(?invalid_shop(ShopID, {already_exists, _})) = pm_client_party:create_claim( + Changeset, Client + ). shop_update(C) -> Client = cfg(client, C), @@ -1096,7 +1108,9 @@ shop_update_before_confirm(C) -> ok = update_claim(Claim0, Changeset2, Client), Claim1 = pm_client_party:get_claim(pm_claim:get_id(Claim0), Client), ok = accept_claim(Claim1, Client), - #domain_Shop{category = NewCategory, details = NewDetails} = pm_client_party:get_shop(ShopID, Client). + #domain_Shop{category = NewCategory, details = NewDetails} = pm_client_party:get_shop( + ShopID, Client + ). shop_update_with_bad_params(C) -> % FIXME add more invalid params checks @@ -1209,7 +1223,9 @@ complex_claim_acceptance(C) -> ), Client ), - ok = update_claim(Claim1, [?shop_modification(ShopID1, {category_modification, ?cat(3)})], Client), + ok = update_claim( + Claim1, [?shop_modification(ShopID1, {category_modification, ?cat(3)})], Client + ), Claim1_1 = pm_client_party:get_claim(pm_claim:get_id(Claim1), Client), true = Claim1#payproc_Claim.changeset =/= Claim1_1#payproc_Claim.changeset, true = Claim1#payproc_Claim.revision =/= Claim1_1#payproc_Claim.revision, @@ -1220,7 +1236,9 @@ complex_claim_acceptance(C) -> comment = PartyComment, contact_info = #domain_PartyContactInfo{manager_contact_emails = Emails} } = pm_client_party:get(Client), - #domain_Shop{details = Details1, category = ?cat(3)} = pm_client_party:get_shop(ShopID1, Client), + #domain_Shop{details = Details1, category = ?cat(3)} = pm_client_party:get_shop( + ShopID1, Client + ), #domain_Shop{details = Details2} = pm_client_party:get_shop(ShopID2, Client). claim_already_accepted_on_revoke(C) -> @@ -1451,8 +1469,12 @@ shop_account_set_retrieval(C) -> shop_account_retrieval(C) -> Client = cfg(client, C), - {shop_account_set_retrieval, #domain_ShopAccount{guarantee = AccountID}} = ?config(saved_config, C), - #payproc_AccountState{account_id = AccountID} = pm_client_party:get_account_state(AccountID, Client). + {shop_account_set_retrieval, #domain_ShopAccount{guarantee = AccountID}} = ?config( + saved_config, C + ), + #payproc_AccountState{account_id = AccountID} = pm_client_party:get_account_state( + AccountID, Client + ). get_account_state_not_found(C) -> Client = cfg(client, C), @@ -1506,7 +1528,9 @@ contract_w_contractor_creation(C) -> ], Claim = assert_claim_pending(pm_client_party:create_claim(Changeset, Client), Client), ok = accept_claim(Claim, Client), - #domain_Contract{id = ContractID, contractor_id = ContractorID} = pm_client_party:get_contract(ContractID, Client). + #domain_Contract{id = ContractID, contractor_id = ContractorID} = pm_client_party:get_contract( + ContractID, Client + ). %% Compute providers @@ -1542,7 +1566,9 @@ compute_provider_not_found(C) -> Client = cfg(client, C), DomainRevision = pm_domain:head(), {exception, #payproc_ProviderNotFound{}} = - (catch pm_client_party:compute_provider(?prv(?WRONG_DMT_OBJ_ID), DomainRevision, #payproc_Varset{}, Client)). + (catch pm_client_party:compute_provider( + ?prv(?WRONG_DMT_OBJ_ID), DomainRevision, #payproc_Varset{}, Client + )). compute_provider_terminal_terms_ok(C) -> Client = cfg(client, C), @@ -1594,7 +1620,9 @@ compute_provider_terminal_terms_ok(C) -> recurrent_paytools = #domain_RecurrentPaytoolsProvisionTerms{ cash_value = {value, ?cash(1000, <<"RUB">>)} } - } = pm_client_party:compute_provider_terminal_terms(?prv(1), ?trm(1), DomainRevision, Varset, Client). + } = pm_client_party:compute_provider_terminal_terms( + ?prv(1), ?trm(1), DomainRevision, Varset, Client + ). compute_provider_terminal_terms_global_allow_ok(C) -> Client = cfg(client, C), @@ -1610,7 +1638,9 @@ compute_provider_terminal_terms_global_allow_ok(C) -> global_allow = {constant, false} } }, - pm_client_party:compute_provider_terminal_terms(?prv(3), ?trm(5), DomainRevision, Varset0, Client) + pm_client_party:compute_provider_terminal_terms( + ?prv(3), ?trm(5), DomainRevision, Varset0, Client + ) ), Varset1 = Varset0#payproc_Varset{party_id = <<"PARTYID2">>}, ?assertEqual( @@ -1620,7 +1650,9 @@ compute_provider_terminal_terms_global_allow_ok(C) -> global_allow = {constant, false} } }, - pm_client_party:compute_provider_terminal_terms(?prv(3), ?trm(5), DomainRevision, Varset1, Client) + pm_client_party:compute_provider_terminal_terms( + ?prv(3), ?trm(5), DomainRevision, Varset1, Client + ) ), Varset2 = Varset0#payproc_Varset{amount = ?cash(101, <<"RUB">>)}, ?assertEqual( @@ -1630,7 +1662,9 @@ compute_provider_terminal_terms_global_allow_ok(C) -> global_allow = {constant, true} } }, - pm_client_party:compute_provider_terminal_terms(?prv(3), ?trm(5), DomainRevision, Varset2, Client) + pm_client_party:compute_provider_terminal_terms( + ?prv(3), ?trm(5), DomainRevision, Varset2, Client + ) ). compute_provider_terminal_terms_not_found(C) -> @@ -1824,7 +1858,9 @@ compute_payment_routing_ruleset_not_found(C) -> Client = cfg(client, C), DomainRevision = pm_domain:head(), {exception, #payproc_RuleSetNotFound{}} = - (catch pm_client_party:compute_routing_ruleset(?ruleset(5), DomainRevision, #payproc_Varset{}, Client)). + (catch pm_client_party:compute_routing_ruleset( + ?ruleset(5), DomainRevision, #payproc_Varset{}, Client + )). %% @@ -1898,29 +1934,34 @@ compute_terms_w_criteria(C) -> {inclusive, ?cash(10, <<"KZT">>)}, {exclusive, ?cash(100, <<"KZT">>)} ), - pm_ct_domain:with( - [ - pm_ct_fixture:construct_criterion( - CritBase, - <<"Visas">>, - {all_of, - ?ordset([ + WasRevision = pm_domain:head(), + % TODO it's a weak point for cleanup, as we don't update Config with new IDs + {_, _NewIDs0} = pm_ct_domain:upsert( + WasRevision, + pm_ct_fixture:construct_criterion( + CritBase, + <<"Visas">>, + {all_of, + ?ordset([ + {condition, + {payment_tool, + {bank_card, #domain_BankCardCondition{ + definition = + {payment_system, #domain_PaymentSystemCondition{ + payment_system_is = ?pmt_sys(<<"visa">>) + }} + }}}}, + {is_not, {condition, {payment_tool, {bank_card, #domain_BankCardCondition{ - definition = - {payment_system, #domain_PaymentSystemCondition{ - payment_system_is = ?pmt_sys(<<"visa">>) - }} - }}}}, - {is_not, - {condition, - {payment_tool, - {bank_card, #domain_BankCardCondition{ - definition = {empty_cvv_is, true} - }}}}} - ])} - ), + definition = {empty_cvv_is, true} + }}}}} + ])} + ) + ), + {_, _NewIDs1} = pm_ct_domain:with( + [ pm_ct_fixture:construct_criterion( CritRef, <<"Kazakh Visas">>, @@ -2020,7 +2061,9 @@ update_claim(#payproc_Claim{id = ClaimID, revision = Revision}, Changeset, Clien accept_claim(#payproc_Claim{id = ClaimID, revision = Revision}, Client) -> ok = pm_client_party:accept_claim(ClaimID, Revision, Client), NextRevision = Revision + 1, - [?claim_status_changed(ClaimID, ?accepted(_), NextRevision, _), ?revision_changed(_, _)] = next_event(Client), + [?claim_status_changed(ClaimID, ?accepted(_), NextRevision, _), ?revision_changed(_, _)] = next_event( + Client + ), ok. deny_claim(#payproc_Claim{id = ClaimID, revision = Revision}, Client) -> @@ -2214,11 +2257,14 @@ construct_domain_fixture() -> ), #domain_PaymentMethodDecision{ if_ = {condition, {payment_tool, {bank_card, #domain_BankCardCondition{}}}}, - then_ = {value, ordsets:from_list([?pmt(bank_card, ?bank_card(<<"mastercard">>))])} + then_ = + {value, ordsets:from_list([?pmt(bank_card, ?bank_card(<<"mastercard">>))])} }, #domain_PaymentMethodDecision{ - if_ = {condition, {payment_tool, {payment_terminal, #domain_PaymentTerminalCondition{}}}}, - then_ = {value, ordsets:from_list([?pmt(payment_terminal, ?pmt_srv(<<"euroset">>))])} + if_ = + {condition, {payment_tool, {payment_terminal, #domain_PaymentTerminalCondition{}}}}, + then_ = + {value, ordsets:from_list([?pmt(payment_terminal, ?pmt_srv(<<"euroset">>))])} }, #domain_PaymentMethodDecision{ if_ = {constant, true}, @@ -2246,10 +2292,18 @@ construct_domain_fixture() -> payment_methods = {decisions, [ mk_payment_decision( - {bank_card, #domain_BankCardCondition{definition = {issuer_bank_is, ?bank(1)}}}, - [?pmt(bank_card, ?bank_card(<<"visa">>)), ?pmt(crypto_currency, ?crypta(<<"bitcoin">>))] + {bank_card, #domain_BankCardCondition{ + definition = {issuer_bank_is, ?bank(1)} + }}, + [ + ?pmt(bank_card, ?bank_card(<<"visa">>)), + ?pmt(crypto_currency, ?crypta(<<"bitcoin">>)) + ] + ), + mk_payment_decision( + {bank_card, #domain_BankCardCondition{definition = {empty_cvv_is, true}}}, + [] ), - mk_payment_decision({bank_card, #domain_BankCardCondition{definition = {empty_cvv_is, true}}}, []), mk_payment_decision( {bank_card, #domain_BankCardCondition{}}, [?pmt(bank_card, ?bank_card(<<"visa">>))] @@ -2436,7 +2490,10 @@ construct_domain_fixture() -> {inclusive, ?cash(0, <<"RUB">>)}, {exclusive, ?cash(3000, <<"RUB">>)} )}}, - then_ = {value, #domain_Fees{fees = #{surplus => ?fixed(50, <<"RUB">>)}}} + then_ = + {value, #domain_Fees{ + fees = #{surplus => ?fixed(50, <<"RUB">>)} + }} }, #domain_FeeDecision{ if_ = @@ -2447,7 +2504,11 @@ construct_domain_fixture() -> {exclusive, ?cash(300000, <<"RUB">>)} )}}, then_ = - {value, #domain_Fees{fees = #{surplus => ?share(4, 100, operation_amount)}}} + {value, #domain_Fees{ + fees = #{ + surplus => ?share(4, 100, operation_amount) + } + }} } ]} } @@ -2526,7 +2587,9 @@ construct_domain_fixture() -> pm_ct_fixture:construct_payment_method(?pmt(bank_card, ?bank_card(<<"mastercard">>))), pm_ct_fixture:construct_payment_method(?pmt(bank_card, ?bank_card(<<"maestro">>))), pm_ct_fixture:construct_payment_method(?pmt(bank_card, ?bank_card(<<"jcb">>))), - pm_ct_fixture:construct_payment_method(?pmt(bank_card, ?token_bank_card(<<"visa">>, <<"applepay">>))), + pm_ct_fixture:construct_payment_method( + ?pmt(bank_card, ?token_bank_card(<<"visa">>, <<"applepay">>)) + ), pm_ct_fixture:construct_payment_method(?pmt(payment_terminal, ?pmt_srv(<<"alipay">>))), pm_ct_fixture:construct_payment_method(?pmt(digital_wallet, ?pmt_srv(<<"qiwi">>))), pm_ct_fixture:construct_payment_method(?pmt(mobile, ?mob(<<"mts">>))), @@ -2802,7 +2865,8 @@ construct_domain_fixture() -> {condition, {payment_tool, {bank_card, #domain_BankCardCondition{ - definition = {issuer_bank_is, #domain_BankRef{id = 1}} + definition = + {issuer_bank_is, #domain_BankRef{id = 1}} }}}}, then_ = {value, @@ -2836,7 +2900,10 @@ construct_domain_fixture() -> {condition, {payment_tool, {bank_card, #domain_BankCardCondition{ - definition = {issuer_bank_is, #domain_BankRef{id = 1}} + definition = + {issuer_bank_is, #domain_BankRef{ + id = 1 + }} }}}}}, then_ = {value, diff --git a/compose.tracing.yaml b/compose.tracing.yaml index bed28a3..4fc2ec7 100644 --- a/compose.tracing.yaml +++ b/compose.tracing.yaml @@ -1,6 +1,6 @@ services: - dominant: + dmt: environment: &otlp_enabled OTEL_TRACES_EXPORTER: otlp OTEL_TRACES_SAMPLER: parentbased_always_off diff --git a/compose.yaml b/compose.yaml index 3a8f51a..4fda2aa 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,5 +1,4 @@ services: - testrunner: image: $DEV_IMAGE_TAG build: @@ -15,28 +14,51 @@ services: depends_on: machinegun: condition: service_healthy - dominant: + dmt: condition: service_healthy shumway: condition: service_started + holmes: + condition: service_started ports: - "8022:8022" command: /sbin/init - dominant: - image: ghcr.io/valitydev/dominant:sha-c0ebc36 - depends_on: - - machinegun + dmt: + image: ghcr.io/valitydev/dominant-v2:sha-67b1207-epic-fixes_for_client + command: /opt/dmt/bin/dmt foreground + healthcheck: + test: "/opt/dmt/bin/dmt ping" + interval: 5s + timeout: 3s + retries: 12 ports: - - "8022" - command: /opt/dominant/bin/dominant foreground + - 8022:8022 + hostname: dmt + environment: + POSTGRES_HOST: dmt-db + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: dmt + depends_on: + dmt-db: + condition: service_healthy volumes: - - ./test/dominant/sys.config:/opt/dominant/releases/0.1/sys.config + - ./test/dmt/sys.config:/opt/dmt/releases/0.1/sys.config + + dmt-db: + image: postgres + environment: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: dmt + ports: + - 5432:5432 healthcheck: - test: "/opt/dominant/bin/dominant ping" + test: ["CMD-SHELL", "pg_isready -U postgres"] interval: 5s - timeout: 1s - retries: 20 + timeout: 5s + retries: 5 machinegun: image: ghcr.io/valitydev/mg2:sha-8bbcd29 @@ -78,3 +100,6 @@ services: - POSTGRES_DB=shumway - POSTGRES_USER=postgres - POSTGRES_PASSWORD=postgres + + holmes: + image: ghcr.io/valitydev/holmes:sha-fdf0020 diff --git a/rebar.config b/rebar.config index 89a132b..a41ded6 100644 --- a/rebar.config +++ b/rebar.config @@ -32,10 +32,10 @@ {prometheus, "4.11.0"}, {prometheus_cowboy, "0.1.9"}, {woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.0"}}}, - {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "master"}}}, + {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "IMP-281/dmt_v2_proto"}}}, {payproc_errors, {git, "https://github.com/valitydev/payproc-errors-erlang.git", {branch, "master"}}}, {mg_proto, {git, "https://github.com/valitydev/machinegun-proto.git", {branch, "master"}}}, - {dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {branch, "master"}}}, + {dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {branch, "v2"}}}, {scoper, {git, "https://github.com/valitydev/scoper.git", {tag, "v1.1.0"}}}, {erl_health, {git, "https://github.com/valitydev/erlang-health.git", {branch, "master"}}}, diff --git a/rebar.lock b/rebar.lock index ca30103..93ea03f 100644 --- a/rebar.lock +++ b/rebar.lock @@ -13,11 +13,11 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"81d1edce2043500e4581867da3f5f4c31e682f44"}}, + {ref,"04968091317ce221085fc260b231329177e5cc96"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt_client.git", - {ref,"d8a4f490d49c038d96f1cbc2a279164c6f4039f9"}}, + {ref,"d877bba8fe9fc585e8595d3e2fca55598cc53b48"}}, 0}, {<<"dmt_core">>, {git,"https://github.com/valitydev/dmt-core.git", @@ -43,22 +43,19 @@ {ref,"3decc8f8b13c9cd1701deab47781aacddd7dbc92"}}, 0}, {<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.3.0">>},2}, - {<<"opentelemetry">>,{pkg,<<"opentelemetry">>,<<"1.3.0">>},0}, - {<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.2.1">>},0}, + {<<"opentelemetry">>,{pkg,<<"opentelemetry">>,<<"1.5.0">>},0}, + {<<"opentelemetry_api">>,{pkg,<<"opentelemetry_api">>,<<"1.4.0">>},0}, {<<"opentelemetry_exporter">>, {pkg,<<"opentelemetry_exporter">>,<<"1.8.0">>}, 0}, - {<<"opentelemetry_semantic_conventions">>, - {pkg,<<"opentelemetry_semantic_conventions">>,<<"0.2.0">>}, - 1}, {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2}, {<<"payproc_errors">>, {git,"https://github.com/valitydev/payproc-errors-erlang.git", {ref,"8ae8586239ef68098398acf7eb8363d9ec3b3234"}}, 0}, - {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.8.1">>},0}, + {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.11.0">>},0}, {<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.9">>},0}, - {<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.13">>},1}, + {<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.14">>},1}, {<<"quantile_estimator">>,{pkg,<<"quantile_estimator">>,<<"0.2.1">>},1}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2}, {<<"scoper">>, @@ -72,15 +69,15 @@ {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.7">>},2}, {<<"thrift">>, {git,"https://github.com/valitydev/thrift_erlang.git", - {ref,"c280ff266ae1c1906fb0dcee8320bb8d8a4a3c75"}}, + {ref,"3a60e5dc5bbd709495024f26e100b041c3547fd9"}}, 1}, {<<"tls_certificate_check">>, - {pkg,<<"tls_certificate_check">>,<<"1.26.0">>}, + {pkg,<<"tls_certificate_check">>,<<"1.27.0">>}, 1}, {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2}, {<<"woody">>, {git,"https://github.com/valitydev/woody_erlang.git", - {ref,"072825ee7179825a4078feb0649df71303c74157"}}, + {ref,"cc983a9423325ba1d6a509775eb6ff7ace721539"}}, 0}]}. [ {pkg_hash,[ @@ -100,18 +97,17 @@ {<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>}, {<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>}, {<<"mimerl">>, <<"D0CD9FC04B9061F82490F6581E0128379830E78535E017F7780F37FEA7545726">>}, - {<<"opentelemetry">>, <<"988AC3C26ACAC9720A1D4FB8D9DC52E95B45ECFEC2D5B5583276A09E8936BC5E">>}, - {<<"opentelemetry_api">>, <<"7B69ED4F40025C005DE0B74FCE8C0549625D59CB4DF12D15C32FE6DC5076FF42">>}, + {<<"opentelemetry">>, <<"7DDA6551EDFC3050EA4B0B40C0D2570423D6372B97E9C60793263EF62C53C3C2">>}, + {<<"opentelemetry_api">>, <<"63CA1742F92F00059298F478048DFB826F4B20D49534493D6919A0DB39B6DB04">>}, {<<"opentelemetry_exporter">>, <<"5D546123230771EF4174E37BEDFD77E3374913304CD6EA3CA82A2ADD49CD5D56">>}, - {<<"opentelemetry_semantic_conventions">>, <<"B67FE459C2938FCAB341CB0951C44860C62347C005ACE1B50F8402576F241435">>}, {<<"parse_trans">>, <<"16328AB840CC09919BD10DAB29E431DA3AF9E9E7E7E6F0089DD5A2D2820011D8">>}, - {<<"prometheus">>, <<"FA76B152555273739C14B06F09F485CF6D5D301FE4E9D31B7FF803D26025D7A0">>}, + {<<"prometheus">>, <<"B95F8DE8530F541BD95951E18E355A840003672E5EDA4788C5FA6183406BA29A">>}, {<<"prometheus_cowboy">>, <<"D9D5B300516A61ED5AE31391F8EEEEB202230081D32A1813F2D78772B6F274E1">>}, - {<<"prometheus_httpd">>, <<"F086390B4E4E3F41112889B745BAC53D26437B6139496E6700C2508858F5985B">>}, + {<<"prometheus_httpd">>, <<"529A63CA2A451FC5D28C77020787A75AF661DADF721E7EC14B5842412FB67A32">>}, {<<"quantile_estimator">>, <<"EF50A361F11B5F26B5F16D0696E46A9E4661756492C981F7B2229EF42FF1CD15">>}, {<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>}, {<<"ssl_verify_fun">>, <<"354C321CF377240C7B8716899E182CE4890C5938111A1296ADD3EC74CF1715DF">>}, - {<<"tls_certificate_check">>, <<"C0E8FFAB875748F2B122D4D4E465AEAA7249EA539F1004B7922CB3C61FFE261D">>}, + {<<"tls_certificate_check">>, <<"2C1C7FC922A329B9EB45DDF39113C998BBDEB28A534219CD884431E2AEE1811E">>}, {<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]}, {pkg_hash_ext,[ {<<"accept">>, <<"A5167FA1AE90315C3F1DD189446312F8A55D00EFA357E9C569BDA47736B874C3">>}, @@ -130,17 +126,16 @@ {<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>}, {<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>}, {<<"mimerl">>, <<"A1E15A50D1887217DE95F0B9B0793E32853F7C258A5CD227650889B38839FE9D">>}, - {<<"opentelemetry">>, <<"8E09EDC26AAD11161509D7ECAD854A3285D88580F93B63B0B1CF0BAC332BFCC0">>}, - {<<"opentelemetry_api">>, <<"6D7A27B7CAD2AD69A09CABF6670514CAFCEC717C8441BEB5C96322BAC3D05350">>}, + {<<"opentelemetry">>, <<"CDF4F51D17B592FC592B9A75F86A6F808C23044BA7CF7B9534DEBBCC5C23B0EE">>}, + {<<"opentelemetry_api">>, <<"3DFBBFAA2C2ED3121C5C483162836C4F9027DEF469C41578AF5EF32589FCFC58">>}, {<<"opentelemetry_exporter">>, <<"A1F9F271F8D3B02B81462A6BFEF7075FD8457FDB06ADFF5D2537DF5E2264D9AF">>}, - {<<"opentelemetry_semantic_conventions">>, <<"D61FA1F5639EE8668D74B527E6806E0503EFC55A42DB7B5F39939D84C07D6895">>}, {<<"parse_trans">>, <<"07CD9577885F56362D414E8C4C4E6BDF10D43A8767ABB92D24CBE8B24C54888B">>}, - {<<"prometheus">>, <<"6EDFBE928D271C7F657A6F2C46258738086584BD6CAE4A000B8B9A6009BA23A5">>}, + {<<"prometheus">>, <<"719862351AABF4DF7079B05DC085D2BBCBE3AC0AC3009E956671B1D5AB88247D">>}, {<<"prometheus_cowboy">>, <<"5F71C039DEB9E9FF9DD6366BC74C907A463872B85286E619EFF0BDA15111695A">>}, - {<<"prometheus_httpd">>, <<"9B5A44D1F6FBB3C3FE6F85F06DAFE680AD9FFD591EC65A10BB51DFF0FBBE45D2">>}, + {<<"prometheus_httpd">>, <<"8B39F8CB6467B80D648FB982FDEB796BAB006BB43B1C95279289F311DB562D4E">>}, {<<"quantile_estimator">>, <<"282A8A323CA2A845C9E6F787D166348F776C1D4A41EDE63046D72D422E3DA946">>}, {<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>}, {<<"ssl_verify_fun">>, <<"FE4C190E8F37401D30167C8C405EDA19469F34577987C76DDE613E838BBC67F8">>}, - {<<"tls_certificate_check">>, <<"1BAD73D88637F788B554A8E939C25DB2BDAAC88B10FFFD5BBA9D1B65F43A6B54">>}, + {<<"tls_certificate_check">>, <<"51A5AD3DBD72D4694848965F3B5076E8B55D70EB8D5057FCDDD536029AB8A23C">>}, {<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]} ]. diff --git a/test/dmt/sys.config b/test/dmt/sys.config new file mode 100644 index 0000000..07082a6 --- /dev/null +++ b/test/dmt/sys.config @@ -0,0 +1,83 @@ +[ + {kernel, [ + {logger_level, info}, + {logger, [ + {handler, default, logger_std_h, #{ + config => #{ + type => standard_io + }, + formatter => {logger_logstash_formatter, #{ + log_level_map => #{ + emergency => 'ERROR', + alert => 'ERROR', + critical => 'ERROR', + error => 'ERROR', + warning => 'WARN', + notice => 'INFO', + info => 'INFO', + debug => 'DEBUG' + } + }} + }} + ]} + ]}, + + {dmt, [ + {host, <<"dmt">>}, + {port, 8022} + ]}, + + {woody, [ + {acceptors_pool_size, 4} + ]}, + + {epg_connector, [ + {databases, #{ + default_db => #{ + host => "dmt-db", + port => 5432, + username => "postgres", + password => "postgres", + database => "dmt" + } + }}, + {pools, #{ + default_pool => #{ + database => default_db, + size => 10 + }, + author_pool => #{ + database => default_db, + size => 10 + } + }} + ]}, + + {scoper, [ + {storage, scoper_storage_logger} + ]}, + + {prometheus, [ + {collectors, [ + default + ]} + ]}, + + {opentelemetry, [ + {span_processor, batch}, + {traces_exporter, otlp}, + {sampler, + {parent_based, #{ + root => always_off, + remote_parent_sampled => always_on, + remote_parent_not_sampled => always_off, + local_parent_sampled => always_on, + local_parent_not_sampled => always_off + }}} + ]}, + + {opentelemetry_exporter, [ + {otlp_protocol, http_protobuf}, + {otlp_endpoint, "http://jaeger:4318"} + ]} +]. diff --git a/test/dominant/sys.config b/test/dominant/sys.config deleted file mode 100644 index c41852e..0000000 --- a/test/dominant/sys.config +++ /dev/null @@ -1,119 +0,0 @@ -%% NOTE Consider DRYing config in composed services -[ - {opentelemetry, [ - {span_processor, batch}, - {traces_exporter, otlp}, - {sampler, - {parent_based, #{ - root => always_off, - remote_parent_sampled => always_on, - remote_parent_not_sampled => always_off, - local_parent_sampled => always_on, - local_parent_not_sampled => always_off - }}} - ]}, - - {opentelemetry_exporter, [ - {otlp_protocol, http_protobuf}, - {otlp_endpoint, "http://jaeger:4318"} - ]}, - - {kernel, [ - {logger_level, info}, - {logger, [ - {handler, default, logger_std_h, #{ - config => #{ - type => standard_io - }, - formatter => {logger_logstash_formatter, #{ - log_level_map => #{ - emergency => 'ERROR', - alert => 'ERROR', - critical => 'ERROR', - error => 'ERROR', - warning => 'WARN', - notice => 'INFO', - info => 'INFO', - debug => 'DEBUG' - } - }} - }} - ]} - ]}, - - {dmt_api, [ - {repository, dmt_api_repository_v5}, - {migration, #{ - timeout => 360, - limit => 20, - read_only_gap => 1000 - }}, - {ip, "::"}, - {port, 8022}, - {default_woody_handling_timeout, 30000}, - {woody_event_handlers, [ - {scoper_woody_event_handler, #{ - event_handler_opts => #{ - formatter_opts => #{ - max_length => 1000, - max_printable_string_length => 80 - } - } - }} - ]}, - {transport_opts, #{ - max_connections => 1024 - }}, - {protocol_opts, #{ - % http keep alive timeout in ms - request_timeout => 60000, - % Should be greater than any other timeouts - idle_timeout => infinity - }}, - % 50Mb - {max_cache_size, 52428800}, - {health_check, #{ - disk => {erl_health, disk, ["/", 99]}, - memory => {erl_health, cg_memory, [99]}, - service => {erl_health, service, [<<"dominant">>]} - }}, - {services, #{ - automaton => #{ - url => "http://machinegun:8022/v1/automaton", - transport_opts => #{ - pool => woody_automaton, - timeout => 1000, - max_connections => 1024 - } - } - }} - ]}, - - {os_mon, [ - % for better compatibility with busybox coreutils - {disksup_posix_only, true} - ]}, - - {scoper, [ - {storage, scoper_storage_logger} - ]}, - - {snowflake, [ - {max_backward_clock_moving, 1000}, % 1 second - {machine_id, hostname_hash} - ]}, - - {prometheus, [ - {collectors, [default]} - ]}, - - {how_are_you, [ - {metrics_publishers, [ - % {hay_statsd_publisher, #{ - % key_prefix => <<"dominant.">>, - % host => "localhost", - % port => 8125 - % }} - ]} - ]} -].