Skip to content

Commit

Permalink
Upgrade amoc_rest with new openapi gens and enforce OTP27
Browse files Browse the repository at this point in the history
  • Loading branch information
NelsonVides committed Nov 16, 2024
1 parent b6dc37c commit e1ebdaf
Show file tree
Hide file tree
Showing 16 changed files with 316 additions and 186 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ jobs:
name: OTP ${{matrix.otp_vsn}}
strategy:
matrix:
otp_vsn: ['27', '26', '25']
rebar_vsn: ['3.23.0']
otp_vsn: ['27']
rebar_vsn: ['3.24.0']
runs-on: 'ubuntu-24.04'
steps:
- uses: actions/checkout@v4
Expand All @@ -29,8 +29,8 @@ jobs:
name: docker container test with OTP ${{matrix.otp_vsn}}
strategy:
matrix:
otp_vsn: ['27', '26', '25']
rebar_vsn: ['3.23.0']
otp_vsn: ['27']
rebar_vsn: ['3.24.0']
runs-on: 'ubuntu-24.04'
env:
OTP_RELEASE: ${{ matrix.otp_vsn }}
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG otp_vsn=25.3
ARG otp_vsn=27.1
FROM erlang:${otp_vsn}
LABEL org.label-schema.name='AMOC Arsenal' \
org.label-schema.vendor='Erlang Solutions'
Expand Down
2 changes: 1 addition & 1 deletion ci/build_docker_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ enable_strict_mode
cd "$git_root"

version="$(git rev-parse --short HEAD)"
otp_vsn="${OTP_RELEASE:-26.2}"
otp_vsn="${OTP_RELEASE:-27.1}"
echo "ERLANG/OTP '${otp_vsn}'"

docker build \
Expand Down
11 changes: 6 additions & 5 deletions rebar.config
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
{minimum_otp_vsn, "27"}.

{erl_opts, [debug_info, warn_missing_spec]}.

{alias, [{test, [compile, ct, xref, dialyzer]}]}.

{deps, [
{amoc, "3.3.0"},
{telemetry, "1.2.1"},
{telemetry, "1.3.0"},
{exometer_core, {git, "https://github.com/esl/exometer_core.git", {branch, "master"}}},
{exometer_report_graphite,
{git, "https://github.com/esl/exometer_report_graphite.git", {branch, "master"}}},
%% when updating amoc_rest version, don't forget to update it at ./doc/http-api.md as well.
{amoc_rest, {git, "https://github.com/esl/amoc_rest.git", {tag, "1.1.2"}}},
{docsh, "0.7.2"}
{amoc_rest, {git, "https://github.com/esl/amoc_rest.git", {branch, "openapi_server"}}}
]}.

{profiles, [
Expand All @@ -23,10 +24,10 @@
]}.

{dialyzer, [
{plt_extra_apps, [compiler, telemetry, amoc, ranch, cowboy, jsx]}
{plt_extra_apps, [compiler, telemetry, amoc, ranch, cowboy, jesse]}
]}.

