Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

importccl: re-enable job control tests #31556

Merged
merged 1 commit into from
Oct 22, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions pkg/ccl/importccl/import_stmt_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"path/filepath"
"runtime"
"strings"
"sync"
"testing"
"time"

Expand Down Expand Up @@ -1498,7 +1499,6 @@ func BenchmarkConvertRecord(b *testing.B) {
// work as intended on import jobs.
func TestImportControlJob(t *testing.T) {
defer leaktest.AfterTest(t)()
t.Skipf("#24658")

defer func(oldInterval time.Duration) {
jobs.DefaultAdoptInterval = oldInterval
Expand Down Expand Up @@ -1527,15 +1527,33 @@ func TestImportControlJob(t *testing.T) {
sqlDB := sqlutils.MakeSQLRunner(tc.Conns[0])
sqlDB.Exec(t, `CREATE DATABASE data`)

t.Run("cancel", func(t *testing.T) {
sqlDB.Exec(t, `CREATE DATABASE cancelimport`)

srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
makeSrv := func() *httptest.Server {
var once sync.Once
return httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
<-allowResponse
// The following code correctly handles both the case where, after the
// CANCEL JOB is issued, the second stage of the IMPORT (the shuffle,
// after the sampling) may or may not be started. If it was started, then a
// second GET request is done. The once here will cause that request to not
// block. The draining for loop below will cause jobutils.RunJob's second send
// on allowResponse to succeed (which it does after issuing the CANCEL JOB).
once.Do(func() {
<-allowResponse
go func() {
for range allowResponse {
}
}()
})

_, _ = w.Write([]byte(r.URL.Path[1:]))
}
}))
}

t.Run("cancel", func(t *testing.T) {
sqlDB.Exec(t, `CREATE DATABASE cancelimport`)

srv := makeSrv()
defer srv.Close()

var urls []string
Expand Down Expand Up @@ -1567,11 +1585,7 @@ func TestImportControlJob(t *testing.T) {

sqlDB.Exec(t, `CREATE DATABASE pauseimport`)

srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
_, _ = w.Write([]byte(r.URL.Path[1:]))
}
}))
srv := makeSrv()
defer srv.Close()

count := 100
Expand Down