test(session): fix test cases
This commit is contained in:
parent
b782d4c53a
commit
26ba1b630c
|
@ -169,18 +169,16 @@ init(Opts) ->
|
||||||
MaxInflight = maps:get(max_inflight, Opts, 1),
|
MaxInflight = maps:get(max_inflight, Opts, 1),
|
||||||
QueueOpts = maps:merge(
|
QueueOpts = maps:merge(
|
||||||
#{max_len => 1000,
|
#{max_len => 1000,
|
||||||
store_qos0 => false,
|
store_qos0 => true
|
||||||
priorities => none,
|
|
||||||
default_priority => lowest
|
|
||||||
}, maps:get(mqueue, Opts, #{})),
|
}, maps:get(mqueue, Opts, #{})),
|
||||||
#session{
|
#session{
|
||||||
max_subscriptions = maps:get(max_subscriptions, Opts, 0),
|
max_subscriptions = maps:get(max_subscriptions, Opts, infinity),
|
||||||
subscriptions = #{},
|
subscriptions = #{},
|
||||||
upgrade_qos = maps:get(upgrade_qos, Opts, false),
|
upgrade_qos = maps:get(upgrade_qos, Opts, false),
|
||||||
inflight = emqx_inflight:new(MaxInflight),
|
inflight = emqx_inflight:new(MaxInflight),
|
||||||
mqueue = emqx_mqueue:init(QueueOpts),
|
mqueue = emqx_mqueue:init(QueueOpts),
|
||||||
next_pkt_id = 1,
|
next_pkt_id = 1,
|
||||||
retry_interval = timer:seconds(maps:get(retry_interval, Opts, 0)),
|
retry_interval = timer:seconds(maps:get(retry_interval, Opts, 30)),
|
||||||
awaiting_rel = #{},
|
awaiting_rel = #{},
|
||||||
max_awaiting_rel = maps:get(max_awaiting_rel, Opts, 100),
|
max_awaiting_rel = maps:get(max_awaiting_rel, Opts, 100),
|
||||||
await_rel_timeout = timer:seconds(maps:get(await_rel_timeout, Opts, 300)),
|
await_rel_timeout = timer:seconds(maps:get(await_rel_timeout, Opts, 300)),
|
||||||
|
|
|
@ -983,8 +983,7 @@ session(InitFields) when is_map(InitFields) ->
|
||||||
maps:fold(fun(Field, Value, Session) ->
|
maps:fold(fun(Field, Value, Session) ->
|
||||||
emqx_session:set_field(Field, Value, Session)
|
emqx_session:set_field(Field, Value, Session)
|
||||||
end,
|
end,
|
||||||
emqx_session:init(#{zone => default, listener => mqtt_tcp},
|
emqx_session:init(#{max_inflight => 0}),
|
||||||
#{receive_maximum => 0}),
|
|
||||||
InitFields).
|
InitFields).
|
||||||
|
|
||||||
%% conn: 5/s; overall: 10/s
|
%% conn: 5/s; overall: 10/s
|
||||||
|
|
|
@ -509,9 +509,7 @@ channel(InitFields) ->
|
||||||
peercert => undefined,
|
peercert => undefined,
|
||||||
mountpoint => undefined
|
mountpoint => undefined
|
||||||
},
|
},
|
||||||
Session = emqx_session:init(#{zone => default, listener => mqtt_tcp},
|
Session = emqx_session:init(#{max_inflight => 0}),
|
||||||
#{receive_maximum => 0}
|
|
||||||
),
|
|
||||||
maps:fold(fun(Field, Value, Channel) ->
|
maps:fold(fun(Field, Value, Channel) ->
|
||||||
emqx_channel:set_field(Field, Value, Channel)
|
emqx_channel:set_field(Field, Value, Channel)
|
||||||
end,
|
end,
|
||||||
|
|
|
@ -51,8 +51,7 @@ end_per_testcase(_TestCase, Config) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
t_session_init(_) ->
|
t_session_init(_) ->
|
||||||
Session = emqx_session:init(#{zone => default, listener => mqtt_tcp},
|
Session = emqx_session:init(#{max_inflight => 64}),
|
||||||
#{receive_maximum => 64}),
|
|
||||||
?assertEqual(#{}, emqx_session:info(subscriptions, Session)),
|
?assertEqual(#{}, emqx_session:info(subscriptions, Session)),
|
||||||
?assertEqual(0, emqx_session:info(subscriptions_cnt, Session)),
|
?assertEqual(0, emqx_session:info(subscriptions_cnt, Session)),
|
||||||
?assertEqual(infinity, emqx_session:info(subscriptions_max, Session)),
|
?assertEqual(infinity, emqx_session:info(subscriptions_max, Session)),
|
||||||
|
@ -377,8 +376,7 @@ session(InitFields) when is_map(InitFields) ->
|
||||||
maps:fold(fun(Field, Value, Session) ->
|
maps:fold(fun(Field, Value, Session) ->
|
||||||
emqx_session:set_field(Field, Value, Session)
|
emqx_session:set_field(Field, Value, Session)
|
||||||
end,
|
end,
|
||||||
emqx_session:init(#{zone => default, listener => mqtt_tcp},
|
emqx_session:init(#{max_inflight => 0}),
|
||||||
#{receive_maximum => 0}),
|
|
||||||
InitFields).
|
InitFields).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -468,9 +468,7 @@ channel(InitFields) ->
|
||||||
peercert => undefined,
|
peercert => undefined,
|
||||||
mountpoint => undefined
|
mountpoint => undefined
|
||||||
},
|
},
|
||||||
Session = emqx_session:init(#{zone => default, listener => mqtt_ws},
|
Session = emqx_session:init(#{max_inflight => 0}),
|
||||||
#{receive_maximum => 0}
|
|
||||||
),
|
|
||||||
maps:fold(fun(Field, Value, Channel) ->
|
maps:fold(fun(Field, Value, Channel) ->
|
||||||
emqx_channel:set_field(Field, Value, Channel)
|
emqx_channel:set_field(Field, Value, Channel)
|
||||||
end,
|
end,
|
||||||
|
|
Loading…
Reference in New Issue