test: integer CI check failed

This commit is contained in:
zhongwencool 2023-06-19 10:30:39 +08:00
parent a4be9b8281
commit 07172e42f0
28 changed files with 104 additions and 101 deletions

View File

@ -497,17 +497,24 @@ t_update_config(_Config) ->
emqx_config_handler:start_link(),
{ok, Pid} = emqx_crl_cache:start_link(),
Conf = #{
refresh_interval => timer:minutes(5),
http_timeout => timer:minutes(10),
refresh_interval => <<"5m">>,
http_timeout => <<"10m">>,
capacity => 123
},
?assertMatch({ok, _}, emqx:update_config([<<"crl_cache">>], Conf)),
State = sys:get_state(Pid),
?assertEqual(Conf, #{
?assertEqual(
#{
refresh_interval => timer:minutes(5),
http_timeout => timer:minutes(10),
capacity => 123
},
#{
refresh_interval => element(3, State),
http_timeout => element(4, State),
capacity => element(7, State)
}),
}
),
emqx_config:erase(<<"crl_cache">>),
emqx_config_handler:stop(),
ok.

View File

@ -33,9 +33,9 @@ init_per_suite(Config) ->
<<"enable">> => true,
<<"max_count">> => 3,
% 0.1s
<<"window_time">> => 100,
<<"window_time">> => <<"100ms">>,
%% 2s
<<"ban_time">> => "2s"
<<"ban_time">> => <<"2s">>
}
),
Config.
@ -119,16 +119,16 @@ t_conf_update(_) ->
?assertEqual(Global#{window_time := 100}, emqx_flapping:get_policy(zone_1)),
Zones = #{
<<"zone_1">> => #{<<"flapping_detect">> => #{<<"window_time">> => 123}},
<<"zone_2">> => #{<<"flapping_detect">> => #{<<"window_time">> => 456}}
<<"zone_1">> => #{<<"flapping_detect">> => #{<<"window_time">> => <<"123s">>}},
<<"zone_2">> => #{<<"flapping_detect">> => #{<<"window_time">> => <<"456s">>}}
},
?assertMatch({ok, _}, emqx:update_config([zones], Zones)),
%% new_zone is already deleted
?assertError({config_not_found, _}, get_policy(new_zone)),
%% update zone(zone_1) has default.
?assertEqual(Global#{window_time := 123}, emqx_flapping:get_policy(zone_1)),
?assertEqual(Global#{window_time := 123000}, emqx_flapping:get_policy(zone_1)),
%% create zone(zone_2) has default
?assertEqual(Global#{window_time := 456}, emqx_flapping:get_policy(zone_2)),
?assertEqual(Global#{window_time := 456000}, emqx_flapping:get_policy(zone_2)),
%% reset to default(empty) andalso get default from global
?assertMatch({ok, _}, emqx:update_config([zones], #{})),
?assertEqual(Global, emqx:get_config([zones, default, flapping_detect])),
@ -172,13 +172,13 @@ validate_timer(Lists) ->
ok.
t_window_compatibility_check(_Conf) ->
Flapping = emqx:get_config([flapping_detect]),
Flapping = emqx:get_raw_config([flapping_detect]),
ok = emqx_config:init_load(emqx_schema, <<"flapping_detect {window_time = disable}">>),
?assertMatch(#{window_time := 60000, enable := false}, emqx:get_config([flapping_detect])),
%% reset
FlappingBin = iolist_to_binary(["flapping_detect {", hocon_pp:do(Flapping, #{}), "}"]),
ok = emqx_config:init_load(emqx_schema, FlappingBin),
?assertEqual(Flapping, emqx:get_config([flapping_detect])),
?assertEqual(Flapping, emqx:get_raw_config([flapping_detect])),
ok.
get_policy(Zone) ->

View File

@ -137,8 +137,8 @@ init_per_testcase(t_ocsp_responder_error_responses, Config) ->
enable_ocsp_stapling => true,
responder_url => <<"http://localhost:9877/">>,
issuer_pem => filename:join(DataDir, "ocsp-issuer.pem"),
refresh_http_timeout => 15_000,
refresh_interval => 1_000
refresh_http_timeout => <<"15s">>,
refresh_interval => <<"1s">>
}
}
},
@ -179,8 +179,8 @@ init_per_testcase(_TestCase, Config) ->
enable_ocsp_stapling => true,
responder_url => <<"http://localhost:9877/">>,
issuer_pem => filename:join(DataDir, "ocsp-issuer.pem"),
refresh_http_timeout => 15_000,
refresh_interval => 1_000
refresh_http_timeout => <<"15s">>,
refresh_interval => <<"1s">>
}
}
},

View File

@ -1316,8 +1316,8 @@ authenticator_examples() ->
<<"password">> => ?PH_PASSWORD
},
pool_size => 8,
connect_timeout => 5000,
request_timeout => 5000,
connect_timeout => <<"5s">>,
request_timeout => <<"5s">>,
enable_pipelining => 100,
ssl => #{enable => false}
}

View File

@ -80,7 +80,7 @@ listener_mqtt_tcp_conf(Port, EnableAuthn) ->
<<"max_connections">> => 1024000,
<<"mountpoint">> => <<>>,
<<"proxy_protocol">> => false,
<<"proxy_protocol_timeout">> => 3000,
<<"proxy_protocol_timeout">> => <<"3s">>,
<<"enable_authn">> => EnableAuthn
}.

View File

@ -105,7 +105,7 @@ set_special_configs(_App) ->
<<"headers">> => #{},
<<"ssl">> => #{<<"enable">> => true},
<<"method">> => <<"get">>,
<<"request_timeout">> => 5000
<<"request_timeout">> => <<"5s">>
}).
-define(SOURCE2, #{
<<"type">> => <<"mongodb">>,

View File

@ -70,7 +70,7 @@ t_api(_) ->
<<"cache">> => #{
<<"enable">> => false,
<<"max_size">> => 32,
<<"ttl">> => 60000
<<"ttl">> => <<"60s">>
}
},
@ -84,7 +84,7 @@ t_api(_) ->
<<"cache">> => #{
<<"enable">> => true,
<<"max_size">> => 32,
<<"ttl">> => 60000
<<"ttl">> => <<"60s">>
}
},

