From e2bf64f8d4d11f5c1d6e348d1db1fbe89d7a9111 Mon Sep 17 00:00:00 2001 From: irfan sharif Date: Tue, 15 Aug 2023 16:52:57 -0400 Subject: [PATCH] admission,roachtest: re-home row-level ttl test 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 #89208. Release note: None --- pkg/cmd/roachtest/tests/BUILD.bazel | 2 +- pkg/cmd/roachtest/tests/admission_control.go | 1 + .../tests/admission_control_elastic_backup.go | 4 +- .../tests/admission_control_row_level_ttl.go | 109 ++++++++++++++++++ pkg/cmd/roachtest/tests/registry.go | 1 - pkg/cmd/roachtest/tests/row_level_ttl.go | 81 ------------- pkg/cmd/roachtest/tests/tpcc.go | 2 +- 7 files changed, 114 insertions(+), 86 deletions(-) create mode 100644 pkg/cmd/roachtest/tests/admission_control_row_level_ttl.go delete mode 100644 pkg/cmd/roachtest/tests/row_level_ttl.go diff --git a/pkg/cmd/roachtest/tests/BUILD.bazel b/pkg/cmd/roachtest/tests/BUILD.bazel index d1d4e73959f5..e3584148a945 100644 --- a/pkg/cmd/roachtest/tests/BUILD.bazel +++ b/pkg/cmd/roachtest/tests/BUILD.bazel @@ -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", @@ -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", diff --git a/pkg/cmd/roachtest/tests/admission_control.go b/pkg/cmd/roachtest/tests/admission_control.go index e95f19035d91..07a8382fcfa9 100644 --- a/pkg/cmd/roachtest/tests/admission_control.go +++ b/pkg/cmd/roachtest/tests/admission_control.go @@ -30,6 +30,7 @@ func registerAdmission(r registry.Registry) { registerElasticControlForBackups(r) registerElasticControlForCDC(r) + registerElasticControlForRowLevelTTL(r) registerMultiStoreOverload(r) registerMultiTenantFairness(r) registerSnapshotOverload(r) diff --git a/pkg/cmd/roachtest/tests/admission_control_elastic_backup.go b/pkg/cmd/roachtest/tests/admission_control_elastic_backup.go index 9d079b50e705..edf6dbbbefd3 100644 --- a/pkg/cmd/roachtest/tests/admission_control_elastic_backup.go +++ b/pkg/cmd/roachtest/tests/admission_control_elastic_backup.go @@ -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{ diff --git a/pkg/cmd/roachtest/tests/admission_control_row_level_ttl.go b/pkg/cmd/roachtest/tests/admission_control_row_level_ttl.go new file mode 100644 index 000000000000..13bc5e1f93f5 --- /dev/null +++ b/pkg/cmd/roachtest/tests/admission_control_row_level_ttl.go @@ -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}) + }, + }) + }, + } +} diff --git a/pkg/cmd/roachtest/tests/registry.go b/pkg/cmd/roachtest/tests/registry.go index fb134392c160..36223cdab246 100644 --- a/pkg/cmd/roachtest/tests/registry.go +++ b/pkg/cmd/roachtest/tests/registry.go @@ -116,7 +116,6 @@ func RegisterTests(r registry.Registry) { registerRestoreNodeShutdown(r) registerRoachmart(r) registerRoachtest(r) - registerRowLevelTTLDuringTPCC(r) registerRubyPG(r) registerRustPostgres(r) registerSQLAlchemy(r) diff --git a/pkg/cmd/roachtest/tests/row_level_ttl.go b/pkg/cmd/roachtest/tests/row_level_ttl.go deleted file mode 100644 index 79a0226d5b04..000000000000 --- a/pkg/cmd/roachtest/tests/row_level_ttl.go +++ /dev/null @@ -1,81 +0,0 @@ -// 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/util/timeutil" -) - -func registerRowLevelTTLDuringTPCC(r registry.Registry) { - const nodes = 7 - var clusterSpec = spec.CPU(4) - const warehouses = 1500 - const activeWarehouses = 100 - const duration = 30 * time.Minute - r.Add(makeRowLevelTTLDuringTPCC(r.MakeClusterSpec(nodes, clusterSpec), warehouses, activeWarehouses, duration, false /* expiredRows */)) - r.Add(makeRowLevelTTLDuringTPCC(r.MakeClusterSpec(nodes, clusterSpec), warehouses, activeWarehouses, duration, true /* expiredRows */)) -} - -func makeRowLevelTTLDuringTPCC( - spec spec.ClusterSpec, warehouses, activeWarehouses int, length time.Duration, expiredRows bool, -) registry.TestSpec { - return registry.TestSpec{ - Name: fmt.Sprintf("row-level-ttl/during/tpcc/expired-rows=%t", expiredRows), - Owner: registry.OwnerSQLFoundations, - Benchmark: true, - Cluster: spec, - Leases: registry.MetamorphicLeases, - Timeout: length * 3, - Run: func(ctx context.Context, t test.Test, c cluster.Cluster) { - runTPCC(ctx, t, c, tpccOptions{ - Warehouses: warehouses, - // 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, warehouses), - // The expired-rows test will delete rows from the order_line table, so - // the post run checks are expected to fail. - SkipPostRunCheck: expiredRows, - During: func(ctx context.Context) error { - nowMinute := timeutil.Now().Minute() - scheduledMinute := (nowMinute + 10) % 60 - 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, - ) - - if err := runAndLogStmts(ctx, t, c, "enable-ttl", []string{ttlStatement}); err != nil { - return err - } - return nil - }, - Duration: length, - SetupType: usingImport, - }) - }, - } -} diff --git a/pkg/cmd/roachtest/tests/tpcc.go b/pkg/cmd/roachtest/tests/tpcc.go index 6f2650ef0cf5..e8426b19f49f 100644 --- a/pkg/cmd/roachtest/tests/tpcc.go +++ b/pkg/cmd/roachtest/tests/tpcc.go @@ -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.