Skip to content

Commit

Permalink
TD-927: bump progressor
Browse files Browse the repository at this point in the history
  • Loading branch information
ttt161 committed Oct 2, 2024
1 parent 62e7702 commit dbfb562
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 8 deletions.
11 changes: 6 additions & 5 deletions apps/hellgate/test/hg_ct_helper.erl
Original file line number Diff line number Diff line change
Expand Up @@ -287,15 +287,15 @@ start_app(epg_connector = AppName) ->
{pools, #{
default_pool => #{
database => default_db,
size => 100
size => 200
},
default_front_pool => #{
database => default_db,
size => 10
size => 50
},
default_scan_pool => #{
database => default_db,
size => 4
size => 8
}
}}
]),
Expand All @@ -307,7 +307,7 @@ start_app(progressor = AppName) ->
{call_wait_timeout, 20},
{defaults, #{
storage => #{
client => prg_pg_backend,
client => prg_pg_backend2,
options => #{
pool => default_pool,
front_pool => default_front_pool,
Expand Down Expand Up @@ -335,7 +335,8 @@ start_app(progressor = AppName) ->
ns => <<"invoice">>,
handler => hg_machine
}
}
},
worker_pool_size => 150
},
invoice_template => #{
processor => #{
Expand Down
54 changes: 54 additions & 0 deletions apps/hellgate/test/hg_invoice_lite_tests_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,12 @@
-export([groups/0]).
-export([init_per_suite/1]).
-export([end_per_suite/1]).
-export([init_per_group/2]).
-export([end_per_group/2]).
-export([init_per_testcase/2]).
-export([end_per_testcase/2]).

-export([payment_ok_test/1]).
-export([payment_start_idempotency/1]).
-export([payment_success/1]).
-export([payment_w_first_blacklisted_success/1]).
Expand Down Expand Up @@ -45,11 +48,21 @@ init([]) ->
all() ->
[
{group, payments}
% {group, wrap_load}
].

-spec groups() -> [{group_name(), list(), [test_case_name()]}].
groups() ->
[
{wrap_load, [], [
{group, load}
]},
{load, [{repeat, 10}], [
{group, pool_payments}
]},
{pool_payments, [parallel],
lists:foldl(fun(_, Acc) -> [payment_ok_test | Acc] end, [], lists:seq(1, 100))
},
{payments, [parallel], [
payment_start_idempotency,
payment_success,
Expand Down Expand Up @@ -115,6 +128,21 @@ end_per_suite(C) ->
hg_invoice_helper:stop_kv_store(cfg(test_sup, C)),
exit(cfg(test_sup, C), shutdown).

-spec init_per_group(group_name(), config()) -> config().
init_per_group(wrap_load, C) ->
io:format(user, "START LOAD: ~p~n", [calendar:local_time()]),
C;
init_per_group(_, C) ->
C.

-spec end_per_group(group_name(), config()) -> _.
end_per_group(wrap_load, _C) ->
io:format(user, "FINISH LOAD: ~p~n", [calendar:local_time()]),
io:format(user, prometheus_text_format:format(), []),
ok;
end_per_group(_Group, _C) ->
ok.

-spec init_per_testcase(test_case_name(), config()) -> config().
init_per_testcase(_, C) ->
ApiClient = hg_ct_helper:create_client(hg_ct_helper:cfg(root_url, C)),
Expand All @@ -130,6 +158,32 @@ end_per_testcase(_, C) ->
C.

%% TESTS
-spec payment_ok_test(config()) -> test_return().
payment_ok_test(C) ->
Client = cfg(client, C),
%timer:sleep(rand:uniform(30)),
InvoiceID = start_invoice(<<"rubberduck">>, make_due_date(10), 42000, C),
Context = #base_Content{
type = <<"application/x-erlang-binary">>,
data = erlang:term_to_binary({you, 643, "not", [<<"welcome">>, here]})
},
PayerSessionInfo = #domain_PayerSessionInfo{
redirect_url = <<"https://redirectly.io/merchant">>
},
PaymentParams = (make_payment_params(?pmt_sys(<<"visa-ref">>)))#payproc_InvoicePaymentParams{
payer_session_info = PayerSessionInfo,
context = Context
},
PaymentID = process_payment(InvoiceID, PaymentParams, Client),
try await_payment_capture(InvoiceID, PaymentID, Client) of
PaymentID -> ok
catch
_:_ ->
io:format(user, "MAYBE FAILED INVOICE: ~p~n", [InvoiceID])
end,
#payproc_Invoice{} = hg_client_invoicing:get(InvoiceID, Client),
ok.

-spec payment_start_idempotency(config()) -> test_return().
payment_start_idempotency(C) ->
Client = cfg(client, C),
Expand Down
4 changes: 2 additions & 2 deletions compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ services:

postgres:
image: postgres:15-bookworm
command: -c 'max_connections=200'
command: -c 'max_connections=300'
environment:
POSTGRES_DB: "progressor_db"
POSTGRES_USER: "progressor"
Expand All @@ -145,7 +145,7 @@ services:
deploy:
resources:
limits:
cpus: '1'
cpus: '2'
memory: 4G

volumes:
Expand Down
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
{<<"pooler">>,{pkg,<<"pooler">>,<<"1.5.3">>},3},
{<<"progressor">>,
{git,"https://github.com/valitydev/progressor.git",
{ref,"fea35aef44f8ff322d2f47daeb70b90ebade1806"}},
{ref,"6f76a423d5a260082009c883505dc91886f0e7d4"}},
0},
{<<"prometheus">>,{pkg,<<"prometheus">>,<<"4.8.1">>},0},
{<<"prometheus_cowboy">>,{pkg,<<"prometheus_cowboy">>,<<"0.1.8">>},0},
Expand Down

0 comments on commit dbfb562

Please sign in to comment.