View File

@ -179,20 +179,20 @@ bridge_async_config(#{port := Port} = Config) ->
PoolSize = maps:get(pool_size, Config, 1),
QueryMode = maps:get(query_mode, Config, "async"),
ConnectTimeout = maps:get(connect_timeout, Config, 1),
RequestTimeout = maps:get(request_timeout, Config, 10000),
RequestTimeout = maps:get(request_timeout, Config, "10s"),
ResumeInterval = maps:get(resume_interval, Config, "1s"),
ResourceRequestTTL = maps:get(resource_request_ttl, Config, "infinity"),
ConfigString = io_lib:format(
"bridges.~s.~s {\n"
" url = \"http://localhost:~p\"\n"
" connect_timeout = \"~ps\"\n"
" connect_timeout = \"~p\"\n"
" enable = true\n"
" enable_pipelining = 100\n"
" max_retries = 2\n"
" method = \"post\"\n"
" pool_size = ~p\n"
" pool_type = \"random\"\n"
" request_timeout = \"~ps\"\n"
" request_timeout = \"~s\"\n"
" body = \"${id}\""
" resource_opts {\n"
" inflight_window = 100\n"
@ -257,8 +257,8 @@ t_send_async_connection_timeout(Config) ->
port => Port,
pool_size => 1,
query_mode => "async",
connect_timeout => 10_000,
request_timeout => ResponseDelayMS * 2,
connect_timeout => integer_to_list(ResponseDelayMS * 2) ++ "s",
request_timeout => "10s",
resource_request_ttl => "infinity"
}),
NumberOfMessagesToSend = 10,
@ -278,8 +278,8 @@ t_async_free_retries(Config) ->
port => Port,
pool_size => 1,
query_mode => "sync",
connect_timeout => 1_000,
request_timeout => 10_000,
connect_timeout => "1s",
request_timeout => "10s",
resource_request_ttl => "10000s"
}),
%% Fail 5 times then succeed.
@ -304,8 +304,8 @@ t_async_common_retries(Config) ->
pool_size => 1,
query_mode => "sync",
resume_interval => "100ms",
connect_timeout => 1_000,
request_timeout => 10_000,
connect_timeout => "1s",
request_timeout => "10s",
resource_request_ttl => "10000s"
}),
%% Keeps failing until connector gives up.

