Skip to content

Commit

Permalink
admission,roachtest: re-home row-level ttl test
Browse files Browse the repository at this point in the history
Rename + own as an AC integration test, similar to ones we have for
backup/changefeeds/etc. We'll integrate row-level TTL reads in the
subsequent commit

Part of cockroachdb#89208.

Release note: None
  • Loading branch information
irfansharif committed Aug 15, 2023
1 parent a598a75 commit e2bf64f
Show file tree
Hide file tree
Showing 7 changed files with 114 additions and 86 deletions.
2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ go_library(
"admission_control_index_overload.go",
"admission_control_multi_store_overload.go",
"admission_control_multitenant_fairness.go",
"admission_control_row_level_ttl.go",
"admission_control_snapshot_overload.go",
"admission_control_tpcc_overload.go",
"allocation_bench.go",
Expand Down Expand Up @@ -139,7 +140,6 @@ go_library(
"restore.go",
"roachmart.go",
"roachtest.go",
"row_level_ttl.go",
"ruby_pg.go",
"ruby_pg_blocklist.go",
"rust_postgres.go",
Expand Down
1 change: 1 addition & 0 deletions pkg/cmd/roachtest/tests/admission_control.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ func registerAdmission(r registry.Registry) {

registerElasticControlForBackups(r)
registerElasticControlForCDC(r)
registerElasticControlForRowLevelTTL(r)
registerMultiStoreOverload(r)
registerMultiTenantFairness(r)
registerSnapshotOverload(r)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/roachtest/tests/admission_control_elastic_backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ func registerElasticControlForBackups(r registry.Registry) {
)

if t.SkipInit() {
t.Status(fmt.Sprintf("running tpcc for %s (<%s)", workloadDuration, time.Minute))
t.Status(fmt.Sprintf("running tpcc for %s (<%s)", workloadDuration, estimatedSetupTime))
} else {
t.Status(fmt.Sprintf("initializing + running tpcc for %s (<%s)", workloadDuration, 10*time.Minute))
t.Status(fmt.Sprintf("initializing + running tpcc for %s (<%s)", workloadDuration, estimatedSetupTime))
}

runTPCC(ctx, t, c, tpccOptions{
Expand Down
109 changes: 109 additions & 0 deletions pkg/cmd/roachtest/tests/admission_control_row_level_ttl.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
// Copyright 2023 The Cockroach Authors.
//
// Use of this software is governed by the Business Source License
// included in the file licenses/BSL.txt.
//
// As of the Change Date specified in that file, in accordance with
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0, included in the file
// licenses/APL.txt.

package tests

import (
"context"
"fmt"
"time"

"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/spec"
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/test"
"github.com/cockroachdb/cockroach/pkg/roachprod/prometheus"
"github.com/cockroachdb/cockroach/pkg/util/timeutil"
)

func registerElasticControlForRowLevelTTL(r registry.Registry) {
const nodes = 7
var clusterSpec = spec.CPU(4)
r.Add(makeElasticControlRowLevelTTL(r.MakeClusterSpec(nodes, clusterSpec), false /* expiredRows */))
r.Add(makeElasticControlRowLevelTTL(r.MakeClusterSpec(nodes, clusterSpec), true /* expiredRows */))
}

func makeElasticControlRowLevelTTL(spec spec.ClusterSpec, expiredRows bool) registry.TestSpec {
return registry.TestSpec{
Name: fmt.Sprintf("admission-control/row-level-ttl/expired-rows=%t", expiredRows),
Owner: registry.OwnerAdmissionControl,
Benchmark: true,
Tags: registry.Tags(`weekly`),
Cluster: spec,
Leases: registry.MetamorphicLeases,
Run: func(ctx context.Context, t test.Test, c cluster.Cluster) {
crdbNodes := c.Spec().NodeCount - 1
workloadNode := crdbNodes + 1

numWarehouses, activeWarehouses, workloadDuration, estimatedSetupTime := 1500, 100, 20*time.Minute, 20*time.Minute
if c.IsLocal() {
numWarehouses, activeWarehouses, workloadDuration, estimatedSetupTime = 1, 1, 3*time.Minute, 2*time.Minute
}

promCfg := &prometheus.Config{}
promCfg.WithPrometheusNode(c.Node(workloadNode).InstallNodes()[0]).
WithNodeExporter(c.Range(1, c.Spec().NodeCount-1).InstallNodes()).
WithCluster(c.Range(1, c.Spec().NodeCount-1).InstallNodes()).
WithGrafanaDashboard("https://go.crdb.dev/p/index-admission-control-grafana").
WithScrapeConfigs(
prometheus.MakeWorkloadScrapeConfig("workload", "/",
makeWorkloadScrapeNodes(
c.Node(workloadNode).InstallNodes()[0],
[]workloadInstance{{nodes: c.Node(workloadNode)}},
),
),
)

if t.SkipInit() {
t.Status(fmt.Sprintf("running tpcc for %s (<%s)", workloadDuration, estimatedSetupTime))
} else {
t.Status(fmt.Sprintf("initializing + running tpcc for %s (<%s)", workloadDuration, estimatedSetupTime))
}

runTPCC(ctx, t, c, tpccOptions{
Warehouses: numWarehouses,
Duration: workloadDuration,
SetupType: usingImport,
EstimatedSetupTime: estimatedSetupTime,
// The expired-rows test will delete rows from the order_line table, so
// the post run checks are expected to fail.
SkipPostRunCheck: expiredRows,
PrometheusConfig: promCfg,
// We limit the number of workers because the default results in a lot
// of connections which can lead to OOM issues (see #40566).
ExtraRunArgs: fmt.Sprintf("--wait=false --tolerate-errors --max-rate=100 --active-warehouses=%d --workers=%d", activeWarehouses, numWarehouses),
DisableDefaultScheduledBackup: true,
During: func(ctx context.Context) error {
cronOffset := 10
if c.IsLocal() {
cronOffset = 1
}
nowMinute := timeutil.Now().Minute()
scheduledMinute := (nowMinute + cronOffset) % 60 // schedule the TTL cron job to kick off a few minutes after test start

var expirationExpr string
if expiredRows {
expirationExpr = `'((ol_delivery_d::TIMESTAMP) + INTERVAL ''1 days'') AT TIME ZONE ''UTC'''`
} else {
// The TPCC fixtures have dates from 2006 for the ol_delivery_d column.
expirationExpr = `'((ol_delivery_d::TIMESTAMP) + INTERVAL ''1000 years'') AT TIME ZONE ''UTC'''`
}

ttlStatement := fmt.Sprintf(`
ALTER TABLE tpcc.public.order_line SET (
ttl_expiration_expression=%s,
ttl_job_cron='%d * * * *'
);`, expirationExpr, scheduledMinute)
return runAndLogStmts(ctx, t, c, "enable-ttl", []string{ttlStatement})
},
})
},
}
}
1 change: 0 additions & 1 deletion pkg/cmd/roachtest/tests/registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ func RegisterTests(r registry.Registry) {
registerRestoreNodeShutdown(r)
registerRoachmart(r)
registerRoachtest(r)
registerRowLevelTTLDuringTPCC(r)
registerRubyPG(r)
registerRustPostgres(r)
registerSQLAlchemy(r)
Expand Down
81 changes: 0 additions & 81 deletions pkg/cmd/roachtest/tests/row_level_ttl.go

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/cmd/roachtest/tests/tpcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ func runTPCC(ctx context.Context, t test.Test, c cluster.Cluster, opts tpccOptio

var ep *tpccChaosEventProcessor
var promCfg *prometheus.Config
if !opts.DisablePrometheus {
if !opts.DisablePrometheus && !t.SkipInit() {
// TODO(irfansharif): Move this after the import step. The statistics
// during import itself is uninteresting and pollutes actual workload
// data.
Expand Down

0 comments on commit e2bf64f

Please sign in to comment.