diff --git a/.github/workflows/tag-action.yml b/.github/workflows/tag-action.yml new file mode 100644 index 00000000..ec3faf40 --- /dev/null +++ b/.github/workflows/tag-action.yml @@ -0,0 +1,18 @@ +name: Create Tag + +on: + push: + branches: + - master + +jobs: + build: + runs-on: ubuntu-latest + steps: + - name: Checkout Repo + uses: actions/checkout@v3 + + - uses: valitydev/action-tagger@v2 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + with-v: true diff --git a/Makefile b/Makefile index b1ca4cdf..86242248 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 @@ -64,6 +64,16 @@ wdeps-%: dev-image $(DOCKERCOMPOSE_W_ENV) down; \ exit $$res +# Database tasks + +ifeq (db,$(firstword $(MAKECMDGOALS))) + DATABASE_NAME := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) + $(eval $(DATABASE_NAME):;@:) +endif + +db: + $(DOCKERCOMPOSE_W_ENV) exec db bash -c "PGPASSWORD=postgres psql -U $(DATABASE_NAME) -d $(DATABASE_NAME)" + # Rebar tasks rebar-shell: diff --git a/apps/hellgate/src/hg_domain.erl b/apps/hellgate/src/hg_domain.erl index 6c23e3ea..ce064f68 100644 --- a/apps/hellgate/src/hg_domain.erl +++ b/apps/hellgate/src/hg_domain.erl @@ -6,29 +6,23 @@ -module(hg_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"). %% -export([head/0]). -export([get/1]). -export([get/2]). --export([get_without_exp/2]). --export([find/2]). --export([exists/2]). --export([commit/2]). -export([reset/1]). -export([insert/1]). -export([update/1]). -export([upsert/1]). --export([remove/1]). -export([cleanup/0]). %% --type revision() :: dmt_client:version(). +-type revision() :: dmt_client:vsn(). -type ref() :: dmsl_domain_thrift:'Reference'(). -type object() :: dmsl_domain_thrift:'DomainObject'(). -type data() :: _. @@ -42,7 +36,7 @@ -spec head() -> revision(). head() -> - dmt_client:get_last_version(). + dmt_client:get_latest_version(). -spec get(ref()) -> data() | no_return(). get(Ref) -> @@ -53,69 +47,59 @@ get(Revision, Ref) -> try extract_data(dmt_client:checkout_object(Revision, Ref)) catch - throw:#domain_conf_ObjectNotFound{} -> + throw:#domain_conf_v2_ObjectNotFound{} -> error({object_not_found, {Revision, Ref}}) end. --spec get_without_exp(dmt_client:version(), ref()) -> data() | get_error(). -get_without_exp(Revision, Ref) -> - try - extract_data(dmt_client:checkout_object(Revision, Ref)) - catch - throw:#domain_conf_ObjectNotFound{} -> - {object_not_found, {Revision, Ref}} - end. - --spec find(revision(), ref()) -> data() | notfound. -find(Revision, Ref) -> - try - extract_data(dmt_client:checkout_object(Revision, Ref)) - catch - throw:#domain_conf_ObjectNotFound{} -> - notfound - end. - --spec exists(revision(), ref()) -> boolean(). -exists(Revision, Ref) -> - try - _ = dmt_client:checkout_object(Revision, Ref), - true - catch - throw:#domain_conf_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 reset(revision()) -> revision() | no_return(). reset(ToRevision) -> - #domain_conf_Snapshot{domain = Domain} = dmt_client:checkout(ToRevision), - upsert(maps:values(Domain)). + Objects = dmt_client:checkout_all(ToRevision), + upsert(unwrap_versioned_objects(Objects)). %% convenience shortcuts, use carefully -spec insert(object() | [object()]) -> revision() | no_return(). insert(ObjectOrMany) -> - dmt_client:insert(ObjectOrMany). + dmt_client:insert(ObjectOrMany, ensure_stub_author()). -spec update(object() | [object()]) -> revision() | no_return(). update(NewObjectOrMany) -> - dmt_client:update(NewObjectOrMany). + dmt_client:update(NewObjectOrMany, ensure_stub_author()). -spec upsert(object() | [object()]) -> revision() | no_return(). upsert(NewObjectOrMany) -> - dmt_client:upsert(NewObjectOrMany). + %% NOTE Checkout all objects from target version to ensure it all + %% cached before operations preparation. + Version = dmt_client:get_latest_version(), + _ = dmt_client:checkout_all(Version), + dmt_client:upsert(Version, NewObjectOrMany, ensure_stub_author()). -spec remove(object() | [object()]) -> revision() | no_return(). remove(ObjectOrMany) -> - dmt_client:remove(ObjectOrMany). + dmt_client:remove(ObjectOrMany, ensure_stub_author()). -spec cleanup() -> revision() | no_return(). cleanup() -> - #domain_conf_Snapshot{domain = Domain} = dmt_client:checkout(latest), - remove(maps:values(Domain)). + Objects = dmt_client:checkout_all(latest), + remove(unwrap_versioned_objects(Objects)). + +ensure_stub_author() -> + %% TODO DISCUSS Stubs and fallback authors + ensure_author(~b"unknown", ~b"unknown@local"). + +ensure_author(Name, Email) -> + try + #domain_conf_v2_Author{id = ID} = dmt_client:get_author_by_email(Email), + ID + catch + throw:#domain_conf_v2_AuthorNotFound{} -> + dmt_client:create_author(Name, Email) + end. + +%% + +unwrap_versioned_objects(VersionedObjects) -> + lists:map(fun(#domain_conf_v2_VersionedObject{object = Object}) -> Object end, VersionedObjects). diff --git a/apps/hellgate/src/hg_invoice_payment_refund.erl b/apps/hellgate/src/hg_invoice_payment_refund.erl index b5dfc55a..c1b15a33 100644 --- a/apps/hellgate/src/hg_invoice_payment_refund.erl +++ b/apps/hellgate/src/hg_invoice_payment_refund.erl @@ -88,7 +88,7 @@ -type session() :: hg_session:t(). -type trx_info() :: dmsl_domain_thrift:'TransactionInfo'(). -type failure() :: dmsl_domain_thrift:'OperationFailure'(). --type revision() :: dmt_client:version(). +-type revision() :: dmt_client:vsn(). -type cash() :: dmsl_domain_thrift:'Cash'(). -type timestamp() :: dmsl_base_thrift:'Timestamp'(). -type route() :: dmsl_domain_thrift:'PaymentRoute'(). diff --git a/apps/hellgate/test/hg_ct_helper.erl b/apps/hellgate/test/hg_ct_helper.erl index 168dcd22..b9f065bf 100644 --- a/apps/hellgate/test/hg_ct_helper.erl +++ b/apps/hellgate/test/hg_ct_helper.erl @@ -115,8 +115,9 @@ start_app(dmt_client = AppName) -> }} ]}, {service_urls, #{ - 'Repository' => <<"http://dominant:8022/v1/domain/repository">>, - 'RepositoryClient' => <<"http://dominant:8022/v1/domain/repository_client">> + 'AuthorManagement' => <<"http://dmt:8022/v1/domain/author">>, + 'Repository' => <<"http://dmt:8022/v1/domain/repository">>, + 'RepositoryClient' => <<"http://dmt:8022/v1/domain/repository_client">> }} ]), #{} @@ -268,11 +269,11 @@ start_app(epg_connector = AppName) -> start_app(AppName, [ {databases, #{ default_db => #{ - host => "postgres", + host => "db", port => 5432, - database => "progressor_db", - username => "progressor", - password => "progressor" + database => "hellgate", + username => "hellgate", + password => "postgres" } }}, {pools, #{ diff --git a/apps/hellgate/test/hg_invoice_tests_SUITE.erl b/apps/hellgate/test/hg_invoice_tests_SUITE.erl index 765438bd..2a02baf4 100644 --- a/apps/hellgate/test/hg_invoice_tests_SUITE.erl +++ b/apps/hellgate/test/hg_invoice_tests_SUITE.erl @@ -641,7 +641,7 @@ end). -spec init_per_group(group_name(), config()) -> config(). init_per_group(route_cascading, C) -> - init_route_cascading_group(C); + [{pre_group_domain_revision, hg_domain:head()} | init_route_cascading_group(C)]; init_per_group(operation_limits, C) -> init_operation_limits_group(C); init_per_group(repair_preproc_w_limits, C) -> @@ -650,8 +650,14 @@ init_per_group(_, C) -> C. -spec end_per_group(group_name(), config()) -> _. -end_per_group(_Group, _C) -> - ok. +end_per_group(_Group, C) -> + case cfg(pre_group_domain_revision, C) of + Revision when is_integer(Revision) -> + _ = hg_domain:reset(Revision), + ok; + undefined -> + ok + end. -spec init_per_testcase(test_case_name(), config()) -> config(). init_per_testcase(Name, C) when @@ -1185,7 +1191,7 @@ payment_shop_limit_success(C) -> #domain_TurnoverLimit{ id = ?SHOPLIMIT_ID, upper_boundary = ?LIMIT_UPPER_BOUNDARY, - domain_revision = dmt_client:get_last_version() + domain_revision = hg_domain:head() } ], ShopID = hg_ct_helper:create_shop(PartyID, ?cat(1), <<"RUB">>, ?trms(1), ?pinst(1), TurnoverLimits, PartyClient), @@ -1206,7 +1212,7 @@ payment_shop_limit_overflow(C) -> #domain_TurnoverLimit{ id = ?SHOPLIMIT_ID, upper_boundary = ?LIMIT_UPPER_BOUNDARY, - domain_revision = dmt_client:get_last_version() + domain_revision = hg_domain:head() } ]), ShopID = hg_ct_helper:create_shop(PartyID, ?cat(1), <<"RUB">>, ?trms(1), ?pinst(1), TurnoverLimits, PartyClient), @@ -1229,7 +1235,7 @@ payment_shop_limit_more_overflow(C) -> #domain_TurnoverLimit{ id = ?SHOPLIMIT_ID, upper_boundary = ?LIMIT_UPPER_BOUNDARY, - domain_revision = dmt_client:get_last_version() + domain_revision = hg_domain:head() } ]), ShopID = hg_ct_helper:create_shop(PartyID, ?cat(1), <<"RUB">>, ?trms(1), ?pinst(1), TurnoverLimits, PartyClient), @@ -6009,7 +6015,9 @@ cascade_fixture(Revision, C) -> init_route_cascading_group(C1) -> PartyID = cfg(party_id, C1), PartyClient = cfg(party_client, C1), - _ = override_domain_fixture(fun cascade_fixture_pre_shop_create/2, undefined, C1), + Revision = hg_domain:head(), + ok = hg_context:save(hg_context:create()), + _ = hg_domain:upsert(cascade_fixture_pre_shop_create(Revision, C1)), C2 = [ { {shop_id, ?PAYMENT_CASCADE_SUCCESS_ID}, @@ -6095,7 +6103,9 @@ init_route_cascading_group(C1) -> } | C1 ], - override_domain_fixture(fun cascade_fixture/2, undefined, C2). + ok = hg_context:cleanup(), + _ = hg_domain:upsert(cascade_fixture(Revision, C2)), + [{base_limits_domain_revision, Revision} | C2]. init_per_cascade_case(payment_cascade_success, C) -> ShopID = cfg({shop_id, ?PAYMENT_CASCADE_SUCCESS_ID}, C), @@ -9361,7 +9371,7 @@ construct_domain_fixture() -> #domain_TurnoverLimit{ id = ?LIMIT_ID, upper_boundary = ?LIMIT_UPPER_BOUNDARY, - domain_revision = dmt_client:get_last_version() + domain_revision = hg_domain:head() } ]} } @@ -9414,7 +9424,7 @@ construct_domain_fixture() -> #domain_TurnoverLimit{ id = ?LIMIT_ID2, upper_boundary = ?LIMIT_UPPER_BOUNDARY, - domain_revision = dmt_client:get_last_version() + domain_revision = hg_domain:head() } ]} } @@ -9459,7 +9469,7 @@ construct_domain_fixture() -> #domain_TurnoverLimit{ id = ?LIMIT_ID3, upper_boundary = ?LIMIT_UPPER_BOUNDARY, - domain_revision = dmt_client:get_last_version() + domain_revision = hg_domain:head() } ]} } diff --git a/apps/hellgate/test/hg_limiter_helper.erl b/apps/hellgate/test/hg_limiter_helper.erl index 79f141e1..b0b8b83c 100644 --- a/apps/hellgate/test/hg_limiter_helper.erl +++ b/apps/hellgate/test/hg_limiter_helper.erl @@ -29,13 +29,18 @@ -spec init_per_suite(config()) -> dmt_client:vsn(). init_per_suite(_Config) -> - dmt_client:upsert([ - {limit_config, mk_config_object(?LIMIT_ID)}, - {limit_config, mk_config_object(?LIMIT_ID2)}, - {limit_config, mk_config_object(?LIMIT_ID3)}, - {limit_config, mk_config_object(?LIMIT_ID4)}, - {limit_config, mk_config_object(?SHOPLIMIT_ID)} - ]). + dmt_client:upsert( + latest, + [ + {limit_config, mk_config_object(?LIMIT_ID)}, + {limit_config, mk_config_object(?LIMIT_ID2)}, + {limit_config, mk_config_object(?LIMIT_ID3)}, + {limit_config, mk_config_object(?LIMIT_ID4)}, + {limit_config, mk_config_object(?SHOPLIMIT_ID)} + ], + dmt_client:create_author(genlib:unique(), genlib:unique()), + #{} + ). -spec get_amount(_) -> pos_integer(). get_amount(#limiter_Limit{amount = Amount}) -> diff --git a/apps/hellgate/test/hg_mock_helper.erl b/apps/hellgate/test/hg_mock_helper.erl index eb743fe9..b4648c7f 100644 --- a/apps/hellgate/test/hg_mock_helper.erl +++ b/apps/hellgate/test/hg_mock_helper.erl @@ -59,10 +59,12 @@ mock_services(Services, SupPid) -> mock_dominant(Services0, SupPid) -> Services1 = lists:map( fun + ({'AuthorManagement', Fun}) -> + {'AuthorManagement', {dmsl_domain_conf_v2_thrift, 'AuthorManagement'}, Fun}; ({'Repository', Fun}) -> - {'Repository', {dmsl_domain_conf_thrift, 'Repository'}, Fun}; + {'Repository', {dmsl_domain_conf_v2_thrift, 'Repository'}, Fun}; ({'RepositoryClient', Fun}) -> - {'RepositoryClient', {dmsl_domain_conf_thrift, 'RepositoryClient'}, Fun} + {'RepositoryClient', {dmsl_domain_conf_v2_thrift, 'RepositoryClient'}, Fun} end, Services0 ), diff --git a/apps/hellgate/test/hg_route_rules_tests_SUITE.erl b/apps/hellgate/test/hg_route_rules_tests_SUITE.erl index 28692884..2f81c9c4 100644 --- a/apps/hellgate/test/hg_route_rules_tests_SUITE.erl +++ b/apps/hellgate/test/hg_route_rules_tests_SUITE.erl @@ -4,7 +4,7 @@ -include("hg_ct_domain.hrl"). -include_lib("common_test/include/ct.hrl"). --include_lib("damsel/include/dmsl_domain_conf_thrift.hrl"). +-include_lib("damsel/include/dmsl_domain_conf_v2_thrift.hrl"). -include_lib("damsel/include/dmsl_payproc_thrift.hrl"). -include_lib("fault_detector_proto/include/fd_proto_fault_detector_thrift.hrl"). -include_lib("stdlib/include/assert.hrl"). @@ -149,24 +149,34 @@ mock_dominant(SupPid) -> Domain = construct_domain_fixture(), RoutingWithFailRateDomain = routing_with_risk_score_fixture(Domain, false), RoutingWithRiskCoverageSetDomain = routing_with_risk_score_fixture(Domain, true), + Getter = fun(Version, Ref, Objects) -> + case maps:get(Ref, Objects, undefined) of + undefined -> + woody_error:raise(business, #domain_conf_v2_ObjectNotFound{}); + Object -> + {ok, #domain_conf_v2_VersionedObject{ + object = Object, + info = #domain_conf_v2_VersionedObjectInfo{ + version = Version, + changed_at = hg_datetime:format_now(), + changed_by = #domain_conf_v2_Author{ + id = ~b"42", + name = ~b"Whoever", + email = ~b"whoever@whereever" + } + } + }} + end + end, _ = hg_mock_helper:mock_dominant( [ - {'Repository', fun - ('Checkout', {{version, ?routing_with_fail_rate_domain_revision}}) -> - {ok, #'domain_conf_Snapshot'{ - version = ?routing_with_fail_rate_domain_revision, - domain = RoutingWithFailRateDomain - }}; - ('Checkout', {{version, ?routing_with_risk_coverage_set_domain_revision}}) -> - {ok, #'domain_conf_Snapshot'{ - version = ?routing_with_risk_coverage_set_domain_revision, - domain = RoutingWithRiskCoverageSetDomain - }}; - ('Checkout', {{version, Version}}) -> - {ok, #'domain_conf_Snapshot'{ - version = Version, - domain = Domain - }} + {'RepositoryClient', fun + ('CheckoutObject', {{version, ?routing_with_fail_rate_domain_revision = Version}, ObjectRef}) -> + Getter(Version, ObjectRef, RoutingWithFailRateDomain); + ('CheckoutObject', {{version, ?routing_with_risk_coverage_set_domain_revision = Version}, ObjectRef}) -> + Getter(Version, ObjectRef, RoutingWithRiskCoverageSetDomain); + ('CheckoutObject', {{version, Version}, ObjectRef}) -> + Getter(Version, ObjectRef, Domain) end} ], SupPid diff --git a/compose.tracing.yaml b/compose.tracing.yaml index 9894d88c..e55c1ff7 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 84ddfa03..8b2af8d9 100644 --- a/compose.yaml +++ b/compose.yaml @@ -11,9 +11,9 @@ services: - .:$PWD hostname: hellgate depends_on: - machinegun: + db: condition: service_healthy - dominant: + dmt: condition: service_healthy party-management: condition: service_healthy @@ -23,22 +23,22 @@ services: condition: service_started bender: condition: service_healthy - postgres: - condition: service_healthy working_dir: $PWD command: /sbin/init - dominant: - image: ghcr.io/valitydev/dominant:sha-4bfce76 - command: /opt/dominant/bin/dominant foreground + dmt: + image: ghcr.io/valitydev/dominant-v2:sha-109d2ea + command: /opt/dmt/bin/dmt foreground + healthcheck: + test: "/opt/dmt/bin/dmt ping" + interval: 5s + timeout: 3s + retries: 12 depends_on: - machinegun: + db: condition: service_healthy - healthcheck: - test: "/opt/dominant/bin/dominant ping" - interval: 10s - timeout: 5s - retries: 10 + volumes: + - ./test/dmt/sys.config:/opt/dmt/releases/0.1/sys.config machinegun: image: ghcr.io/valitydev/mg2:sha-436f723 @@ -65,7 +65,7 @@ services: retries: 10 limiter: - image: ghcr.io/valitydev/limiter:sha-08cdd07 + image: ghcr.io/valitydev/limiter:sha-8fd529e command: /opt/limiter/bin/limiter foreground depends_on: machinegun: @@ -84,16 +84,15 @@ services: image: ghcr.io/valitydev/shumway:sha-658587c restart: unless-stopped depends_on: - - shumway-db - ports: - - "8022" + db: + condition: service_healthy entrypoint: - java - -Xmx512m - -jar - /opt/shumway/shumway.jar - - --spring.datasource.url=jdbc:postgresql://shumway-db:5432/shumway - - --spring.datasource.username=postgres + - --spring.datasource.url=jdbc:postgresql://db:5432/shumway + - --spring.datasource.username=shumway - --spring.datasource.password=postgres - --management.endpoint.metrics.enabled=false - --management.endpoint.prometheus.enabled=false @@ -101,42 +100,33 @@ services: disable: true liminator: - image: ghcr.io/valitydev/liminator:sha-fc6546f + image: ghcr.io/valitydev/liminator:sha-63b164d restart: unless-stopped entrypoint: - java - -Xmx512m - -jar - /opt/liminator/liminator.jar - - --spring.datasource.url=jdbc:postgresql://liminator-db:5432/liminator - - --spring.datasource.username=vality + - --spring.datasource.url=jdbc:postgresql://db:5432/liminator + - --spring.datasource.username=liminator - --spring.datasource.password=postgres - - --spring.flyway.url=jdbc:postgresql://liminator-db:5432/liminator - - --spring.flyway.username=vality - - --spring.flyway.password=postgres - --service.skipExistedHoldOps=false depends_on: - - liminator-db + db: + condition: service_healthy healthcheck: test: "curl http://localhost:8022/actuator/health" interval: 5s timeout: 1s retries: 20 - liminator-db: - image: docker.io/library/postgres:13.10 - environment: - - POSTGRES_DB=liminator - - POSTGRES_USER=vality - - POSTGRES_PASSWORD=postgres - party-management: - image: ghcr.io/valitydev/party-management:sha-435e3f2 + image: ghcr.io/valitydev/party-management:sha-6b6d4a5 command: /opt/party-management/bin/party-management foreground depends_on: - machinegun: + db: condition: service_healthy - dominant: + dmt: condition: service_started shumway: condition: service_started @@ -145,38 +135,21 @@ services: interval: 10s timeout: 5s retries: 10 + volumes: + - ./test/party-management/sys.config:/opt/party-management/releases/0.1/sys.config - shumway-db: - image: docker.io/library/postgres:13.10 - environment: - - POSTGRES_DB=shumway - - POSTGRES_USER=postgres - - POSTGRES_PASSWORD=postgres - - postgres: + db: image: postgres:15-bookworm - command: -c 'max_connections=300' + command: -c 'max_connections=1000' environment: - POSTGRES_DB: "progressor_db" - POSTGRES_USER: "progressor" - POSTGRES_PASSWORD: "progressor" - PGDATA: "/tmp/postgresql/data/pgdata" + POSTGRES_MULTIPLE_DATABASES: "hellgate,dmt,party_management,shumway,liminator" + POSTGRES_PASSWORD: "postgres" volumes: - - progressor-data:/tmp/postgresql/data - ports: - - "5432:5432" + - ./test/postgres/docker-entrypoint-initdb.d:/docker-entrypoint-initdb.d healthcheck: - test: ["CMD-SHELL", "pg_isready -U progressor -d progressor_db"] + test: ["CMD-SHELL", "pg_isready -U hellgate"] interval: 10s timeout: 5s retries: 5 start_period: 10s restart: unless-stopped - deploy: - resources: - limits: - cpus: '2' - memory: 4G - -volumes: - progressor-data: diff --git a/config/sys.config b/config/sys.config index d50a3eae..8865a8e4 100644 --- a/config/sys.config +++ b/config/sys.config @@ -19,6 +19,7 @@ {hg_proto, [ {services, #{ + limiter => "http://limiter:8022/v1/limiter", automaton => "http://machinegun:8022/v1/automaton", eventsink => "http://machinegun:8022/v1/event_sink", accounter => "http://shumway:8022/accounter", @@ -146,8 +147,9 @@ }} ]}, {service_urls, #{ - 'Repository' => <<"http://dominant:8022/v1/domain/repository">>, - 'RepositoryClient' => <<"http://dominant:8022/v1/domain/repository_client">> + 'AuthorManagement' => <<"http://dmt:8022/v1/domain/author">>, + 'Repository' => <<"http://dmt:8022/v1/domain/repository">>, + 'RepositoryClient' => <<"http://dmt:8022/v1/domain/repository_client">> }} ]}, @@ -270,11 +272,11 @@ {epg_connector, [ {databases, #{ hellgate_db => #{ - host => "postgres", + host => "db", port => 5432, - database => "progressor_db", - username => "progressor", - password => "progressor" + database => "hellgate", + username => "hellgate", + password => "postgres" } }}, {pools, #{ diff --git a/rebar.config b/rebar.config index 9b073179..adae26cc 100644 --- a/rebar.config +++ b/rebar.config @@ -29,27 +29,27 @@ {recon, "2.5.2"}, {cache, "2.3.3"}, {gproc, "0.9.0"}, - {genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}}, - {woody, {git, "https://github.com/valitydev/woody_erlang.git", {branch, "master"}}}, - {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "master"}}}, + {genlib, {git, "https://github.com/valitydev/genlib.git", {tag, "v1.1.0"}}}, + {woody, {git, "https://github.com/valitydev/woody_erlang.git", {tag, "v1.1.0"}}}, + {damsel, {git, "https://github.com/valitydev/damsel.git", {tag, "v2.2.0"}}}, {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"}}}, - {scoper, {git, "https://github.com/valitydev/scoper.git", {branch, "master"}}}, - {party_client, {git, "https://github.com/valitydev/party-client-erlang.git", {branch, "master"}}}, - {bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {branch, "master"}}}, + {dmt_client, {git, "https://github.com/valitydev/dmt-client.git", {tag, "v2.0.0"}}}, + {scoper, {git, "https://github.com/valitydev/scoper.git", {tag, "v1.1.0"}}}, + {party_client, {git, "https://github.com/valitydev/party-client-erlang.git", {tag, "v2.0.0"}}}, + {bender_client, {git, "https://github.com/valitydev/bender-client-erlang.git", {tag, "v1.1.0"}}}, {erl_health, {git, "https://github.com/valitydev/erlang-health.git", {branch, "master"}}}, {fault_detector_proto, {git, "https://github.com/valitydev/fault-detector-proto.git", {branch, "master"}}}, {limiter_proto, {git, "https://github.com/valitydev/limiter-proto.git", {branch, "master"}}}, {herd, {git, "https://github.com/wgnet/herd.git", {tag, "1.3.4"}}}, - {progressor, {git, "https://github.com/valitydev/progressor.git", {tag, "v1.0.1"}}}, - {prometheus, "4.8.1"}, - {prometheus_cowboy, "0.1.8"}, + {progressor, {git, "https://github.com/valitydev/progressor.git", {tag, "v1.0.2"}}}, + {prometheus, "4.11.0"}, + {prometheus_cowboy, "0.1.9"}, %% OpenTelemetry deps - {opentelemetry_api, "1.2.1"}, - {opentelemetry, "1.3.0"}, - {opentelemetry_exporter, "1.3.0"} + {opentelemetry_api, "1.4.0"}, + {opentelemetry, "1.5.0"}, + {opentelemetry_exporter, "1.8.0"} ]}. {xref_checks, [ @@ -68,7 +68,6 @@ % mandatory unmatched_returns, error_handling, - % race_conditions, unknown ]}, {plt_apps, all_deps} @@ -134,14 +133,6 @@ ]} ]}. -%% NOTE -%% It is needed to use rebar3 lint plugin -{overrides, [ - {del, accept, [{plugins, [{rebar3_archive_plugin, "0.0.2"}]}]}, - {del, prometheus_cowboy, [{plugins, [{rebar3_archive_plugin, "0.0.1"}]}]}, - {del, prometheus_httpd, [{plugins, [{rebar3_archive_plugin, "0.0.1"}]}]} -]}. - {shell, [ {config, "config/sys.config"}, {apps, [hellgate, hg_client, hg_progressor, hg_proto, routing, recon]} diff --git a/rebar.lock b/rebar.lock index 2552a841..fdbeb28e 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,9 +1,9 @@ {"1.2.0", -[{<<"accept">>,{pkg,<<"accept">>,<<"0.3.5">>},2}, +[{<<"accept">>,{pkg,<<"accept">>,<<"0.3.7">>},2}, {<<"acceptor_pool">>,{pkg,<<"acceptor_pool">>,<<"1.0.0">>},2}, {<<"bender_client">>, {git,"https://github.com/valitydev/bender-client-erlang.git", - {ref,"d8837617c8dc36216ce8c4ffc9a56a34e423ca5e"}}, + {ref,"2fceffde5deac85d3bd3f071187041d84c8c3af4"}}, 0}, {<<"bender_proto">>, {git,"https://github.com/valitydev/bender-proto.git", @@ -27,11 +27,11 @@ {<<"ctx">>,{pkg,<<"ctx">>,<<"0.6.0">>},2}, {<<"damsel">>, {git,"https://github.com/valitydev/damsel.git", - {ref,"5ca4f4a2af6bd68ba4d255889c0e2c0c1c5479a4"}}, + {ref,"ba7414811590859d058817b8f22d2e9c22f627f8"}}, 0}, {<<"dmt_client">>, {git,"https://github.com/valitydev/dmt-client.git", - {ref,"d8a4f490d49c038d96f1cbc2a279164c6f4039f9"}}, + {ref,"fcfb028a041149caeebec8d9cef469c8cdbbc63e"}}, 0}, {<<"dmt_core">>, {git,"https://github.com/valitydev/dmt-core.git", @@ -55,7 +55,7 @@ 0}, {<<"genlib">>, {git,"https://github.com/valitydev/genlib.git", - {ref,"f6074551d6586998e91a97ea20acb47241254ff3"}}, + {ref,"d2324089afbbd9630e85fac554620f1de0b33dfe"}}, 0}, {<<"gproc">>,{pkg,<<"gproc">>,<<"0.9.0">>},0}, {<<"grpcbox">>,{pkg,<<"grpcbox">>,<<"0.17.1">>},1}, @@ -71,30 +71,27 @@ {<<"kafka_protocol">>,{pkg,<<"kafka_protocol">>,<<"4.1.10">>},2}, {<<"limiter_proto">>, {git,"https://github.com/valitydev/limiter-proto.git", - {ref,"efeb7d4a05bd13c95fada18514509b34b107fcb9"}}, + {ref,"d4cdf0f6328125996ee705c3da87461f99dde7f4"}}, 0}, {<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2}, {<<"mg_proto">>, {git,"https://github.com/valitydev/machinegun-proto.git", {ref,"3decc8f8b13c9cd1701deab47781aacddd7dbc92"}}, 0}, - {<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.3.0">>},2}, + {<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.4.0">>},2}, {<<"msgpack_proto">>, {git,"https://github.com/valitydev/msgpack-proto.git", {ref,"7e447496aa5df4a5f1ace7ef2e3c31248b2a3ed0"}}, 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.3.0">>}, + {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}, {<<"party_client">>, {git,"https://github.com/valitydev/party-client-erlang.git", - {ref,"a82682b6f55f41ff4962b2666bbd12cb5f1ece25"}}, + {ref,"b10b102673d899f6661e0c1a9e70f04ebddc9263"}}, 0}, {<<"payproc_errors">>, {git,"https://github.com/valitydev/payproc-errors-erlang.git", @@ -102,17 +99,17 @@ 0}, {<<"progressor">>, {git,"https://github.com/valitydev/progressor.git", - {ref,"6df2e447a867434ad45bfc3540c4681e10105e02"}}, + {ref,"4c44615f712ae8992ff1a654f227def9f44c8aa7"}}, 0}, - {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.8.1">>},0}, - {<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.8">>},0}, - {<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.11">>},1}, + {<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.11.0">>},0}, + {<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.9">>},0}, + {<<"prometheus_httpd">>,{pkg,<<"prometheus_httpd">>,<<"2.1.15">>},1}, {<<"quantile_estimator">>,{pkg,<<"quantile_estimator">>,<<"0.2.1">>},1}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2}, {<<"recon">>,{pkg,<<"recon">>,<<"2.5.2">>},0}, {<<"scoper">>, {git,"https://github.com/valitydev/scoper.git", - {ref,"55a2a32ee25e22fa35f583a18eaf38b2b743429b"}}, + {ref,"0e7aa01e9632daa39727edd62d4656ee715b4569"}}, 0}, {<<"snowflake">>, {git,"https://github.com/valitydev/snowflake.git", @@ -124,16 +121,16 @@ {ref,"3a60e5dc5bbd709495024f26e100b041c3547fd9"}}, 1}, {<<"tls_certificate_check">>, - {pkg,<<"tls_certificate_check">>,<<"1.24.0">>}, + {pkg,<<"tls_certificate_check">>,<<"1.28.0">>}, 1}, - {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2}, + {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.1">>},2}, {<<"woody">>, {git,"https://github.com/valitydev/woody_erlang.git", - {ref,"072825ee7179825a4078feb0649df71303c74157"}}, + {ref,"cc983a9423325ba1d6a509775eb6ff7ace721539"}}, 0}]}. [ {pkg_hash,[ - {<<"accept">>, <<"B33B127ABCA7CC948BBE6CAA4C263369ABF1347CFA9D8E699C6D214660F10CD1">>}, + {<<"accept">>, <<"CD6E34A2D7E28CA38B2D3CB233734CA0C221EFBC1F171F91FEC5F162CC2D18DA">>}, {<<"acceptor_pool">>, <<"43C20D2ACAE35F0C2BCD64F9D2BDE267E459F0F3FD23DAB26485BF518C281B21">>}, {<<"brod">>, <<"51F4DFF17ED43A806558EBD62CC88E7B35AED336D1BA1F3DE2D010F463D49736">>}, {<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>}, @@ -152,23 +149,22 @@ {<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>}, {<<"kafka_protocol">>, <<"F917B6C90C8DF0DE2B40A87D6B9AE1CFCE7788E91A65818E90E40CF76111097A">>}, {<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>}, - {<<"mimerl">>, <<"D0CD9FC04B9061F82490F6581E0128379830E78535E017F7780F37FEA7545726">>}, - {<<"opentelemetry">>, <<"988AC3C26ACAC9720A1D4FB8D9DC52E95B45ECFEC2D5B5583276A09E8936BC5E">>}, - {<<"opentelemetry_api">>, <<"7B69ED4F40025C005DE0B74FCE8C0549625D59CB4DF12D15C32FE6DC5076FF42">>}, - {<<"opentelemetry_exporter">>, <<"1D8809C0D4F4ACF986405F7700ED11992BCBDB6A4915DD11921E80777FFA7167">>}, - {<<"opentelemetry_semantic_conventions">>, <<"B67FE459C2938FCAB341CB0951C44860C62347C005ACE1B50F8402576F241435">>}, + {<<"mimerl">>, <<"3882A5CA67FBBE7117BA8947F27643557ADEC38FA2307490C4C4207624CB213B">>}, + {<<"opentelemetry">>, <<"7DDA6551EDFC3050EA4B0B40C0D2570423D6372B97E9C60793263EF62C53C3C2">>}, + {<<"opentelemetry_api">>, <<"63CA1742F92F00059298F478048DFB826F4B20D49534493D6919A0DB39B6DB04">>}, + {<<"opentelemetry_exporter">>, <<"5D546123230771EF4174E37BEDFD77E3374913304CD6EA3CA82A2ADD49CD5D56">>}, {<<"parse_trans">>, <<"16328AB840CC09919BD10DAB29E431DA3AF9E9E7E7E6F0089DD5A2D2820011D8">>}, - {<<"prometheus">>, <<"FA76B152555273739C14B06F09F485CF6D5D301FE4E9D31B7FF803D26025D7A0">>}, - {<<"prometheus_cowboy">>, <<"CFCE0BC7B668C5096639084FCD873826E6220EA714BF60A716F5BD080EF2A99C">>}, - {<<"prometheus_httpd">>, <<"F616ED9B85B536B195D94104063025A91F904A4CFC20255363F49A197D96C896">>}, + {<<"prometheus">>, <<"B95F8DE8530F541BD95951E18E355A840003672E5EDA4788C5FA6183406BA29A">>}, + {<<"prometheus_cowboy">>, <<"D9D5B300516A61ED5AE31391F8EEEEB202230081D32A1813F2D78772B6F274E1">>}, + {<<"prometheus_httpd">>, <<"8F767D819A5D36275EAB9264AFF40D87279151646776069BF69FBDBBD562BD75">>}, {<<"quantile_estimator">>, <<"EF50A361F11B5F26B5F16D0696E46A9E4661756492C981F7B2229EF42FF1CD15">>}, {<<"ranch">>, <<"8C7A100A139FD57F17327B6413E4167AC559FBC04CA7448E9BE9057311597A1D">>}, {<<"recon">>, <<"CBA53FA8DB83AD968C9A652E09C3ED7DDCC4DA434F27C3EAA9CA47FFB2B1FF03">>}, {<<"ssl_verify_fun">>, <<"354C321CF377240C7B8716899E182CE4890C5938111A1296ADD3EC74CF1715DF">>}, - {<<"tls_certificate_check">>, <<"D00E2887551FF8CDAE4D0340D90D9FCBC4943C7B5F49D32ED4BC23AFF4DB9A44">>}, - {<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]}, + {<<"tls_certificate_check">>, <<"C39BF21F67C2D124AE905454FAD00F27E625917E8AB1009146E916E1DF6AB275">>}, + {<<"unicode_util_compat">>, <<"A48703A25C170EEDADCA83B11E88985AF08D35F37C6F664D6DCFB106A97782FC">>}]}, {pkg_hash_ext,[ - {<<"accept">>, <<"11B18C220BCC2EAB63B5470C038EF10EB6783BCB1FCDB11AA4137DEFA5AC1BB8">>}, + {<<"accept">>, <<"CA69388943F5DAD2E7232A5478F16086E3C872F48E32B88B378E1885A59F5649">>}, {<<"acceptor_pool">>, <<"0CBCD83FDC8B9AD2EEE2067EF8B91A14858A5883CB7CD800E6FCD5803E158788">>}, {<<"brod">>, <<"88584FDEBA746AA6729E2A1826416C10899954F68AF93659B3C2F38A2DCAA27C">>}, {<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>}, @@ -187,19 +183,18 @@ {<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>}, {<<"kafka_protocol">>, <<"DF680A3706EAD8695F8B306897C0A33E8063C690DA9308DB87B462CFD7029D04">>}, {<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>}, - {<<"mimerl">>, <<"A1E15A50D1887217DE95F0B9B0793E32853F7C258A5CD227650889B38839FE9D">>}, - {<<"opentelemetry">>, <<"8E09EDC26AAD11161509D7ECAD854A3285D88580F93B63B0B1CF0BAC332BFCC0">>}, - {<<"opentelemetry_api">>, <<"6D7A27B7CAD2AD69A09CABF6670514CAFCEC717C8441BEB5C96322BAC3D05350">>}, - {<<"opentelemetry_exporter">>, <<"2B40007F509D38361744882FD060A8841AF772AB83BB542AA5350908B303AD65">>}, - {<<"opentelemetry_semantic_conventions">>, <<"D61FA1F5639EE8668D74B527E6806E0503EFC55A42DB7B5F39939D84C07D6895">>}, + {<<"mimerl">>, <<"13AF15F9F68C65884ECCA3A3891D50A7B57D82152792F3E19D88650AA126B144">>}, + {<<"opentelemetry">>, <<"CDF4F51D17B592FC592B9A75F86A6F808C23044BA7CF7B9534DEBBCC5C23B0EE">>}, + {<<"opentelemetry_api">>, <<"3DFBBFAA2C2ED3121C5C483162836C4F9027DEF469C41578AF5EF32589FCFC58">>}, + {<<"opentelemetry_exporter">>, <<"A1F9F271F8D3B02B81462A6BFEF7075FD8457FDB06ADFF5D2537DF5E2264D9AF">>}, {<<"parse_trans">>, <<"07CD9577885F56362D414E8C4C4E6BDF10D43A8767ABB92D24CBE8B24C54888B">>}, - {<<"prometheus">>, <<"6EDFBE928D271C7F657A6F2C46258738086584BD6CAE4A000B8B9A6009BA23A5">>}, - {<<"prometheus_cowboy">>, <<"BA286BECA9302618418892D37BCD5DC669A6CC001F4EB6D6AF85FF81F3F4F34C">>}, - {<<"prometheus_httpd">>, <<"0BBE831452CFDF9588538EB2F570B26F30C348ADAE5E95A7D87F35A5910BCF92">>}, + {<<"prometheus">>, <<"719862351AABF4DF7079B05DC085D2BBCBE3AC0AC3009E956671B1D5AB88247D">>}, + {<<"prometheus_cowboy">>, <<"5F71C039DEB9E9FF9DD6366BC74C907A463872B85286E619EFF0BDA15111695A">>}, + {<<"prometheus_httpd">>, <<"67736D000745184D5013C58A63E947821AB90CB9320BC2E6AE5D3061C6FFE039">>}, {<<"quantile_estimator">>, <<"282A8A323CA2A845C9E6F787D166348F776C1D4A41EDE63046D72D422E3DA946">>}, {<<"ranch">>, <<"49FBCFD3682FAB1F5D109351B61257676DA1A2FDBE295904176D5E521A2DDFE5">>}, {<<"recon">>, <<"2C7523C8DEE91DFF41F6B3D63CBA2BD49EB6D2FE5BF1EEC0DF7F87EB5E230E1C">>}, {<<"ssl_verify_fun">>, <<"FE4C190E8F37401D30167C8C405EDA19469F34577987C76DDE613E838BBC67F8">>}, - {<<"tls_certificate_check">>, <<"90B25A58EE433D91C17F036D4D354BF8859A089BFDA60E68A86F8EECAE45EF1B">>}, - {<<"unicode_util_compat">>, <<"25EEE6D67DF61960CF6A794239566599B09E17E668D3700247BC498638152521">>}]} + {<<"tls_certificate_check">>, <<"3AB058C3F9457FFFCA916729587415F0DDC822048A0E5B5E2694918556D92DF1">>}, + {<<"unicode_util_compat">>, <<"B3A917854CE3AE233619744AD1E0102E05673136776FB2FA76234F3E03B23642">>}]} ]. diff --git a/test/dmt/sys.config b/test/dmt/sys.config new file mode 100644 index 00000000..f1c50ed7 --- /dev/null +++ b/test/dmt/sys.config @@ -0,0 +1,74 @@ +[ + {kernel, [ + {log_level, debug}, + {logger, [ + {handler, default, logger_std_h, #{ + level => all, + config => #{ + type => standard_io + } + %% formatter => + %% {logger_logstash_formatter, #{}} + }} + ]} + ]}, + + {dmt, [ + {host, <<"dmt">>}, + {port, 8022}, + {scoper_event_handler_options, #{ + event_handler_opts => #{ + formatter_opts => #{ + max_length => 1000 + } + } + }}, + {services, #{ + repository => #{ + url => <<"http://dmt:8022/v1/domain/repository">> + }, + repository_client => #{ + url => <<"http://dmt:8022/v1/domain/repository_client">> + }, + author => #{ + url => <<"http://dmt:8022/v1/domain/author">> + } + }} + ]}, + + {woody, [ + {acceptors_pool_size, 4} + ]}, + + {epg_connector, [ + {databases, #{ + default_db => #{ + host => "db", + port => 5432, + username => "dmt", + 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 + ]} + ]} +]. diff --git a/test/machinegun/config.yaml b/test/machinegun/config.yaml index 3a55dce2..1bea8b92 100644 --- a/test/machinegun/config.yaml +++ b/test/machinegun/config.yaml @@ -22,10 +22,6 @@ namespaces: processor: url: http://party-management:8022/v1/stateproc/party pool_size: 300 - domain-config: - processor: - url: http://dominant:8022/v1/stateproc - pool_size: 300 lim/config_v1: processor: url: http://limiter:8022/v1/stateproc/lim/config_v1 diff --git a/test/party-management/sys.config b/test/party-management/sys.config new file mode 100644 index 00000000..2020a20e --- /dev/null +++ b/test/party-management/sys.config @@ -0,0 +1,128 @@ +%% -*- mode: erlang -*- +[ + {kernel, [ + {logger_level, info}, + {logger, [ + {handler, default, logger_std_h, #{ + config => #{ + type => standard_io, + sync_mode_qlen => 20 + } + }} + ]} + ]}, + + {scoper, [ + {storage, scoper_storage_logger} + ]}, + + {party_management, [ + {machinery_backend, progressor}, + {scoper_event_handler_options, #{ + event_handler_opts => #{ + formatter_opts => #{ + max_length => 1000 + } + } + }}, + {services, #{ + automaton => "http://machinegun-ha:8022/v1/automaton", + accounter => "http://shumway:8022/accounter" + }}, + {cache_options, #{ %% see `pm_party_cache:cache_options/0` + memory => 209715200, % 200Mb, cache memory quota in bytes + ttl => 3600, + size => 3000 + }}, + {health_check, #{ + memory => {erl_health, cg_memory, [70]}, + dmt_client => {dmt_client, health_check, []} + }} + ]}, + + {epg_connector, [ + {databases, #{ + default_db => #{ + host => "db", + port => 5432, + database => "party_management", + username => "party_management", + password => "postgres" + } + }}, + {pools, #{ + default_pool => #{ + database => default_db, + size => 30 + } + }} + ]}, + + {progressor, [ + {call_wait_timeout, 20}, + {defaults, #{ + storage => #{ + client => prg_pg_backend, + options => #{ + pool => default_pool + } + }, + retry_policy => #{ + initial_timeout => 5, + backoff_coefficient => 1.0, + %% seconds + max_timeout => 180, + max_attempts => 3, + non_retryable_errors => [] + }, + task_scan_timeout => 1, + worker_pool_size => 100, + process_step_timeout => 30 + }}, + {namespaces, #{ + 'party' => #{ + processor => #{ + client => machinery_prg_backend, + options => #{ + namespace => 'party', + handler => {pm_party_machine, #{}}, + schema => party_management_machinery_schema + } + } + } + }} + ]}, + + {dmt_client, [ + {cache_update_interval, 5000}, % milliseconds + {cache_server_call_timeout, 30000}, % milliseconds + {max_cache_size, #{ + elements => 20, + memory => 52428800 % 50Mb + }}, + {woody_event_handlers, [ + {scoper_woody_event_handler, #{ + event_handler_opts => #{ + formatter_opts => #{ + max_length => 1000 + } + } + }} + ]}, + {service_urls, #{ + 'AuthorManagement' => <<"http://dmt:8022/v1/domain/author">>, + 'Repository' => <<"http://dmt:8022/v1/domain/repository">>, + 'RepositoryClient' => <<"http://dmt:8022/v1/domain/repository_client">> + }} + ]}, + + {snowflake, [{machine_id, 1}]}, + + {prometheus, [ + {collectors, [default]} + ]}, + + {hackney, [ + {mod_metrics, woody_hackney_prometheus} + ]} +]. diff --git a/test/postgres/docker-entrypoint-initdb.d/create-multiple-postgresql-databases.sh b/test/postgres/docker-entrypoint-initdb.d/create-multiple-postgresql-databases.sh new file mode 100755 index 00000000..83e34fd7 --- /dev/null +++ b/test/postgres/docker-entrypoint-initdb.d/create-multiple-postgresql-databases.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +set -e +set -u + +function create_user_and_database() { + local database=$1 + echo " Creating user and database '$database'" + psql -v ON_ERROR_STOP=1 --username "$POSTGRES_USER" <<-EOSQL + CREATE DATABASE $database; + \c $database; + CREATE USER $database; + ALTER USER $database WITH ENCRYPTED PASSWORD '$POSTGRES_PASSWORD'; + GRANT ALL ON SCHEMA public TO $database; + GRANT ALL PRIVILEGES ON DATABASE $database TO $database; +EOSQL +} + +if [ -n "$POSTGRES_MULTIPLE_DATABASES" ]; then + echo "Multiple database creation requested: $POSTGRES_MULTIPLE_DATABASES" + for db in $(echo $POSTGRES_MULTIPLE_DATABASES | tr ',' ' '); do + create_user_and_database $db + done + echo "Multiple databases created" +fi