{ xref_checks, [
{xref_checks, [
%% enable most checks, but avoid 'unused calls' which makes amoc-arsenal fail...
undefined_function_calls, undefined_functions, locals_not_used,
deprecated_function_calls, deprecated_functions
Expand Down
29 changes: 7 additions & 22 deletions rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
[{<<"amoc">>,{pkg,<<"amoc">>,<<"3.3.0">>},0},
{<<"amoc_rest">>,
{git,"https://github.com/esl/amoc_rest.git",
{ref,"1e41be5b6b332a827d125380fa4f7ea23a00748e"}},
{ref,"8277e90097d9f99e76330bf100f53086b1334523"}},
0},
{<<"bear">>,{pkg,<<"bear">>,<<"1.0.0">>},1},
{<<"cowboy">>,{pkg,<<"cowboy">>,<<"2.12.0">>},1},
{<<"cowlib">>,{pkg,<<"cowlib">>,<<"2.13.0">>},2},
{<<"docsh">>,{pkg,<<"docsh">>,<<"0.7.2">>},0},
{<<"exometer_core">>,
{git,"https://github.com/esl/exometer_core.git",
{ref,"123daa053a4abb3ff4bdbf52f08344da535294e9"}},
Expand All @@ -16,41 +15,27 @@
{git,"https://github.com/esl/exometer_report_graphite.git",
{ref,"59e475a094818294443de9dc68e08ee0116a5626"}},
0},
{<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},2},
{<<"jesse">>,{pkg,<<"jesse">>,<<"1.8.0">>},1},
{<<"jsx">>,{pkg,<<"jsx">>,<<"3.1.0">>},1},
{<<"jesse">>,{pkg,<<"jesse">>,<<"1.8.1">>},1},
{<<"parse_trans">>,{pkg,<<"parse_trans">>,<<"3.4.0">>},1},
{<<"providers">>,{pkg,<<"providers">>,<<"1.8.1">>},1},
{<<"ranch">>,{pkg,<<"ranch">>,<<"2.1.0">>},1},
{<<"rfc3339">>,{pkg,<<"rfc3339">>,<<"0.9.0">>},2},
{<<"telemetry">>,{pkg,<<"telemetry">>,<<"1.2.1">>},0}]}.
{<<"telemetry">>,{pkg,<<"telemetry">>,<<"1.3.0">>},0}]}.
[
{pkg_hash,[
{<<"amoc">>, <<"531B7E8CE39D40B4BF5A819868091C4451DC3D3FDAE753E3E3B1D0E5E8E81CDD">>},
{<<"bear">>, <<"430419C1126B477686CDE843E88BA0F2C7DC5CDF0881C677500074F704339A99">>},
{<<"cowboy">>, <<"F276D521A1FF88B2B9B4C54D0E753DA6C66DD7BE6C9FCA3D9418B561828A3731">>},
{<<"cowlib">>, <<"DB8F7505D8332D98EF50A3EF34B34C1AFDDEC7506E4EE4DD4A3A266285D282CA">>},
{<<"docsh">>, <<"F893D5317A0E14269DD7FE79CF95FB6B9BA23513DA0480EC6E77C73221CAE4F2">>},
{<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>},
{<<"jesse">>, <<"CF7615C3F2BE892F77BCCF736F23B4BD54A0FC686C7040431AEBA5EF7932CC4D">>},
{<<"jsx">>, <<"D12516BAA0BB23A59BB35DCCAF02A1BD08243FCBB9EFE24F2D9D056CCFF71268">>},
{<<"jesse">>, <<"C9E3670C7EE40F719734E3BC716578143AABA93FC7525A02A7D5CB300B3AD71E">>},
{<<"parse_trans">>, <<"BB87AC362A03CA674EBB7D9D498F45C03256ADED7214C9101F7035EF44B798C7">>},
{<<"providers">>, <<"70B4197869514344A8A60E2B2A4EF41CA03DEF43CFB1712ECF076A0F3C62F083">>},
{<<"ranch">>, <<"2261F9ED9574DCFCC444106B9F6DA155E6E540B2F82BA3D42B339B93673B72A3">>},
{<<"rfc3339">>, <<"2075653DC9407541C84B1E15F8BDA2ABE95FB17C9694025E079583F2D19C1060">>},
{<<"telemetry">>, <<"68FDFE8D8F05A8428483A97D7AAB2F268AAFF24B49E0F599FAA091F1D4E7F61C">>}]},
{<<"telemetry">>, <<"FEDEBBAE410D715CF8E7062C96A1EF32EC22E764197F70CDA73D82778D61E7A2">>}]},
{pkg_hash_ext,[
{<<"amoc">>, <<"B8DD4F77BB94716ABC64E863158EEF8E1375CECB2F69E57DC4A293B0949D4985">>},
{<<"bear">>, <<"157B67901ADF84FF0DA6EAE035CA1292A0AC18AA55148154D8C582B2C68959DB">>},
{<<"cowboy">>, <<"8A7ABE6D183372CEB21CAA2709BEC928AB2B72E18A3911AA1771639BEF82651E">>},
{<<"cowlib">>, <<"E1E1284DC3FC030A64B1AD0D8382AE7E99DA46C3246B815318A4B848873800A4">>},
{<<"docsh">>, <<"4E7DB461BB07540D2BC3D366B8513F0197712D0495BB85744F367D3815076134">>},
{<<"getopt">>, <<"53E1AB83B9CEB65C9672D3E7A35B8092E9BDC9B3EE80721471A161C10C59959C">>},
{<<"jesse">>, <<"860EF4621DDBFB72792668929BE127E45E8B07CF19EEA264B0A9D48D36CCA41B">>},
{<<"jsx">>, <<"0C5CC8FDC11B53CC25CF65AC6705AD39E54ECC56D1C22E4ADB8F5A53FB9427F3">>},
{<<"jesse">>, <<"0EDED3F18623FDA2F25989804A06CF518B4ACF2E9365B18C8E8C013D7E3C906F">>},
{<<"parse_trans">>, <<"F99E368830BEA44552224E37E04943A54874F08B8590485DE8D13832B63A2DC3">>},
{<<"providers">>, <<"E45745ADE9C476A9A469EA0840E418AB19360DC44F01A233304E118A44486BA0">>},
{<<"ranch">>, <<"244EE3FA2A6175270D8E1FC59024FD9DBC76294A321057DE8F803B1479E76916">>},
{<<"rfc3339">>, <<"182314DE35C9F4180B22EB5F22916D8D7A799C1109A060C752970273A9332AD6">>},
{<<"telemetry">>, <<"DAD9CE9D8EFFC621708F99EAC538EF1CBE05D6A874DD741DE2E689C47FEAFED5">>}]}
{<<"telemetry">>, <<"7015FC8919DBE63764F4B4B87A95B7C0996BD539E0D499BE6EC9D7F3875B79E6">>}]}
].
7 changes: 3 additions & 4 deletions src/amoc_arsenal.app.src
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
{application, amoc_arsenal, [
{description, "An OTP application"},
{vsn, "0.1.0"},
{description, "A batteries-included load-testing tool."},
{vsn, git},
{registered, []},
{mod, {amoc_arsenal_app, []}},
{applications, [
kernel,
stdlib,
amoc,
exometer_core,
exometer_report_graphite,
amoc_rest,
docsh
amoc
]},
{env, [
{exometer_predefined, [
Expand Down
22 changes: 4 additions & 18 deletions src/amoc_arsenal_sup.erl
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
%%%-------------------------------------------------------------------
%% @doc amoc_arsenal top level supervisor.
%% @end
%%%-------------------------------------------------------------------

-module(amoc_arsenal_sup).

-behaviour(supervisor).
Expand All @@ -13,23 +8,14 @@

-define(SERVER, ?MODULE).

-spec start_link() -> supervisor:startlink_ret().
start_link() ->
supervisor:start_link({local, ?SERVER}, ?MODULE, []).
supervisor:start_link({local, ?SERVER}, ?MODULE, noargs).

%% sup_flags() = #{strategy => strategy(), % optional
%% intensity => non_neg_integer(), % optional
%% period => pos_integer()} % optional
%% child_spec() = #{id => child_id(), % mandatory
%% start => mfargs(), % mandatory
%% restart => restart(), % optional
%% shutdown => shutdown(), % optional
%% type => worker(), % optional
%% modules => modules()} % optional
init([]) ->
-spec init(noargs) -> {ok, {supervisor:sup_flags(), [supervisor:child_spec()]}}.
init(noargs) ->
SupFlags = #{strategy => one_for_all,
intensity => 0,
period => 1},
ChildSpecs = [],
{ok, {SupFlags, ChildSpecs}}.

%% internal functions
17 changes: 12 additions & 5 deletions src/rest_api/amoc_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,19 @@

-spec start() -> {ok, pid()} | {error, any()}.
start() ->
LogicHandler = amoc_api_logic_handler,
amoc_api_logic_handler:set_validator_state(),
Port = amoc_config_env:get(api_port, 4000),
ServerParams = #{ip => {0, 0, 0, 0}, port => Port, net_opts => [],
logic_handler => LogicHandler},
amoc_rest_server:start(http_server, ServerParams).
TransportOpts = #{socket_opts => [{ip, {0, 0, 0, 0}}, {port, Port}]},
amoc_rest_server:start(
openapi_http_server,
#{
transport => tcp,
transport_opts => TransportOpts,
protocol_opts => #{},
logic_handler => amoc_api_logic_handler
}
).

-spec stop() -> ok | {error, not_found}.
stop() ->
cowboy:stop_listener(http_server).
cowboy:stop_listener(openapi_http_server).
3 changes: 1 addition & 2 deletions src/rest_api/amoc_api_helpers_execution.erl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@

-spec start(body()) -> ret_value().
start(#{<<"scenario">> := ScenarioName} = Body) ->
case
amoc_api_helpers_scenario_info:is_loaded(ScenarioName) of
case amoc_api_helpers_scenario_info:is_loaded(ScenarioName) of
{true, Scenario} ->
Users = maps:get(<<"users">>, Body, 0),
SettingsMap = maps:get(<<"settings">>, Body, #{}),
Expand Down
24 changes: 11 additions & 13 deletions src/rest_api/amoc_api_helpers_scenario_info.erl
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
%%==============================================================================
%% Copyright 2020 Erlang Solutions Ltd.
%% Copyright 2024 Erlang Solutions Ltd.
%% Licensed under the Apache License, Version 2.0 (see LICENSE file)
%%==============================================================================
-module(amoc_api_helpers_scenario_info).

-include_lib("kernel/include/eep48.hrl").

%% API
-export([is_loaded/1,
scenario_settings/1,
scenario_params/1,
get_edoc/1]).
get_documentation/1]).

-spec get_edoc(module()) -> binary().
get_edoc(Scenario) ->
case docsh_lib:get_docs(Scenario) of
-spec get_documentation(module()) -> binary().
get_documentation(Scenario) ->
case code:get_doc(Scenario) of
{error, _} ->
ScenarioName = atom_to_binary(Scenario, utf8),
<<"cannot extract documentation for ", ScenarioName/binary>>;
{ok, Docs} ->
case docsh_format:lookup(Docs, Scenario, [moduledoc]) of
{not_found, _} ->
<<"no documentation found">>;
{ok, [DocItem]} ->
Doc = maps:get(<<"en">>, DocItem),
iolist_to_binary(docsh_edoc:format_edoc(Doc, #{}))
end
{ok, #docs_v1{module_doc = ModuleDoc}} ->
Doc = maps:get(<<"en">>, ModuleDoc),
iolist_to_binary(Doc)
end.

-spec scenario_settings(module()) -> #{atom() => binary()}.
Expand Down
2 changes: 1 addition & 1 deletion src/rest_api/amoc_api_helpers_status.erl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ get_status() ->
{amoc, _Desc, _Vsn} -> <<"up">>;
false -> <<"down">>
end,
Env = get_envs(),
Env = maps:from_list(get_envs()),
Status = #{amoc_status => AmocStatus, env => Env},
maybe_add_controller_status(Status).

Expand Down
Loading

0 comments on commit e1ebdaf

Please sign in to comment.