(t *testing.T)
| 240 | } |
| 241 | |
| 242 | func 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 | |
| 287 | func TestMaxExecutionTime(t *testing.T) { |
| 288 | store := testkit.CreateMockStore(t) |
nothing calls this directly
no test coverage detected