github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ccl/changefeedccl/nemeses_test.go (about) 1 // Copyright 2019 The Cockroach Authors. 2 // 3 // Licensed as a CockroachDB Enterprise file under the Cockroach Community 4 // License (the "License"); you may not use this file except in compliance with 5 // the License. You may obtain a copy of the License at 6 // 7 // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt 8 9 package changefeedccl 10 11 import ( 12 gosql "database/sql" 13 "math" 14 "regexp" 15 "strings" 16 "testing" 17 "time" 18 19 "github.com/cockroachdb/cockroach/pkg/ccl/changefeedccl/cdctest" 20 "github.com/cockroachdb/cockroach/pkg/jobs" 21 "github.com/cockroachdb/cockroach/pkg/util/leaktest" 22 "github.com/cockroachdb/cockroach/pkg/util/log" 23 ) 24 25 func TestChangefeedNemeses(t *testing.T) { 26 defer leaktest.AfterTest(t)() 27 defer func(i time.Duration) { jobs.DefaultAdoptInterval = i }(jobs.DefaultAdoptInterval) 28 jobs.DefaultAdoptInterval = 10 * time.Millisecond 29 scope := log.Scope(t) 30 defer scope.Close(t) 31 32 testFn := func(t *testing.T, db *gosql.DB, f cdctest.TestFeedFactory) { 33 // TODO(dan): Ugly hack to disable `eventPause` in sinkless feeds. See comment in 34 // `RunNemesis` for details. 35 isSinkless := strings.Contains(t.Name(), "sinkless") 36 v, err := cdctest.RunNemesis(f, db, isSinkless) 37 if err != nil { 38 t.Fatalf("%+v", err) 39 } 40 for _, failure := range v.Failures() { 41 t.Error(failure) 42 } 43 } 44 t.Run(`sinkless`, sinklessTest(testFn)) 45 t.Run(`enterprise`, enterpriseTest(testFn)) 46 t.Run(`cloudstorage`, cloudStorageTest(testFn)) 47 log.Flush() 48 entries, err := log.FetchEntriesFromFiles(0, math.MaxInt64, 1, regexp.MustCompile("cdc ux violation")) 49 if err != nil { 50 t.Fatal(err) 51 } 52 if len(entries) > 0 { 53 t.Fatalf("Found violation of CDC's guarantees: %v", entries) 54 } 55 }