diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..5401b79 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,8 @@ +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_size = 4 +indent_style = space +trim_trailing_whitespace = true +max_line_length = 120 diff --git a/.env b/.env new file mode 100644 index 0000000..eb41925 --- /dev/null +++ b/.env @@ -0,0 +1,6 @@ +# NOTE +# You SHOULD specify point releases here so that build time and run time Erlang/OTPs +# are the same. See: https://github.com/erlware/relx/pull/902 +OTP_VERSION=24.2.0 +REBAR_VERSION=3.18 +THRIFT_VERSION=0.14.2.2 diff --git a/.github/workflows/basic-linters.yml b/.github/workflows/basic-linters.yml new file mode 100644 index 0000000..60b10c5 --- /dev/null +++ b/.github/workflows/basic-linters.yml @@ -0,0 +1,15 @@ +name: Vality basic linters + +on: + pull_request: + branches: + - master + - main + push: + branches: + - master + - main + +jobs: + lint: + uses: valitydev/base-workflows/.github/workflows/basic-linters.yml@v1 diff --git a/.github/workflows/erlang-checks.yml b/.github/workflows/erlang-checks.yml new file mode 100644 index 0000000..4bb7abf --- /dev/null +++ b/.github/workflows/erlang-checks.yml @@ -0,0 +1,39 @@ +name: Erlang CI Checks + +on: + push: + branches: + - 'master' + - 'epic/**' + pull_request: + branches: ['**'] + +jobs: + setup: + name: Load .env + runs-on: ubuntu-latest + outputs: + otp-version: ${{ steps.otp-version.outputs.version }} + rebar-version: ${{ steps.rebar-version.outputs.version }} + thrift-version: ${{ steps.thrift-version.outputs.version }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + - run: grep -v '^#' .env >> $GITHUB_ENV + - id: otp-version + run: echo "::set-output name=version::$OTP_VERSION" + - id: rebar-version + run: echo "::set-output name=version::$REBAR_VERSION" + - id: thrift-version + run: echo "::set-output name=version::$THRIFT_VERSION" + + run: + name: Run checks + needs: setup + uses: valitydev/erlang-workflows/.github/workflows/erlang-parallel-build.yml@v1.0.1 + with: + otp-version: ${{ needs.setup.outputs.otp-version }} + rebar-version: ${{ needs.setup.outputs.rebar-version }} + use-thrift: true + thrift-version: ${{ needs.setup.outputs.thrift-version }} + run-ct-with-compose: true diff --git a/.gitignore b/.gitignore index d360f73..5173038 100644 --- a/.gitignore +++ b/.gitignore @@ -1,16 +1,14 @@ -# general -log -/.rebar3/ +# Build artifacts /_build/ -/ebin/ -*~ +*.o +*.beam +*.plt + +# Run artifacts erl_crash.dump -.tags* -*.sublime-workspace -.DS_Store +rebar3.crashdump +log -# builtils -docker-compose.yml - -src/dmt_client_*_thrift.erl -include/dmt_client_*_thrift.hrl +# make stuff +/.image.* +Makefile.env diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 4a5266f..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "build_utils"] - path = build_utils - url = git@github.com:rbkmoney/build_utils.git diff --git a/Dockerfile.dev b/Dockerfile.dev new file mode 100644 index 0000000..e4cfa53 --- /dev/null +++ b/Dockerfile.dev @@ -0,0 +1,17 @@ +ARG OTP_VERSION + +FROM docker.io/library/erlang:${OTP_VERSION} +SHELL ["/bin/bash", "-o", "pipefail", "-c"] + +# Install thrift compiler +ARG THRIFT_VERSION +ARG TARGETARCH +RUN wget -q -O- "https://github.com/valitydev/thrift/releases/download/${THRIFT_VERSION}/thrift-${THRIFT_VERSION}-linux-${TARGETARCH}.tar.gz" \ + | tar -xvz -C /usr/local/bin/ + +# Set env +ENV CHARSET=UTF-8 +ENV LANG=C.UTF-8 + +# Set runtime +CMD ["/bin/bash"] diff --git a/Jenkinsfile b/Jenkinsfile deleted file mode 100644 index f7a5f68..0000000 --- a/Jenkinsfile +++ /dev/null @@ -1,38 +0,0 @@ -#!groovy -// -*- mode: groovy -*- -// -// Copyright 2020 RBKmoney -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -// - -def finalHook = { - runStage('store CT logs') { - archive '_build/test/logs/' - } -} - -build('party_client_erlang', 'docker-host', finalHook) { - checkoutRepo() - loadBuildUtils() - - def pipeErlangLib - runStage('load pipeline') { - env.JENKINS_LIB = "build_utils/jenkins_lib" - env.SH_TOOLS = "build_utils/sh" - pipeErlangLib = load("${env.JENKINS_LIB}/pipeErlangLib.groovy") - } - - pipeErlangLib.runPipe(true,false) -} - diff --git a/Makefile b/Makefile index b85a670..4d73511 100644 --- a/Makefile +++ b/Makefile @@ -1,59 +1,114 @@ -REBAR := $(shell which rebar3 2>/dev/null || which ./rebar3) -SUBMODULES = build_utils -SUBTARGETS = $(patsubst %,%/.git,$(SUBMODULES)) +# HINT +# Use this file to override variables here. +# For example, to run with podman put `DOCKER=podman` there. +-include Makefile.env -UTILS_PATH := build_utils -TEMPLATES_PATH := . +# NOTE +# Variables specified in `.env` file are used to pick and setup specific +# component versions, both when building a development image and when running +# CI workflows on GH Actions. This ensures that tasks run with `wc-` prefix +# (like `wc-dialyze`) are reproducible between local machine and CI runners. +DOTENV := $(shell grep -v '^\#' .env) -# Name of the service -SERVICE_NAME := party_client +# Development images +DEV_IMAGE_TAG = $(TEST_CONTAINER_NAME)-dev +DEV_IMAGE_ID = $(file < .image.dev) -# Build image tag to be used -BUILD_IMAGE_NAME := build-erlang -BUILD_IMAGE_TAG := 1aa346b3638e143b4c1fafd74b3f25041024ce35 - -CALL_ANYWHERE := all submodules compile xref lint dialyze clean distclean check_format format -CALL_W_CONTAINER := $(CALL_ANYWHERE) test get_test_deps +DOCKER ?= docker +DOCKERCOMPOSE ?= docker-compose +DOCKERCOMPOSE_W_ENV = DEV_IMAGE_TAG=$(DEV_IMAGE_TAG) $(DOCKERCOMPOSE) +REBAR ?= rebar3 +TEST_CONTAINER_NAME ?= testrunner all: compile --include $(UTILS_PATH)/make_lib/utils_container.mk +.PHONY: dev-image clean-dev-image wc-shell test -.PHONY: $(CALL_W_CONTAINER) +dev-image: .image.dev -$(SUBTARGETS): %/.git: % - git submodule update --init $< - touch $@ +.image.dev: Dockerfile.dev .env + env $(DOTENV) $(DOCKERCOMPOSE_W_ENV) build $(TEST_CONTAINER_NAME) + $(DOCKER) image ls -q -f "reference=$(DEV_IMAGE_ID)" | head -n1 > $@ -submodules: $(SUBTARGETS) +clean-dev-image: +ifneq ($(DEV_IMAGE_ID),) + $(DOCKER) image rm -f $(DEV_IMAGE_TAG) + rm .image.dev +endif -compile: submodules +DOCKER_WC_OPTIONS := -v $(PWD):$(PWD) --workdir $(PWD) +DOCKER_WC_EXTRA_OPTIONS ?= --rm +DOCKER_RUN = $(DOCKER) run -t $(DOCKER_WC_OPTIONS) $(DOCKER_WC_EXTRA_OPTIONS) + +DOCKERCOMPOSE_RUN = $(DOCKERCOMPOSE_W_ENV) run --rm $(DOCKER_WC_OPTIONS) + +# Utility tasks + +wc-shell: dev-image + $(DOCKER_RUN) --interactive --tty $(DEV_IMAGE_TAG) + +wc-%: dev-image + $(DOCKER_RUN) $(DEV_IMAGE_TAG) make $* + +# TODO docker compose down doesn't work yet +wdeps-shell: dev-image + $(DOCKERCOMPOSE_RUN) $(TEST_CONTAINER_NAME) su; \ + $(DOCKERCOMPOSE_W_ENV) down + +# Pass CT_CASE through to container env +wdeps-common-test.%: MAKE_ARGS=$(if $(CT_CASE),CT_CASE=$(CT_CASE)) + +wdeps-%: dev-image + $(DOCKERCOMPOSE_RUN) -T $(TEST_CONTAINER_NAME) make $(if $(MAKE_ARGS),$(MAKE_ARGS) $*,$*); \ + res=$$?; \ + $(DOCKERCOMPOSE_W_ENV) down; \ + exit $$res + +# Rebar tasks + +rebar-shell: + $(REBAR) shell + +compile: $(REBAR) compile -xref: submodules +xref: $(REBAR) xref lint: - elvis rock -V + $(REBAR) lint -check_format: +check-format: $(REBAR) fmt -c +dialyze: + $(REBAR) as test dialyzer + +release: + $(REBAR) as prod release + +eunit: + $(REBAR) eunit --cover + +common-test: + $(REBAR) ct --cover + +common-test.%: apps/hellgate/test/hg_%_tests_SUITE.erl + $(REBAR) ct --cover --suite=$^ $(if $(CT_CASE),--case=$(strip $(CT_CASE))) + +cover: + $(REBAR) covertool generate + format: $(REBAR) fmt -w -dialyze: submodules - $(REBAR) dialyzer - -test: submodules - $(REBAR) ct - -get_test_deps: submodules - $(REBAR) as test get-deps - clean: $(REBAR) clean -distclean: - $(REBAR) clean -a - rm -rfv _build _builds _cache _steps _temp +distclean: clean-build-image + rm -rf _build + +test: eunit common-test + +cover-report: + $(REBAR) cover diff --git a/build_utils b/build_utils deleted file mode 160000 index be44d69..0000000 --- a/build_utils +++ /dev/null @@ -1 +0,0 @@ -Subproject commit be44d69fc87b22a0bb82d98d6eae7658d1647f98 diff --git a/docker-compose.sh b/compose.yaml old mode 100755 new mode 100644 similarity index 52% rename from docker-compose.sh rename to compose.yaml index 0b23afb..bfcf1bb --- a/docker-compose.sh +++ b/compose.yaml @@ -1,44 +1,72 @@ -#!/bin/bash -cat < "http://party-management:8022/v1/processing/partymgmt" }}, {woody, #{ - cache_mode => safe, % disabled | safe | aggressive + % disabled | safe | aggressive + cache_mode => safe, + aggressive_caching_timeout => 30000, options => #{ woody_client => #{ - event_handler => {scoper_woody_event_handler, #{ - event_handler_opts => #{ - formatter_opts => #{ - max_length => 1000 + event_handler => + {scoper_woody_event_handler, #{ + event_handler_opts => #{ + formatter_opts => #{ + max_length => 1000 + } } - } - }} + }} } } }} - ]}, + ]} ]. diff --git a/elvis.config b/elvis.config index 67e58f8..e7c2128 100644 --- a/elvis.config +++ b/elvis.config @@ -2,26 +2,34 @@ {elvis, [ {config, [ #{ - dirs => ["src", "test"], + dirs => ["src", "include"], filter => "*.erl", + ruleset => erl_files, rules => [ - {elvis_text_style, line_length, #{limit => 120, skip_comments => false}}, - {elvis_text_style, no_tabs}, - {elvis_text_style, no_trailing_whitespace}, - {elvis_style, macro_module_names}, - {elvis_style, operator_spaces, #{rules => [{right, ","}, {right, "++"}, {left, "++"}]}}, + {elvis_text_style, line_length, #{limit => 120}}, + {elvis_text_style, no_trailing_whitespace, #{ignore_empty_lines => true}}, {elvis_style, nesting_level, #{level => 3}}, - {elvis_style, god_modules, #{limit => 35, ignore => [party_client_thrift]}}, - {elvis_style, no_if_expression}, - {elvis_style, invalid_dynamic_call, #{ignore => [elvis]}}, - {elvis_style, used_ignored_variable}, - {elvis_style, no_behavior_info}, - {elvis_style, module_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*(_SUITE)?$"}}, - {elvis_style, function_naming_convention, #{regex => "^[a-z]([a-z0-9]*_?)*$"}}, - {elvis_style, state_record_and_type, #{ignore => []}}, - {elvis_style, no_spec_with_records}, - {elvis_style, dont_repeat_yourself, #{min_complexity => 15, ignore => [party_client_base_hg_tests_SUITE]}}, - {elvis_style, no_debug_call, #{ignore => [elvis, elvis_utils]}} + {elvis_style, function_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*$"}}, + {elvis_style, no_if_expression, disable}, + {elvis_style, atom_naming_convention, disable}, + %% Meh + {elvis_style, god_modules, #{ignore => [party_client_thrift]}}, + %% ?? + {elvis_style, dont_repeat_yourself, #{min_complexity => 15}} + ] + }, + #{ + dirs => ["test"], + filter => "*.erl", + ruleset => erl_files, + rules => [ + {elvis_text_style, line_length, #{limit => 120}}, + {elvis_text_style, no_trailing_whitespace, #{ignore_empty_lines => true}}, + {elvis_style, nesting_level, #{level => 3}}, + {elvis_style, function_naming_convention, #{regex => "^([a-z][a-z0-9]*_?)*$"}}, + {elvis_style, no_if_expression, disable}, + {elvis_style, atom_naming_convention, disable}, + {elvis_style, dont_repeat_yourself, #{min_complexity => 30}} ] }, #{ @@ -37,10 +45,14 @@ #{ dirs => ["."], filter => "rebar.config", + ruleset => rebar_config, rules => [ {elvis_text_style, line_length, #{limit => 120, skip_comments => false}}, {elvis_text_style, no_tabs}, - {elvis_text_style, no_trailing_whitespace} + {elvis_text_style, no_trailing_whitespace}, + % Only use this rule for first-party dependencies + % Replace it when it's possible to filter by regex + {elvis_project, no_deps_master_rebar, disable} ] }, #{ diff --git a/rebar.config b/rebar.config index 2a88b07..157363c 100644 --- a/rebar.config +++ b/rebar.config @@ -1,6 +1,5 @@ %% Common project erlang options. {erl_opts, [ - % mandatory debug_info, warnings_as_errors, @@ -27,10 +26,10 @@ %% Common project dependencies. {deps, [ - {genlib, {git, "https://github.com/rbkmoney/genlib.git", {branch, "master"}}}, - {damsel, {git, "https://github.com/rbkmoney/damsel.git", {branch, "release/erlang/master"}}}, - {woody, {git, "https://github.com/rbkmoney/woody_erlang.git", {branch, "master"}}}, - {woody_user_identity, {git, "https://github.com/rbkmoney/woody_erlang_user_identity.git", {branch, "master"}}} + {genlib, {git, "https://github.com/valitydev/genlib.git", {branch, "master"}}}, + {damsel, {git, "https://github.com/valitydev/damsel.git", {branch, "master"}}}, + {woody, {git, "https://github.com/valitydev/woody_erlang.git", {branch, "master"}}}, + {woody_user_identity, {git, "https://github.com/valitydev/woody_erlang_user_identity.git", {branch, "master"}}} ]}. %% XRef checks @@ -65,17 +64,32 @@ {profiles, [ {test, [ + {cover_enabled, true}, {deps, [ - {dmt_client, {git, "https://github.com/rbkmoney/dmt_client.git", {branch, "master"}}} + {dmt_client, {git, "https://github.com/valitydev/dmt_client.git", {branch, "master"}}} + ]}, + {dialyzer, [ + {plt_extra_apps, [eunit, common_test, runtime_tools, damsel, dmt_client]} ]} ]} ]}. -{plugins, [ - {erlfmt, "1.0.0"} +{project_plugins, [ + {rebar3_lint, "1.0.1"}, + {erlfmt, "1.0.0"}, + {covertool, "2.0.4"} ]}. +{elvis_output_format, colors}. + {erlfmt, [ {print_width, 120}, - {files, "{src,include,test}/*.{hrl,erl}"} + {files, ["{src,test}/*.{hrl,erl,app.src}", "rebar.config", "elvis.config", "config/sys.config"]} +]}. + +{covertool, [ + {coverdata_files, [ + "eunit.coverdata", + "ct.coverdata" + ]} ]}. diff --git a/rebar.lock b/rebar.lock index e5b6a52..0850563 100644 --- a/rebar.lock +++ b/rebar.lock @@ -1,49 +1,49 @@ {"1.2.0", [{<<"cache">>,{pkg,<<"cache">>,<<"2.3.3">>},1}, - {<<"certifi">>,{pkg,<<"certifi">>,<<"2.6.1">>},2}, + {<<"certifi">>,{pkg,<<"certifi">>,<<"2.8.0">>},2}, {<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.9.0">>},1}, {<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.11.0">>},2}, {<<"damsel">>, - {git,"https://github.com/rbkmoney/damsel.git", - {ref,"a7c69ff2f576aae91ea68420f54a37cd6258af8e"}}, + {git,"https://github.com/valitydev/damsel.git", + {ref,"3efe7dffaae0f40a77dead166a52f8c9108f2d8d"}}, 0}, {<<"genlib">>, - {git,"https://github.com/rbkmoney/genlib.git", - {ref,"3e1776536802739d8819351b15d54ec70568aba7"}}, + {git,"https://github.com/valitydev/genlib.git", + {ref,"82c5ff3866e3019eb347c7f1d8f1f847bed28c10"}}, 0}, {<<"gproc">>,{pkg,<<"gproc">>,<<"0.9.0">>},1}, - {<<"hackney">>,{pkg,<<"hackney">>,<<"1.17.4">>},1}, + {<<"hackney">>,{pkg,<<"hackney">>,<<"1.18.0">>},1}, {<<"idna">>,{pkg,<<"idna">>,<<"6.1.1">>},2}, {<<"metrics">>,{pkg,<<"metrics">>,<<"1.0.1">>},2}, {<<"mimerl">>,{pkg,<<"mimerl">>,<<"1.2.0">>},2}, {<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.3.1">>},2}, {<<"ranch">>,{pkg,<<"ranch">>,<<"1.8.0">>},2}, {<<"snowflake">>, - {git,"https://github.com/rbkmoney/snowflake.git", + {git,"https://github.com/valitydev/snowflake.git", {ref,"de159486ef40cec67074afe71882bdc7f7deab72"}}, 1}, {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},2}, {<<"thrift">>, - {git,"https://github.com/rbkmoney/thrift_erlang.git", - {ref,"846a0819d9b6d09d0c31f160e33a78dbad2067b4"}}, + {git,"https://github.com/valitydev/thrift_erlang.git", + {ref,"c280ff266ae1c1906fb0dcee8320bb8d8a4a3c75"}}, 1}, {<<"unicode_util_compat">>,{pkg,<<"unicode_util_compat">>,<<"0.7.0">>},2}, {<<"woody">>, - {git,"https://github.com/rbkmoney/woody_erlang.git", - {ref,"330bdcf71e99c2ea7aed424cd718939cb360ec1c"}}, + {git,"https://github.com/valitydev/woody_erlang.git", + {ref,"3ddacb9296691aa8ddad05498d1fd34b078eda75"}}, 0}, {<<"woody_user_identity">>, - {git,"https://github.com/rbkmoney/woody_erlang_user_identity.git", + {git,"https://github.com/valitydev/woody_erlang_user_identity.git", {ref,"a480762fea8d7c08f105fb39ca809482b6cb042e"}}, 0}]}. [ {pkg_hash,[ {<<"cache">>, <<"B23A5FE7095445A88412A6E614C933377E0137B44FFED77C9B3FEF1A731A20B2">>}, - {<<"certifi">>, <<"DBAB8E5E155A0763EEA978C913CA280A6B544BFA115633FA20249C3D396D9493">>}, + {<<"certifi">>, <<"D4FB0A6BB20B7C9C3643E22507E42F356AC090A1DCEA9AB99E27E0376D695EBA">>}, {<<"cowboy">>, <<"865DD8B6607E14CF03282E10E934023A1BD8BE6F6BACF921A7E2A96D800CD452">>}, {<<"cowlib">>, <<"0B9FF9C346629256C42EBE1EEB769A83C6CB771A6EE5960BD110AB0B9B872063">>}, {<<"gproc">>, <<"853CCB7805E9ADA25D227A157BA966F7B34508F386A3E7E21992B1B484230699">>}, - {<<"hackney">>, <<"99DA4674592504D3FB0CFEF0DB84C3BA02B4508BAE2DFF8C0108BAA0D6E0977C">>}, + {<<"hackney">>, <<"C4443D960BB9FBA6D01161D01CD81173089686717D9490E5D3606644C48D121F">>}, {<<"idna">>, <<"8A63070E9F7D0C62EB9D9FCB360A7DE382448200FBBD1B106CC96D3D8099DF8D">>}, {<<"metrics">>, <<"25F094DEA2CDA98213CECC3AEFF09E940299D950904393B2A29D191C346A8486">>}, {<<"mimerl">>, <<"67E2D3F571088D5CFD3E550C383094B47159F3EEE8FFA08E64106CDF5E981BE3">>}, @@ -53,11 +53,11 @@ {<<"unicode_util_compat">>, <<"BC84380C9AB48177092F43AC89E4DFA2C6D62B40B8BD132B1059ECC7232F9A78">>}]}, {pkg_hash_ext,[ {<<"cache">>, <<"44516CE6FA03594D3A2AF025DD3A87BFE711000EB730219E1DDEFC816E0AA2F4">>}, - {<<"certifi">>, <<"524C97B4991B3849DD5C17A631223896272C6B0AF446778BA4675A1DFF53BB7E">>}, + {<<"certifi">>, <<"6AC7EFC1C6F8600B08D625292D4BBF584E14847CE1B6B5C44D983D273E1097EA">>}, {<<"cowboy">>, <<"2C729F934B4E1AA149AFF882F57C6372C15399A20D54F65C8D67BEF583021BDE">>}, {<<"cowlib">>, <<"2B3E9DA0B21C4565751A6D4901C20D1B4CC25CBB7FD50D91D2AB6DD287BC86A9">>}, {<<"gproc">>, <<"587E8AF698CCD3504CF4BA8D90F893EDE2B0F58CABB8A916E2BF9321DE3CF10B">>}, - {<<"hackney">>, <<"DE16FF4996556C8548D512F4DBE22DD58A587BF3332E7FD362430A7EF3986B16">>}, + {<<"hackney">>, <<"9AFCDA620704D720DB8C6A3123E9848D09C87586DC1C10479C42627B905B5C5E">>}, {<<"idna">>, <<"92376EB7894412ED19AC475E4A86F7B413C1B9FBB5BD16DCCD57934157944CEA">>}, {<<"metrics">>, <<"69B09ADDDC4F74A40716AE54D140F93BEB0FB8978D8636EADED0C31B6F099F16">>}, {<<"mimerl">>, <<"F278585650AA581986264638EBF698F8BB19DF297F66AD91B18910DFC6E19323">>}, diff --git a/sys.config.example b/sys.config.example deleted file mode 100644 index 0e6b24e..0000000 --- a/sys.config.example +++ /dev/null @@ -1,12 +0,0 @@ -[ - {party_client, [ - % {services, #{ - % party_management => "http://party-management:8022/v1/processing/partymgmt" - % }}, - % {woody, #{ - % cache_mode => safe, % disabled | safe | aggressive - % aggressive_caching_timeout => 30000, - % options => #{}, % see woody_caching_client:options/0 - % }} - ]} -]. diff --git a/test/machinegun/config.yaml b/test/machinegun/config.yaml index 8f98b8b..77ea6fc 100644 --- a/test/machinegun/config.yaml +++ b/test/machinegun/config.yaml @@ -1,4 +1,6 @@ service_name: machinegun +erlang: + secret_cookie_file: "/opt/machinegun/etc/cookie" namespaces: party: event_sinks: @@ -12,3 +14,6 @@ namespaces: url: http://dominant:8022/v1/stateproc storage: type: memory +woody_server: + max_concurrent_connections: 8000 + http_keep_alive_timeout: 15S diff --git a/test/machinegun/cookie b/test/machinegun/cookie new file mode 100644 index 0000000..9daeafb --- /dev/null +++ b/test/machinegun/cookie @@ -0,0 +1 @@ +test diff --git a/test/party_client_base_pm_tests_SUITE.erl b/test/party_client_base_pm_tests_SUITE.erl index 17a3c72..1ab8523 100644 --- a/test/party_client_base_pm_tests_SUITE.erl +++ b/test/party_client_base_pm_tests_SUITE.erl @@ -105,7 +105,7 @@ init_per_suite(Config) -> true = erlang:unlink(ClientPid), [{apps, Apps}, {client, Client}, {client_pid, ClientPid}, {test_id, genlib:to_binary(Revision)} | Config]. --spec end_per_suite(config()) -> config(). +-spec end_per_suite(config()) -> ok. end_per_suite(C) -> true = erlang:exit(conf(client_pid, C), shutdown), genlib_app:stop_unload_applications(proplists:get_value(apps, C)). @@ -114,7 +114,7 @@ end_per_suite(C) -> init_per_group(Group, Config) -> [{test_id, genlib:to_binary(Group)} | Config]. --spec end_per_group(atom(), config()) -> config(). +-spec end_per_group(atom(), config()) -> ok. end_per_group(_Group, _Config) -> ok. @@ -122,7 +122,7 @@ end_per_group(_Group, _Config) -> init_per_testcase(Name, Config) -> [{test_id, genlib:to_binary(Name)} | Config]. --spec end_per_testcase(atom(), config()) -> config(). +-spec end_per_testcase(atom(), config()) -> ok. end_per_testcase(_Name, _Config) -> ok. @@ -552,7 +552,7 @@ test_init_info(C) -> Context = create_context(), {ok, PartyId, Client, Context}. --spec make_battle_ready_contractor() -> dmsl_payment_processing_thrift:'Contractor'(). +-spec make_battle_ready_contractor() -> dmsl_domain_thrift:'Contractor'(). make_battle_ready_contractor() -> BankAccount = #domain_RussianBankAccount{ account = <<"4276300010908312893">>, diff --git a/test/party_client_config_tests_SUITE.erl b/test/party_client_config_tests_SUITE.erl index a0770b1..ce53e79 100644 --- a/test/party_client_config_tests_SUITE.erl +++ b/test/party_client_config_tests_SUITE.erl @@ -24,12 +24,16 @@ all() -> -spec init_per_suite(config()) -> config(). init_per_suite(Config) -> AppConfig = [ - {party_client, [{woody, #{options => #{a => b, woody_client => #{c => d}}}}]} + {party_client, [ + {woody, #{ + options => #{cache => #{local_name => blah}, woody_client => #{protocol_handler_override => my_handler}} + }} + ]} ], Apps = lists:flatten([genlib_app:start_application_with(A, C) || {A, C} <- AppConfig]), [{apps, Apps} | Config]. --spec end_per_suite(config()) -> config(). +-spec end_per_suite(config()) -> ok. end_per_suite(C) -> genlib_app:stop_unload_applications(proplists:get_value(apps, C)). @@ -37,16 +41,19 @@ end_per_suite(C) -> -spec config_merge_test(config()) -> any(). config_merge_test(_C) -> - Client = party_client:create_client(#{woody_options => #{a => c, woody_client => #{e => f}}}), + Client = party_client:create_client(#{ + woody_options => #{ + cache => #{local_name => party_client_default_cache}, woody_client => #{deadline => undefined} + } + }), WoodyOptions = party_client_config:get_woody_options(Client), #{ - a := c, cache := #{ local_name := party_client_default_cache }, woody_client := #{ - e := f, - c := d, + protocol_handler_override := my_handler, + deadline := undefined, event_handler := woody_event_handler_default, transport_opts := #{}, url := _Urls diff --git a/test/party_domain_fixtures.erl b/test/party_domain_fixtures.erl index 63c3a3a..7adca27 100644 --- a/test/party_domain_fixtures.erl +++ b/test/party_domain_fixtures.erl @@ -486,8 +486,6 @@ construct_category(Ref, Name, Type) -> -spec construct_payment_method(dmsl_domain_thrift:'PaymentMethodRef'()) -> {payment_method, dmsl_domain_thrift:'PaymentMethodObject'()}. -construct_payment_method(?pmt(_Type, ?tkz_bank_card(Name, _)) = Ref) when is_atom(Name) -> - construct_payment_method(Name, Ref); construct_payment_method(?pmt(_Type, Name) = Ref) when is_atom(Name) -> construct_payment_method(Name, Ref). @@ -588,12 +586,12 @@ construct_system_account_set(Ref, Name, ?cur(CurrencyCode)) -> }}. -spec construct_external_account_set(external_account_set()) -> - {system_account_set, dmsl_domain_thrift:'ExternalAccountSetObject'()}. + {external_account_set, dmsl_domain_thrift:'ExternalAccountSetObject'()}. construct_external_account_set(Ref) -> construct_external_account_set(Ref, <<"Primaries">>, ?cur(<<"RUB">>)). -spec construct_external_account_set(external_account_set(), name(), currency()) -> - {system_account_set, dmsl_domain_thrift:'ExternalAccountSetObject'()}. + {external_account_set, dmsl_domain_thrift:'ExternalAccountSetObject'()}. construct_external_account_set(Ref, Name, ?cur(CurrencyCode)) -> AccountID1 = 1, AccountID2 = 2, @@ -630,7 +628,8 @@ construct_business_schedule(Ref) -> } }}. --spec construct_routing_ruleset(routing_ruleset_ref(), name(), _) -> dmsl_domain_thrift:'RoutingRulesetObject'(). +-spec construct_routing_ruleset(routing_ruleset_ref(), name(), _) -> + {routing_rules, dmsl_domain_thrift:'RoutingRulesObject'()}. construct_routing_ruleset(Ref, Name, Decisions) -> {routing_rules, #domain_RoutingRulesObject{ ref = Ref,