-
Notifications
You must be signed in to change notification settings - Fork 3.8k
/
Copy pathscrub.go
81 lines (73 loc) · 2.2 KB
/
scrub.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// Copyright 2018 The Cockroach Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
// implied. See the License for the specific language governing
// permissions and limitations under the License. See the AUTHORS file
// for names of contributors.
package main
import (
"context"
"fmt"
"time"
)
var tpccTables = [...]string{
"customer",
"district",
"history",
"item",
"new_order",
"order",
"order_line",
"stock",
"warehouse",
}
func registerScrubIndexOnlyTPCC(r *registry) {
// TODO (lucy): increase numScrubRuns once we improve SCRUB performance
r.Add(makeScrubTPCCTest(5, 1000, time.Hour*3, true, 2))
}
func registerScrubAllChecksTPCC(r *registry) {
// TODO (lucy): increase numScrubRuns once we improve SCRUB performance
r.Add(makeScrubTPCCTest(5, 1000, time.Hour*3, false, 1))
}
func makeScrubTPCCTest(
numNodes, warehouses int, length time.Duration, indexOnly bool, numScrubRuns int,
) testSpec {
var optionName string
if indexOnly {
optionName = "index-only"
} else {
optionName = "all-checks"
}
stmts := make([]string, numScrubRuns*len(tpccTables))
for i := 0; i < len(stmts); i += len(tpccTables) {
for j, t := range tpccTables {
if indexOnly {
stmts[i+j] = fmt.Sprintf(`EXPERIMENTAL SCRUB TABLE tpcc.%s AS OF SYSTEM TIME '-0s' WITH OPTIONS INDEX ALL`, t)
} else {
stmts[i+j] = fmt.Sprintf(`EXPERIMENTAL SCRUB TABLE tpcc.%s AS OF SYSTEM TIME '-0s'`, t)
}
}
}
return testSpec{
Name: fmt.Sprintf("scrub/%s/tpcc-%d", optionName, warehouses),
Nodes: nodes(numNodes),
Run: func(ctx context.Context, t *test, c *cluster) {
runTPCC(ctx, t, c, tpccOptions{
Warehouses: warehouses,
Extra: "--wait=false --tolerate-errors",
During: func(ctx context.Context) error {
return runAndLogStmts(ctx, t, c, "scrub", stmts)
},
Duration: length,
})
},
}
}