Skip to content

Commit

Permalink
statistics: fix the test case by increase the time interval (#51139)
Browse files Browse the repository at this point in the history
close #51142
  • Loading branch information
Rustin170506 authored Feb 19, 2024
1 parent 1f03420 commit d96244d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/statistics/handle/autoanalyze/priorityqueue/job_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,11 +259,11 @@ func TestIsValidToAnalyze(t *testing.T) {
// Just failed.
now := tk.MustQuery("select now()").Rows()[0][0].(string)
insertFailedJobWithStartTime(tk, job.TableSchema, job.TableName, "", now)
valid, failReason = job.IsValidToAnalyze(sctx)
// Note: The failure reason is not checked in this test because the time duration can sometimes be inaccurate.(not now)
valid, _ = job.IsValidToAnalyze(sctx)
require.False(t, valid)
require.Equal(t, "last analysis just failed", failReason)
// Failed 1 second ago.
startTime := tk.MustQuery("select now() - interval 1 second").Rows()[0][0].(string)
// Failed 10 seconds ago.
startTime := tk.MustQuery("select now() - interval 10 second").Rows()[0][0].(string)
insertFailedJobWithStartTime(tk, job.TableSchema, job.TableName, "", startTime)
valid, failReason = job.IsValidToAnalyze(sctx)
require.False(t, valid)
Expand Down Expand Up @@ -330,11 +330,11 @@ func TestIsValidToAnalyzeForPartitionedTba(t *testing.T) {
// Just failed.
now := tk.MustQuery("select now()").Rows()[0][0].(string)
insertFailedJobWithStartTime(tk, job.TableSchema, job.TableName, "p0", now)
valid, failReason = job.IsValidToAnalyze(sctx)
// Note: The failure reason is not checked in this test because the time duration can sometimes be inaccurate.(not now)
valid, _ = job.IsValidToAnalyze(sctx)
require.False(t, valid)
require.Equal(t, "last analysis just failed", failReason)
// Failed 1 second ago.
startTime := tk.MustQuery("select now() - interval 1 second").Rows()[0][0].(string)
// Failed 10 seconds ago.
startTime := tk.MustQuery("select now() - interval 10 second").Rows()[0][0].(string)
insertFailedJobWithStartTime(tk, job.TableSchema, job.TableName, "p0", startTime)
valid, failReason = job.IsValidToAnalyze(sctx)
require.False(t, valid)
Expand Down

0 comments on commit d96244d

Please sign in to comment.