View File

@ -635,9 +635,9 @@ t_bad_sql_parameter(Config) ->
Config,
#{
<<"resource_opts">> => #{
<<"request_ttl">> => 500,
<<"resume_interval">> => 100,
<<"health_check_interval">> => 100
<<"request_ttl">> => <<"500ms">>,
<<"resume_interval">> => <<"100ms">>,
<<"health_check_interval">> => <<"100ms">>
}
}
)

View File

@ -184,7 +184,7 @@ clickhouse_config() ->
]
)
),
connect_timeout => 10000
connect_timeout => <<"10s">>
},
#{<<"config">> => Config}.

View File

@ -135,8 +135,8 @@ bridge_config(TestCase, _TestGroup, Config) ->
" iotdb_version = \"~s\"\n"
" pool_size = 1\n"
" resource_opts = {\n"
" health_check_interval = 5000\n"
" request_ttl = 30000\n"
" health_check_interval = \"5s\"\n"
" request_ttl = 30s\n"
" query_mode = \"async\"\n"
" worker_pool_size = 1\n"
" }\n"

View File

@ -590,7 +590,7 @@ kafka_config(TestCase, _KafkaType, Config) ->
" kafka {\n"
" max_batch_bytes = 896KB\n"
" max_rejoin_attempts = 5\n"
" offset_commit_interval_seconds = 3\n"
" offset_commit_interval_seconds = 3s\n"
%% todo: matrix this
" offset_reset_policy = latest\n"
" }\n"

View File

@ -307,7 +307,7 @@ bridges.kafka_consumer.my_consumer {
kafka {
max_batch_bytes = 896KB
max_rejoin_attempts = 5
offset_commit_interval_seconds = 3
offset_commit_interval_seconds = 3s
offset_reset_policy = latest
}
topic_mapping = [

View File

@ -298,9 +298,9 @@ t_write_timeout(Config) ->
Config,
#{
<<"resource_opts">> => #{
<<"request_ttl">> => 500,
<<"resume_interval">> => 100,
<<"health_check_interval">> => 100
<<"request_ttl">> => <<"500ms">>,
<<"resume_interval">> => <<"100ms">>,
<<"health_check_interval">> => <<"100ms">>
}
}
),

View File

@ -456,9 +456,9 @@ t_write_timeout(Config) ->
Config,
#{
<<"resource_opts">> => #{
<<"request_ttl">> => 500,
<<"resume_interval">> => 100,
<<"health_check_interval">> => 100
<<"request_ttl">> => <<"500ms">>,
<<"resume_interval">> => <<"100ms">>,
<<"health_check_interval">> => <<"100ms">>
}
}
),

View File

