Skip to content

Commit

Permalink
ddl: tiny update
Browse files Browse the repository at this point in the history
  • Loading branch information
zimulala committed Feb 10, 2023
1 parent 06d01f4 commit 9f9022e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion ddl/ddl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,10 @@ const testLease = 5 * time.Millisecond
type DDLForTest interface {
// SetInterceptor sets the interceptor.
SetInterceptor(h Interceptor)
NewReorgCtx(jobID int64, startKey []byte, currElement *meta.Element, rowCount int64) *reorgCtx
SetReorgCtxForBackfill(bfJob *BackfillJob)
GetReorgCtx(jobID int64) *reorgCtx
RemoveReorgCtx(id int64)
NewReorgCtx(jobID int64, startKey []byte, currElement *meta.Element, rowCount int64) *reorgCtx
}

// SetInterceptor implements DDL.SetInterceptor interface.
Expand All @@ -56,6 +57,11 @@ func (d *ddl) SetInterceptor(i Interceptor) {
d.mu.interceptor = i
}

// IsReorgCanceled exports for testing.
func (rc *reorgCtx) IsReorgCanceled() bool {
return rc.isReorgCanceled()
}

// NewReorgCtx exports for testing.
func (d *ddl) NewReorgCtx(jobID int64, startKey []byte, currElement *meta.Element, rowCount int64) *reorgCtx {
return d.newReorgCtx(jobID, startKey, currElement, rowCount)
Expand All @@ -66,6 +72,11 @@ func (d *ddl) SetReorgCtxForBackfill(bfJob *BackfillJob) {
d.setReorgCtxForBackfill(bfJob)
}

// GetReorgCtx exports for testing.
func (d *ddl) GetReorgCtx(jobID int64) *reorgCtx {
return d.getReorgCtx(jobID)
}

// RemoveReorgCtx exports for testing.
func (d *ddl) RemoveReorgCtx(id int64) {
d.removeReorgCtx(id)
Expand Down
2 changes: 2 additions & 0 deletions ddl/ddl_worker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ func TestUsingReorgCtx(t *testing.T) {
bfJob := &ddl.BackfillJob{JobID: jobID, EleID: 1, EleKey: nil}
for i := 0; i < 100; i++ {
d.(ddl.DDLForTest).SetReorgCtxForBackfill(bfJob)
d.(ddl.DDLForTest).GetReorgCtx(jobID).IsReorgCanceled()
d.(ddl.DDLForTest).RemoveReorgCtx(jobID)
}
})
Expand All @@ -330,6 +331,7 @@ func TestUsingReorgCtx(t *testing.T) {
ele := &meta.Element{ID: 1, TypeKey: nil}
for i := 0; i < 100; i++ {
d.(ddl.DDLForTest).NewReorgCtx(jobID, startKey, ele, 0)
d.(ddl.DDLForTest).GetReorgCtx(jobID).IsReorgCanceled()
d.(ddl.DDLForTest).RemoveReorgCtx(jobID)
}
})
Expand Down

0 comments on commit 9f9022e

Please sign in to comment.