MCPcopy
hub / github.com/pingcap/tidb / TestSetEnableRateLimitAction

Function TestSetEnableRateLimitAction

pkg/session/test/variable/variable_test.go:242–285  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

240}
241
242func TestSetEnableRateLimitAction(t *testing.T) {
243 store := testkit.CreateMockStore(t)
244
245 tk := testkit.NewTestKit(t, store)
246 tk.MustExec("use test")
247
248 tk.MustExec("set @@tidb_enable_rate_limit_action=true")
249 // assert default value
250 result := tk.MustQuery("select @@tidb_enable_rate_limit_action;")
251 result.Check(testkit.Rows("1"))
252 tk.MustExec("use test")
253 tk.MustExec("create table tmp123(id int)")
254 rs, err := tk.Exec("select * from tmp123;")
255 require.NoError(t, err)
256 haveRateLimitAction := false
257 action := tk.Session().GetSessionVars().MemTracker.GetFallbackForTest(false)
258 for ; action != nil; action = action.GetFallback() {
259 if action.GetPriority() == memory.DefRateLimitPriority {
260 haveRateLimitAction = true
261 break
262 }
263 }
264 require.True(t, haveRateLimitAction)
265 err = rs.Close()
266 require.NoError(t, err)
267
268 // assert set sys variable
269 tk.MustExec("set global tidb_enable_rate_limit_action= '0';")
270 tk.Session().Close()
271
272 tk.RefreshSession()
273 result = tk.MustQuery("select @@tidb_enable_rate_limit_action;")
274 result.Check(testkit.Rows("0"))
275
276 haveRateLimitAction = false
277 action = tk.Session().GetSessionVars().MemTracker.GetFallbackForTest(false)
278 for ; action != nil; action = action.GetFallback() {
279 if action.GetPriority() == memory.DefRateLimitPriority {
280 haveRateLimitAction = true
281 break
282 }
283 }
284 require.False(t, haveRateLimitAction)
285}
286
287func TestMaxExecutionTime(t *testing.T) {
288 store := testkit.CreateMockStore(t)

Callers

nothing calls this directly

Calls 14

MustExecMethod · 0.95
MustQueryMethod · 0.95
ExecMethod · 0.95
SessionMethod · 0.95
RefreshSessionMethod · 0.95
CreateMockStoreFunction · 0.92
NewTestKitFunction · 0.92
RowsFunction · 0.92
GetFallbackForTestMethod · 0.80
CheckMethod · 0.65
GetSessionVarsMethod · 0.65
GetFallbackMethod · 0.65

Tested by

no test coverage detected