@ -55,7 +55,7 @@ log.console_handler {
burst_limit {
enable = true
max_count = 10000
window_time = 1000
window_time = 1s
}
chars_limit = unlimited
drop_mode_qlen = 3000
@ -66,9 +66,9 @@ log.console_handler {
max_depth = 100
overload_kill {
enable = true
mem_size = 31457280
mem_size = \"30MB\"
qlen = 20000
restart_after = 5000
restart_after = \"5s\"
}
single_line = true
supervisor_reports = error
@ -80,7 +80,7 @@ log.file_handlers {
burst_limit {
enable = true
max_count = 10000
window_time = 1000
window_time = 1s
}
chars_limit = unlimited
drop_mode_qlen = 3000
@ -93,9 +93,9 @@ log.file_handlers {
max_size = \"1024MB\"
overload_kill {
enable = true
mem_size = 31457280
mem_size = \"30MB\"
qlen = 20000
restart_after = 5000
restart_after = \"5s\"
}
rotation {count = 20, enable = true}
single_line = true

View File

@ -35,7 +35,7 @@ t_run_gc(_) ->
node => #{
cookie => <<"cookie">>,
data_dir => <<"data">>,
global_gc_interval => 1000
global_gc_interval => <<"1s">>
}
},
emqx_common_test_helpers:load_config(emqx_conf_schema, Conf0),

View File

@ -225,7 +225,7 @@ t_update_conf(_Config) ->
DeletedConf = Conf#{<<"servers">> => Servers2},
validate_servers(Path, DeletedConf, Servers2),
[L1, L2 | Servers3] = Servers,
UpdateL2 = L2#{<<"pool_size">> => 1, <<"request_timeout">> => 1000},
UpdateL2 = L2#{<<"pool_size">> => 1, <<"request_timeout">> => <<"1s">>},
UpdatedServers = [L1, UpdateL2 | Servers3],
UpdatedConf = Conf#{<<"servers">> => UpdatedServers},
validate_servers(Path, UpdatedConf, UpdatedServers),

View File

@ -67,7 +67,7 @@ init_per_suite(Config) ->
_ = emqx_exhook_demo_svr:start(),
load_cfg(?CONF_DEFAULT),
emqx_mgmt_api_test_util:init_suite([emqx_exhook]),
[Conf] = emqx:get_config([exhook, servers]),
[Conf] = emqx:get_raw_config([exhook, servers]),
[{template, Conf} | Config].
end_per_suite(Config) ->
@ -157,8 +157,8 @@ t_get(_) ->
t_add(Cfg) ->
Template = proplists:get_value(template, Cfg),
Instance = Template#{
name => <<"test1">>,
url => "http://127.0.0.1:9001"
<<"name">> => <<"test1">>,
<<"url">> => "http://127.0.0.1:9001"
},
{ok, Data} = request_api(
post,
@ -186,8 +186,8 @@ t_add(Cfg) ->
t_add_duplicate(Cfg) ->
Template = proplists:get_value(template, Cfg),
Instance = Template#{
name => <<"test1">>,
url => "http://127.0.0.1:9001"
<<"name">> => <<"test1">>,
<<"url">> => "http://127.0.0.1:9001"
},
{error, _Reason} = request_api(
@ -203,8 +203,8 @@ t_add_duplicate(Cfg) ->
t_add_with_bad_name(Cfg) ->
Template = proplists:get_value(template, Cfg),
Instance = Template#{
name => <<"🤔">>,
url => "http://127.0.0.1:9001"
<<"name">> => <<"🤔">>,
<<"url">> => "http://127.0.0.1:9001"
},
{error, _Reason} = request_api(
@ -298,7 +298,7 @@ t_hooks(_Cfg) ->
t_update(Cfg) ->
Template = proplists:get_value(template, Cfg),
Instance = Template#{enable => false},
Instance = Template#{<<"enable">> => false},
{ok, <<"{\"", _/binary>>} = request_api(
put,
api_path(["exhooks", "default"]),

View File

@ -77,7 +77,7 @@ set_special_configs(Config) ->
% complete transfers.
Storage = emqx_utils_maps:deep_merge(
emqx_ft_test_helpers:local_storage(Config),
#{<<"local">> => #{<<"segments">> => #{<<"gc">> => #{<<"interval">> => 0}}}}
#{<<"local">> => #{<<"segments">> => #{<<"gc">> => #{<<"interval">> => <<"0s">>}}}}
),
emqx_ft_test_helpers:load_config(#{
<<"enable">> => true,

View File

@ -1,4 +1,4 @@
%%--------------------------------------------------------------------
%--------------------------------------------------------------------
%% Copyright (c) 2020-2023 EMQ Technologies Co., Ltd. All Rights Reserved.
%%
%% Licensed under the Apache License, Version 2.0 (the "License");
@ -192,7 +192,7 @@ default_config(Overrides) ->
" xml_dir = \"~s\"\n"
" lifetime_min = 1s\n"
" lifetime_max = 86400s\n"
" qmode_time_window = 22\n"
" qmode_time_window = 22s\n"
" auto_observe = ~w\n"
" mountpoint = \"lwm2m/${username}\"\n"
" update_msg_publish_condition = contains_object_list\n"

View File

@ -468,7 +468,7 @@ fields(rebalance_evacuation_start) ->
)},
{"wait_takeover",
mk(
pos_integer(),
emqx_schema:timeout_duration_s(),
#{
desc => ?DESC(wait_takeover),
required => false
@ -709,24 +709,24 @@ fields(global_status) ->
rebalance_example() ->
#{
wait_health_check => 10,
wait_health_check => <<"10s">>,
conn_evict_rate => 10,
sess_evict_rate => 20,
abs_conn_threshold => 10,
rel_conn_threshold => 1.5,
abs_sess_threshold => 10,
rel_sess_threshold => 1.5,
wait_takeover => 10,
wait_takeover => <<"10s">>,
nodes => [<<"othernode@127.0.0.1">>]
}.
rebalance_evacuation_example() ->
#{
wait_health_check => 10,
wait_health_check => <<"10s">>,
conn_evict_rate => 100,
sess_evict_rate => 100,
redirect_to => <<"othernode:1883">>,
wait_takeover => 10,
wait_takeover => <<"10s">>,
migrate_to => [<<"othernode@127.0.0.1">>]
}.

View File

@ -67,7 +67,6 @@ t_start_evacuation_validation(Config) ->
BadOpts = [
#{conn_evict_rate => <<"conn">>},
#{sess_evict_rate => <<"sess">>},
#{redirect_to => 123},
#{wait_takeover => <<"wait">>},
#{wait_health_check => <<"wait">>},
#{migrate_to => []},
@ -83,7 +82,8 @@ t_start_evacuation_validation(Config) ->
api_post(
["load_rebalance", atom_to_list(DonorNode), "evacuation", "start"],
Opts
)
),
Opts
)
end,
BadOpts
@ -103,8 +103,8 @@ t_start_evacuation_validation(Config) ->
#{
conn_evict_rate => 10,
sess_evict_rate => 10,
wait_takeover => 10,
wait_health_check => 10,
wait_takeover => <<"10s">>,
wait_health_check => <<"10s">>,
redirect_to => <<"srv">>,
migrate_to => [atom_to_binary(RecipientNode)]
}
@ -166,8 +166,8 @@ t_start_rebalance_validation(Config) ->
#{
conn_evict_rate => 10,
sess_evict_rate => 10,
wait_takeover => 10,
wait_health_check => 10,
wait_takeover => <<"10s">>,
wait_health_check => <<"10s">>,
abs_conn_threshold => 10,
rel_conn_threshold => 1.001,
abs_sess_threshold => 10,

