@@ -23,12 +23,14 @@ import (
23
23
"testing"
24
24
"time"
25
25
26
+ "github.com/pingcap/failpoint"
26
27
"github.com/pingcap/tidb/pkg/domain"
27
28
"github.com/pingcap/tidb/pkg/infoschema"
28
29
"github.com/pingcap/tidb/pkg/kv"
29
30
"github.com/pingcap/tidb/pkg/owner"
30
31
"github.com/pingcap/tidb/pkg/parser/model"
31
32
"github.com/pingcap/tidb/pkg/sessionctx"
33
+ "github.com/pingcap/tidb/pkg/sessionctx/variable"
32
34
"github.com/pingcap/tidb/pkg/testkit"
33
35
"github.com/stretchr/testify/require"
34
36
clientv3 "go.etcd.io/etcd/client/v3"
@@ -504,18 +506,16 @@ func TestSettingSQLVariables(t *testing.T) {
504
506
eventuallyWithLock (t , wrk , func () bool { return int32 (7200 ) == wrk .snapshotInterval })
505
507
eventuallyWithLock (t , wrk , func () bool { return int32 (365 ) == wrk .retentionDays })
506
508
507
- // Test invalid value for sampling interval
508
- err := tk .ExecToErr ("set @@global." + repositorySamplingInterval + " = 'invalid'" )
509
- require . Error ( t , err )
510
- require . Contains ( t , err . Error (), "Incorrect argument type" )
509
+ // Test invalid values for intervals
510
+ tk .MustGetDBError ("set @@global." + repositorySamplingInterval + " = 'invalid'" , variable . ErrWrongTypeForVar )
511
+ tk . MustGetDBError ( "set @@global." + repositorySnapshotInterval + " = 'invalid'" , variable . ErrWrongTypeForVar )
512
+ tk . MustGetDBError ( "set @@global." + repositoryRetentionDays + " = 'invalid'" , variable . ErrWrongTypeForVar )
511
513
512
- err = tk .ExecToErr ("set @@global." + repositorySnapshotInterval + " = 'invalid'" )
513
- require .Error (t , err )
514
- require .Contains (t , err .Error (), "Incorrect argument type" )
515
-
516
- err = tk .ExecToErr ("set @@global." + repositoryRetentionDays + " = 'invalid'" )
517
- require .Error (t , err )
518
- require .Contains (t , err .Error (), "Incorrect argument type" )
514
+ // Test that if the strconv.Atoi call fails that the error is correctly handled.
515
+ require .NoError (t , failpoint .Enable ("github.com/pingcap/tidb/pkg/util/workloadrepo/FastRunawayGC" , `return(true)` ))
516
+ tk .MustGetDBError ("set @@global." + repositorySamplingInterval + " = 10" , errWrongValueForVar )
517
+ tk .MustGetDBError ("set @@global." + repositorySnapshotInterval + " = 901" , errWrongValueForVar )
518
+ require .NoError (t , failpoint .Disable ("github.com/pingcap/tidb/pkg/util/workloadrepo/FastRunawayGC" ))
519
519
520
520
trueWithLock (t , wrk , func () bool { return int32 (600 ) == wrk .samplingInterval })
521
521
trueWithLock (t , wrk , func () bool { return int32 (7200 ) == wrk .snapshotInterval })
@@ -530,9 +530,7 @@ func TestSettingSQLVariables(t *testing.T) {
530
530
eventuallyWithLock (t , wrk , func () bool { return ! wrk .enabled })
531
531
532
532
// Test invalid value for repository destination
533
- err = tk .ExecToErr ("set @@global." + repositoryDest + " = 'invalid'" )
534
- require .Error (t , err )
535
- require .Contains (t , err .Error (), "invalid repository destination" )
533
+ tk .MustGetDBError ("set @@global." + repositoryDest + " = 'invalid'" , errWrongValueForVar )
536
534
}
537
535
538
536
func getTable (t * testing.T , tableName string , wrk * worker ) * repositoryTable {
0 commit comments