Merge pull request #5170 from qzhuyan/dev/william/ci-fix-build-package

ci(quic): conditionally quicer build
This commit is contained in:
William Yang 2021-07-08 17:34:47 +02:00 committed by GitHub
commit 793aa951e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 115 additions and 45 deletions

View File

@ -38,7 +38,8 @@ emqx_test(){
packagename=$(basename "${PACKAGE_PATH}/${EMQX_NAME}"-*.zip) packagename=$(basename "${PACKAGE_PATH}/${EMQX_NAME}"-*.zip)
unzip -q "${PACKAGE_PATH}/${packagename}" unzip -q "${PACKAGE_PATH}/${packagename}"
export EMQX_ZONE__EXTERNAL__SERVER_KEEPALIVE=60 \ export EMQX_ZONE__EXTERNAL__SERVER_KEEPALIVE=60 \
EMQX_MQTT__MAX_TOPIC_ALIAS=10 EMQX_MQTT__MAX_TOPIC_ALIAS=10
[[ $(arch) == *arm* || $(arch) == aarch64 ]] && export EMQX_LISTENER__QUIC__EXTERNAL__ENDPOINT=''
# sed -i '/emqx_telemetry/d' "${PACKAGE_PATH}"/emqx/data/loaded_plugins # sed -i '/emqx_telemetry/d' "${PACKAGE_PATH}"/emqx/data/loaded_plugins
echo "running ${packagename} start" echo "running ${packagename} start"
@ -113,11 +114,25 @@ emqx_test(){
} }
running_test(){ running_test(){
export EMQX_ZONE__EXTERNAL__SERVER_KEEPALIVE=60 \
EMQX_MQTT__MAX_TOPIC_ALIAS=10
# sed -i '/emqx_telemetry/d' /var/lib/emqx/loaded_plugins # sed -i '/emqx_telemetry/d' /var/lib/emqx/loaded_plugins
emqx_env_vars=$(dirname "$(readlink "$(command -v emqx)")")/../releases/emqx_vars
if ! emqx start; then if [ -f "$emqx_env_vars" ];
then
tee -a "$emqx_env_vars" <<EOF
export EMQX_ZONE__EXTERNAL__SERVER_KEEPALIVE=60
export EMQX_MQTT__MAX_TOPIC_ALIAS=10
EOF
## for ARM, due to CI env issue, skip start of quic listener for the moment
[[ $(arch) == *arm* || $(arch) == aarch64 ]] && tee tee -a "$emqx_env_vars" <<EOF
export EMQX_LISTENER__QUIC__EXTERNAL__ENDPOINT=''
EOF
else
echo "Error: cannot locate emqx_vars"
exit 1
fi
if ! su - emqx -c "emqx start"; then
cat /var/log/emqx/erlang.log.1 || true cat /var/log/emqx/erlang.log.1 || true
cat /var/log/emqx/emqx.log.1 || true cat /var/log/emqx/emqx.log.1 || true
exit 1 exit 1
@ -138,7 +153,6 @@ running_test(){
if [ "$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" = ubuntu ] \ if [ "$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" = ubuntu ] \
|| [ "$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" = debian ] ;then || [ "$(sed -n '/^ID=/p' /etc/os-release | sed -r 's/ID=(.*)/\1/g' | sed 's/"//g')" = debian ] ;then
if ! service emqx start; then if ! service emqx start; then
cat /var/log/emqx/erlang.log.1 || true cat /var/log/emqx/erlang.log.1 || true
cat /var/log/emqx/emqx.log.1 || true cat /var/log/emqx/emqx.log.1 || true

View File

@ -42,6 +42,7 @@ jobs:
if: endsWith(github.repository, 'emqx') if: endsWith(github.repository, 'emqx')
run: | run: |
make -C source deps-all make -C source deps-all
rm source/rebar.lock
zip -ryq source.zip source/* source/.[^.]* zip -ryq source.zip source/* source/.[^.]*
- name: get_all_deps - name: get_all_deps
if: endsWith(github.repository, 'enterprise') if: endsWith(github.repository, 'enterprise')
@ -63,6 +64,7 @@ jobs:
if: endsWith(github.repository, 'emqx') if: endsWith(github.repository, 'emqx')
strategy: strategy:
fail-fast: false
matrix: matrix:
profile: ${{fromJSON(needs.prepare.outputs.profiles)}} profile: ${{fromJSON(needs.prepare.outputs.profiles)}}
exclude: exclude:
@ -131,6 +133,7 @@ jobs:
needs: prepare needs: prepare
strategy: strategy:
fail-fast: false
matrix: matrix:
profile: ${{fromJSON(needs.prepare.outputs.profiles)}} profile: ${{fromJSON(needs.prepare.outputs.profiles)}}
erl_otp: erl_otp:
@ -210,6 +213,7 @@ jobs:
needs: prepare needs: prepare
strategy: strategy:
fail-fast: false
matrix: matrix:
profile: ${{fromJSON(needs.prepare.outputs.profiles)}} profile: ${{fromJSON(needs.prepare.outputs.profiles)}}
arch: arch:
@ -336,6 +340,7 @@ jobs:
needs: prepare needs: prepare
strategy: strategy:
fail-fast: false
matrix: matrix:
profile: ${{fromJSON(needs.prepare.outputs.profiles)}} profile: ${{fromJSON(needs.prepare.outputs.profiles)}}
arch: arch:

View File

@ -20,7 +20,6 @@
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}} , {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
, {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.5"}}}
]}. ]}.
{plugins, [rebar3_proper]}. {plugins, [rebar3_proper]}.
@ -31,7 +30,7 @@
[ meck [ meck
, {bbmustache,"1.10.0"} , {bbmustache,"1.10.0"}
, {emqx_ct_helpers, {git,"https://github.com/emqx/emqx-ct-helpers", {branch,"hocon"}}} , {emqx_ct_helpers, {git,"https://github.com/emqx/emqx-ct-helpers", {branch,"hocon"}}}
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.4.1"}}} , {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.4.2"}}}
]}, ]},
{extra_src_dirs, [{"test",[recursive]}]} {extra_src_dirs, [{"test",[recursive]}]}
]} ]}

View File

@ -1,11 +1,30 @@
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}}, IsCentos6 = fun() ->
AddBcrypt = fun(C) -> case file:read_file("/etc/centos-release") of
{deps, Deps0} = lists:keyfind(deps, 1, C), {ok, <<"CentOS release 6", _/binary >>} ->
Deps = [Bcrypt | Deps0], true;
lists:keystore(deps, 1, C, {deps, Deps}) _ ->
end, false
end
end,
case os:type() of IsWin32 = fun() ->
{win32, _} -> CONFIG; win32 =:= element(1, os:type())
_ -> AddBcrypt(CONFIG) end,
end.
IsQuicSupp = fun() ->
not (IsCentos6() orelse IsWin32() orelse
false =/= os:getenv("EMQX_BUILD_WITHOUT_QUIC")
)
end,
Bcrypt = {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}},
Quicer = {quicer, {git, "https://github.com/emqx/quic.git", {branch, "main"}}},
ExtraDeps = fun(C) ->
{deps, Deps0} = lists:keyfind(deps, 1, C),
Deps = Deps0 ++ [Bcrypt || not IsWin32()] ++
[ Quicer || IsQuicSupp()],
lists:keystore(deps, 1, C, {deps, Deps})
end,
ExtraDeps(CONFIG).

View File

@ -4,7 +4,7 @@
{vsn, "5.0.0"}, % strict semver, bump manually! {vsn, "5.0.0"}, % strict semver, bump manually!
{modules, []}, {modules, []},
{registered, []}, {registered, []},
{applications, [kernel,stdlib,gproc,gen_rpc,esockd,cowboy,sasl,os_mon,quicer,jiffy]}, {applications, [kernel,stdlib,gproc,gen_rpc,esockd,cowboy,sasl,os_mon,jiffy]},
{mod, {emqx_app,[]}}, {mod, {emqx_app,[]}},
{env, []}, {env, []},
{licenses, ["Apache-2.0"]}, {licenses, ["Apache-2.0"]},

View File

@ -49,6 +49,8 @@ start(_Type, _Args) ->
_ = load_ce_modules(), _ = load_ce_modules(),
ekka:start(), ekka:start(),
ok = ekka_rlog:wait_for_shards(?EMQX_SHARDS, infinity), ok = ekka_rlog:wait_for_shards(?EMQX_SHARDS, infinity),
false == os:getenv("EMQX_NO_QUIC")
andalso application:ensure_all_started(quicer),
{ok, Sup} = emqx_sup:start_link(), {ok, Sup} = emqx_sup:start_link(),
ok = start_autocluster(), ok = start_autocluster(),
% ok = emqx_plugins:init(), % ok = emqx_plugins:init(),

View File

@ -106,6 +106,8 @@ format_listen_on(ListenOn) -> format(ListenOn).
start_listener(#{proto := Proto, name := Name, listen_on := ListenOn, opts := Options}) -> start_listener(#{proto := Proto, name := Name, listen_on := ListenOn, opts := Options}) ->
ID = identifier(Proto, Name), ID = identifier(Proto, Name),
case start_listener(Proto, ListenOn, Options) of case start_listener(Proto, ListenOn, Options) of
{ok, skipped} ->
console_print("Start ~s listener on ~s skpped.~n", [ID, format(ListenOn)]);
{ok, _} -> {ok, _} ->
console_print("Start ~s listener on ~s successfully.~n", [ID, format(ListenOn)]); console_print("Start ~s listener on ~s successfully.~n", [ID, format(ListenOn)]);
{error, Reason} -> {error, Reason} ->
@ -123,7 +125,7 @@ console_print(_Fmt, _Args) -> ok.
%% Start MQTT/TCP listener %% Start MQTT/TCP listener
-spec(start_listener(esockd:proto(), esockd:listen_on(), [esockd:option()]) -spec(start_listener(esockd:proto(), esockd:listen_on(), [esockd:option()])
-> {ok, pid()} | {error, term()}). -> {ok, pid() | skipped} | {error, term()}).
start_listener(tcp, ListenOn, Options) -> start_listener(tcp, ListenOn, Options) ->
start_mqtt_listener('mqtt:tcp', ListenOn, Options); start_mqtt_listener('mqtt:tcp', ListenOn, Options);
@ -143,24 +145,31 @@ start_listener(Proto, ListenOn, Options) when Proto == https; Proto == wss ->
%% Start MQTT/QUIC listener %% Start MQTT/QUIC listener
start_listener(quic, ListenOn, Options) -> start_listener(quic, ListenOn, Options) ->
%% @fixme unsure why we need reopen lib and reopen config. case [ A || {quicer, _, _} = A<-application:which_applications() ] of
quicer_nif:open_lib(), [_] ->
quicer_nif:reg_open(), %% @fixme unsure why we need reopen lib and reopen config.
SSLOpts = proplists:get_value(ssl_options, Options), quicer_nif:open_lib(),
DefAcceptors = erlang:system_info(schedulers_online) * 8, quicer_nif:reg_open(),
ListenOpts = [ {cert, proplists:get_value(certfile, SSLOpts)} SSLOpts = proplists:get_value(ssl_options, Options),
, {key, proplists:get_value(keyfile, SSLOpts)} DefAcceptors = erlang:system_info(schedulers_online) * 8,
, {alpn, ["mqtt"]} ListenOpts = [ {cert, proplists:get_value(certfile, SSLOpts)}
, {conn_acceptors, proplists:get_value(acceptors, Options, DefAcceptors)} , {key, proplists:get_value(keyfile, SSLOpts)}
, {idle_timeout_ms, proplists:get_value(idle_timeout, Options, 60000)} , {alpn, ["mqtt"]}
], , {conn_acceptors, proplists:get_value(acceptors, Options, DefAcceptors)}
ConnectionOpts = [ {conn_callback, emqx_quic_connection} , {idle_timeout_ms, proplists:get_value(idle_timeout, Options, 60000)}
, {peer_unidi_stream_count, 1} ],
, {peer_bidi_stream_count, 10} ConnectionOpts = [ {conn_callback, emqx_quic_connection}
| Options , {peer_unidi_stream_count, 1}
], , {peer_bidi_stream_count, 10}
StreamOpts = [], | Options
quicer:start_listener('mqtt:quic', ListenOn, {ListenOpts, ConnectionOpts, StreamOpts}). ],
StreamOpts = [],
quicer:start_listener('mqtt:quic', ListenOn, {ListenOpts, ConnectionOpts, StreamOpts});
[] ->
io:format(standard_error, "INFO: quicer application is unavailable/disabled~n",
[]),
{ok, skipped}
end.
replace(Opts, Key, Value) -> [{Key, Value} | proplists:delete(Key, Opts)]. replace(Opts, Key, Value) -> [{Key, Value} | proplists:delete(Key, Opts)].

View File

@ -333,7 +333,7 @@ fields("quic_listener") ->
[ {"$name", ref("quic_listener_settings")}]; [ {"$name", ref("quic_listener_settings")}];
fields("listener_settings") -> fields("listener_settings") ->
[ {"endpoint", t(union(ip_port(), integer()))} [ {"endpoint", t(union([ip_port(), integer(), ""]))}
, {"acceptors", t(integer(), undefined, 8)} , {"acceptors", t(integer(), undefined, 8)}
, {"max_connections", t(integer(), undefined, 1024)} , {"max_connections", t(integer(), undefined, 1024)}
, {"max_conn_rate", t(integer())} , {"max_conn_rate", t(integer())}
@ -785,6 +785,7 @@ tr_listeners(Conf) ->
TcpListeners = fun(Type, Name) -> TcpListeners = fun(Type, Name) ->
Prefix = string:join(["listener", Type, Name], "."), Prefix = string:join(["listener", Type, Name], "."),
ListenOnN = case conf_get(Prefix ++ ".endpoint", Conf) of ListenOnN = case conf_get(Prefix ++ ".endpoint", Conf) of
"" -> [];
undefined -> []; undefined -> [];
ListenOn -> ListenOn ListenOn -> ListenOn
end, end,
@ -801,6 +802,8 @@ tr_listeners(Conf) ->
SslListeners = fun(Type, Name) -> SslListeners = fun(Type, Name) ->
Prefix = string:join(["listener", Type, Name], "."), Prefix = string:join(["listener", Type, Name], "."),
case conf_get(Prefix ++ ".endpoint", Conf) of case conf_get(Prefix ++ ".endpoint", Conf) of
"" ->
[];
undefined -> undefined ->
[]; [];
ListenOn -> ListenOn ->

View File

@ -55,7 +55,7 @@
, {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.1"}}} , {ecpool, {git, "https://github.com/emqx/ecpool", {tag, "0.5.1"}}}
, {replayq, {git, "https://github.com/emqx/replayq", {tag, "0.3.2"}}} , {replayq, {git, "https://github.com/emqx/replayq", {tag, "0.3.2"}}}
, {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}} , {pbkdf2, {git, "https://github.com/emqx/erlang-pbkdf2.git", {branch, "2.0.4"}}}
, {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.4.1"}}} , {emqtt, {git, "https://github.com/emqx/emqtt", {tag, "1.4.2"}}}
, {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.2"}}} , {rulesql, {git, "https://github.com/emqx/rulesql", {tag, "0.1.2"}}}
, {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}} , {recon, {git, "https://github.com/ferd/recon", {tag, "2.5.1"}}}
, {observer_cli, "1.6.1"} % NOTE: depends on recon 2.5.1 , {observer_cli, "1.6.1"} % NOTE: depends on recon 2.5.1
@ -63,7 +63,6 @@
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "0.13.0"}}}
, {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.9.0"}}} , {hocon, {git, "https://github.com/emqx/hocon.git", {tag, "0.9.0"}}}
, {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.2.1"}}} , {emqx_http_lib, {git, "https://github.com/emqx/emqx_http_lib.git", {tag, "0.2.1"}}}
, {quicer, {git, "https://github.com/emqx/quic.git", {tag, "0.0.5"}}}
]}. ]}.
{xref_ignores, {xref_ignores,

View File

@ -15,12 +15,14 @@ do(Dir, CONFIG) ->
bcrypt() -> bcrypt() ->
{bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}}. {bcrypt, {git, "https://github.com/emqx/erlang-bcrypt.git", {branch, "0.6.0"}}}.
quicer() ->
%% @todo use tag
{quicer, {git, "https://github.com/emqx/quic.git", {branch, "main"}}}.
deps(Config) -> deps(Config) ->
{deps, OldDeps} = lists:keyfind(deps, 1, Config), {deps, OldDeps} = lists:keyfind(deps, 1, Config),
MoreDeps = case provide_bcrypt_dep() of MoreDeps = [bcrypt() || provide_bcrypt_dep()] ++
true -> [bcrypt()]; [quicer() || is_quicer_supported()],
false -> []
end,
{HasElixir, ExtraDeps} = extra_deps(), {HasElixir, ExtraDeps} = extra_deps(),
{HasElixir, lists:keystore(deps, 1, Config, {deps, OldDeps ++ MoreDeps ++ ExtraDeps})}. {HasElixir, lists:keystore(deps, 1, Config, {deps, OldDeps ++ MoreDeps ++ ExtraDeps})}.
@ -78,6 +80,24 @@ is_cover_enabled() ->
is_enterprise() -> is_enterprise() ->
filelib:is_regular("EMQX_ENTERPRISE"). filelib:is_regular("EMQX_ENTERPRISE").
is_quicer_supported() ->
not (false =/= os:getenv("BUILD_WITHOUT_QUIC") orelse
is_win32() orelse is_centos_6()
).
is_centos_6() ->
%% reason:
%% glibc is too old
case file:read_file("/etc/centos-release") of
{ok, <<"CentOS release 6", _/binary >>} ->
true;
_ ->
false
end.
is_win32() ->
win32 =:= element(1, os:type()).
project_app_dirs() -> project_app_dirs() ->
["apps/*"] ++ ["apps/*"] ++
case is_enterprise() of case is_enterprise() of
@ -242,7 +262,6 @@ relx_apps(ReleaseType) ->
, compiler , compiler
, runtime_tools , runtime_tools
, cuttlefish , cuttlefish
, quicer
, emqx , emqx
, {mnesia, load} , {mnesia, load}
, {ekka, load} , {ekka, load}
@ -263,6 +282,7 @@ relx_apps(ReleaseType) ->
, emqx_retainer , emqx_retainer
, emqx_statsd , emqx_statsd
] ]
++ [quicer || is_quicer_supported()]
++ [emqx_telemetry || not is_enterprise()] ++ [emqx_telemetry || not is_enterprise()]
++ [emqx_license || is_enterprise()] ++ [emqx_license || is_enterprise()]
++ [bcrypt || provide_bcrypt_release(ReleaseType)] ++ [bcrypt || provide_bcrypt_release(ReleaseType)]