View File

@ -483,26 +483,25 @@ t_clear_expired(_) ->
with_conf(ConfMod, Case).
t_max_payload_size(_) ->
ConfMod = fun(Conf) -> Conf#{<<"max_payload_size">> := 6} end,
ConfMod = fun(Conf) -> Conf#{<<"max_payload_size">> := <<"1kb">>} end,
Case = fun() ->
emqx_retainer:clean(),
timer:sleep(500),
{ok, C1} = emqtt:start_link([{clean_start, true}, {proto_ver, v5}]),
{ok, _} = emqtt:connect(C1),
Payload = iolist_to_binary(lists:duplicate(1024, <<"0">>)),
emqtt:publish(
C1,
<<"retained/1">>,
#{},
<<"1234">>,
Payload,
[{qos, 0}, {retain, true}]
),
emqtt:publish(
C1,
<<"retained/2">>,
#{},
<<"1234567">>,
<<"1", Payload/binary>>,
[{qos, 0}, {retain, true}]
),

View File

@ -84,7 +84,7 @@ t_full_config(_Config) ->
<<"min_part_size">> => <<"10mb">>,
<<"acl">> => <<"public_read">>,
<<"transport_options">> => #{
<<"connect_timeout">> => 30000,
<<"connect_timeout">> => <<"30s">>,
<<"enable_pipelining">> => 200,
<<"pool_size">> => 10,
<<"pool_type">> => <<"random">>,

View File

@ -64,10 +64,10 @@ base_raw_config(tcp) ->
<<"secret_access_key">> => bin(?SECRET_ACCESS_KEY),
<<"host">> => ?TCP_HOST,
<<"port">> => ?TCP_PORT,
<<"max_part_size">> => 10 * 1024 * 1024,
<<"max_part_size">> => <<"10MB">>,
<<"transport_options">> =>
#{
<<"request_timeout">> => 2000
<<"request_timeout">> => <<"2s">>
}
};
base_raw_config(tls) ->
@ -77,10 +77,10 @@ base_raw_config(tls) ->
<<"secret_access_key">> => bin(?SECRET_ACCESS_KEY),
<<"host">> => ?TLS_HOST,
<<"port">> => ?TLS_PORT,
<<"max_part_size">> => 10 * 1024 * 1024,
<<"max_part_size">> => <<"10MB">>,
<<"transport_options">> =>
#{
<<"request_timeout">> => 2000,
<<"request_timeout">> => <<"2s">>,
<<"ssl">> => #{
<<"enable">> => true,
<<"cacertfile">> => bin(cert_path("ca.crt")),

View File

@ -139,7 +139,7 @@ settings(get, _) ->
{200, emqx:get_raw_config([slow_subs], #{})};
settings(put, #{body := Body}) ->
case emqx_slow_subs:update_settings(Body) of
{ok, #{config := NewConf}} ->
{ok, #{raw_config := NewConf}} ->
{200, NewConf};
{error, Reason} ->
Message = list_to_binary(io_lib:format("Update slow subs config failed ~p", [Reason])),

View File

@ -41,7 +41,7 @@
"{\n"
" enable = true\n"
" top_k_num = 5,\n"
" expire_interval = 60000\n"
" expire_interval = 60s\n"
" stats_type = whole\n"
"}"
""
@ -137,36 +137,33 @@ t_clear(_) ->
?assertEqual(0, ets:info(?TOPK_TAB, size)).
t_settting(_) ->
Conf = emqx:get_config([slow_subs]),
Conf2 = Conf#{stats_type => internal},
RawConf = emqx:get_raw_config([slow_subs]),
RawConf2 = RawConf#{<<"stats_type">> => <<"internal">>},
{ok, Data} = request_api(
put,
api_path(["slow_subscriptions", "settings"]),
[],
auth_header_(),
Conf2
RawConf2
),
Return = decode_json(Data),
Expect = emqx_config:fill_defaults(RawConf2),
?assertEqual(Conf2#{stats_type := <<"internal">>}, Return),
?assertEqual(Expect, Return),
timer:sleep(800),
{ok, GetData} = request_api(
get,
api_path(["slow_subscriptions", "settings"]),
[],
auth_header_()
),
timer:sleep(1000),
GetReturn = decode_json(GetData),
?assertEqual(Conf2#{stats_type := <<"internal">>}, GetReturn).
?assertEqual(Expect, GetReturn).
decode_json(Data) ->
BinJosn = emqx_utils_json:decode(Data, [return_maps]),
emqx_utils_maps:unsafe_atom_key_map(BinJosn).
emqx_utils_json:decode(Data, [return_maps]).
request_api(Method, Url, Auth) ->
request_api(Method, Url, [], Auth, []).