Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
132263: lint: fix `TestForbiddenImports` r=rail,herkolategan a=rickystewart

We need to set `Dir` in the `packages.Load()` call or else the whole thing doesn't work. It would be really nice if it threw an error instead of simply doing nothing, but it is what it is. To guard against this in the future I added an error if the list is empty.

Fix the test then all existing violations, except for `raftlogger` and `rafttest` which will need some extra TLC by the owning team (see cockroachdb#132262)

Closes cockroachdb#132258

Epic: none
Release note: None

132341: roachtest: run perf tests with sql and kv mode r=jeffswenson a=msbutler

Epic: none

Release note: none

Co-authored-by: Ricky Stewart <[email protected]>
Co-authored-by: Michael Butler <[email protected]>
  • Loading branch information
3 people committed Oct 10, 2024
3 parents 88600d3 + 4e662c4 + 904f0ed commit a69a2f3
Show file tree
Hide file tree
Showing 21 changed files with 107 additions and 37 deletions.
1 change: 0 additions & 1 deletion pkg/ccl/crosscluster/logical/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ go_library(
"//pkg/util/timeutil",
"//pkg/util/tracing",
"@com_github_cockroachdb_errors//:errors",
"@com_github_cockroachdb_errors//issuelink",
"@com_github_cockroachdb_logtags//:logtags",
"@com_github_cockroachdb_redact//:redact",
"@com_github_lib_pq//oid",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/tracing"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/errors/issuelink"
)

func init() {
Expand Down Expand Up @@ -94,7 +93,7 @@ func createLogicalReplicationStreamPlanHook(
}

if stmt.From.Database != "" {
return errors.UnimplementedErrorf(issuelink.IssueLink{}, "logical replication streams on databases are unsupported")
return errors.UnimplementedErrorf(errors.IssueLink{}, "logical replication streams on databases are unsupported")
}
if len(stmt.From.Tables) != len(stmt.Into.Tables) {
return pgerror.New(pgcode.InvalidParameterValue, "the same number of source and destination tables must be specified")
Expand Down
1 change: 0 additions & 1 deletion pkg/ccl/crosscluster/streamclient/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ go_library(
"@com_github_golang_snappy//:snappy",
"@com_github_jackc_pgconn//:pgconn",
"@com_github_jackc_pgx_v4//:pgx",
"@com_github_pkg_errors//:errors",
],
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/ccl/crosscluster/streamclient/client_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"github.com/cockroachdb/cockroach/pkg/ccl/crosscluster"
"github.com/cockroachdb/cockroach/pkg/repstream/streampb"
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/cockroachdb/errors"
"github.com/golang/snappy"
"github.com/jackc/pgx/v4"
"github.com/pkg/errors"
)

func subscribeInternal(
Expand Down
95 changes: 77 additions & 18 deletions pkg/cmd/roachtest/tests/logical_data_replication.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ type LDRWorkload struct {
func registerLogicalDataReplicationTests(r registry.Registry) {
specs := []ldrTestSpec{
{
name: "ldr/kv0/workload=both/ingestion",
name: "ldr/kv0/workload=both/basic/immediate",
clusterSpec: multiClusterSpec{
leftNodes: 3,
rightNodes: 3,
Expand All @@ -82,10 +82,11 @@ func registerLogicalDataReplicationTests(r registry.Registry) {
spec.VolumeSize(100),
},
},
run: TestLDRBasic,
mode: ModeImmediate,
run: TestLDRBasic,
},
{
name: "ldr/kv0/workload=both/update_heavy",
name: "ldr/kv0/workload=both/basic/validated",
clusterSpec: multiClusterSpec{
leftNodes: 3,
rightNodes: 3,
Expand All @@ -96,7 +97,38 @@ func registerLogicalDataReplicationTests(r registry.Registry) {
spec.VolumeSize(100),
},
},
run: TestLDRUpdateHeavy,
mode: ModeValidated,
run: TestLDRBasic,
},
{
name: "ldr/kv0/workload=both/update_heavy/immediate",
clusterSpec: multiClusterSpec{
leftNodes: 3,
rightNodes: 3,
clusterOpts: []spec.Option{
spec.CPU(8),
spec.WorkloadNode(),
spec.WorkloadNodeCPU(8),
spec.VolumeSize(100),
},
},
mode: ModeImmediate,
run: TestLDRUpdateHeavy,
},
{
name: "ldr/kv0/workload=both/update_heavy/validated",
clusterSpec: multiClusterSpec{
leftNodes: 3,
rightNodes: 3,
clusterOpts: []spec.Option{
spec.CPU(8),
spec.WorkloadNode(),
spec.WorkloadNodeCPU(8),
spec.VolumeSize(100),
},
},
mode: ModeValidated,
run: TestLDRUpdateHeavy,
},
{
name: "ldr/kv0/workload=both/shutdown_node",
Expand Down Expand Up @@ -143,6 +175,7 @@ func registerLogicalDataReplicationTests(r registry.Registry) {
}

for _, sp := range specs {

r.Add(registry.TestSpec{
Name: sp.name,
Owner: registry.OwnerDisasterRecovery,
Expand All @@ -162,14 +195,15 @@ func registerLogicalDataReplicationTests(r registry.Registry) {
}
setup, cleanup := mc.Start(ctx, t)
defer cleanup()
sp.run(ctx, t, c, setup)

sp.run(ctx, t, c, setup, sp.mode)
},
})
}
}

func TestLDRBasic(ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup) {
func TestLDRBasic(
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup, mode mode,
) {
duration := 15 * time.Minute
initRows := 1000
maxBlockBytes := 1024
Expand All @@ -191,7 +225,7 @@ func TestLDRBasic(ctx context.Context, t test.Test, c cluster.Cluster, setup mul
tableName: "kv",
}

leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload)
leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload, mode)

// Setup latency verifiers
maxExpectedLatency := 2 * time.Minute
Expand Down Expand Up @@ -236,7 +270,7 @@ func TestLDRBasic(ctx context.Context, t test.Test, c cluster.Cluster, setup mul
}

func TestLDRSchemaChange(
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup,
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup, mode mode,
) {
duration := 15 * time.Minute
if c.IsLocal() {
Expand All @@ -254,7 +288,7 @@ func TestLDRSchemaChange(
tableName: "kv",
}

leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload)
leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload, mode)

// Setup latency verifiers
maxExpectedLatency := 2 * time.Minute
Expand Down Expand Up @@ -312,7 +346,7 @@ func TestLDRSchemaChange(
}

func TestLDRUpdateHeavy(
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup,
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup, mode mode,
) {

duration := 10 * time.Minute
Expand All @@ -331,7 +365,7 @@ func TestLDRUpdateHeavy(
tableName: "usertable",
}

leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload)
leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload, mode)

// Setup latency verifiers
maxExpectedLatency := 3 * time.Minute
Expand Down Expand Up @@ -376,7 +410,7 @@ func TestLDRUpdateHeavy(
}

func TestLDROnNodeShutdown(
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup,
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup, mode mode,
) {

duration := 10 * time.Minute
Expand All @@ -395,7 +429,7 @@ func TestLDROnNodeShutdown(
tableName: "kv",
}

leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload)
leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload, mode)

// Setup latency verifiers, remembering to account for latency spike from killing a node
maxExpectedLatency := 5 * time.Minute
Expand Down Expand Up @@ -472,7 +506,7 @@ func TestLDROnNodeShutdown(
// aim to keep the workload going on both sides and wait for reconciliation
// once the network partition has completed
func TestLDROnNetworkPartition(
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup,
ctx context.Context, t test.Test, c cluster.Cluster, setup multiClusterSetup, mode mode,
) {
duration := 10 * time.Minute
if c.IsLocal() {
Expand All @@ -490,7 +524,7 @@ func TestLDROnNetworkPartition(
tableName: "kv",
}

leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload)
leftJobID, rightJobID := setupLDR(ctx, t, c, setup, ldrWorkload, mode)

monitor := c.NewMonitor(ctx, setup.CRDBNodes())
monitor.Go(func(ctx context.Context) error {
Expand Down Expand Up @@ -552,9 +586,29 @@ func getLogicalDataReplicationJobInfo(db *gosql.DB, jobID int) (jobInfo, error)
type ldrTestSpec struct {
name string
clusterSpec multiClusterSpec
run func(context.Context, test.Test, cluster.Cluster, multiClusterSetup)
run func(context.Context, test.Test, cluster.Cluster, multiClusterSetup, mode)
mode mode
}

type mode int

func (m mode) String() string {
switch m {
case ModeImmediate:
return "immediate"
case ModeValidated:
return "validated"
default:
return "default"
}
}

const (
Default = iota
ModeImmediate
ModeValidated
)

type multiClusterSpec struct {
clusterOpts []spec.Option

Expand Down Expand Up @@ -669,6 +723,7 @@ func setupLDR(
c cluster.Cluster,
setup multiClusterSetup,
ldrWorkload LDRWorkload,
mode mode,
) (int, int) {
c.Run(ctx,
option.WithNodes(setup.workloadNode),
Expand All @@ -680,9 +735,13 @@ func setupLDR(
dbName, tableName := ldrWorkload.dbName, ldrWorkload.tableName

startLDR := func(targetDB *sqlutils.SQLRunner, sourceURL string) int {
options := ""
if mode.String() != "" {
options = fmt.Sprintf("WITH mode='%s'", mode)
}
targetDB.Exec(t, fmt.Sprintf("USE %s", dbName))
r := targetDB.QueryRow(t,
fmt.Sprintf("CREATE LOGICAL REPLICATION STREAM FROM TABLE %s ON $1 INTO TABLE %s", tableName, tableName),
fmt.Sprintf("CREATE LOGICAL REPLICATION STREAM FROM TABLE %s ON $1 INTO TABLE %s %s", tableName, tableName, options),
sourceURL,
)
var jobID int
Expand Down
1 change: 1 addition & 0 deletions pkg/raft/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ go_library(
"//pkg/raft/raftstoreliveness",
"//pkg/raft/tracker",
"//pkg/util/hlc",
"@com_github_cockroachdb_errors//:errors",
"@org_golang_x_exp//maps",
],
)
Expand Down
3 changes: 1 addition & 2 deletions pkg/raft/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,8 @@
package raft

import (
"errors"

pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb"
"github.com/cockroachdb/errors"
)

// Bootstrap initializes the RawNode for first use by appending configuration
Expand Down
2 changes: 2 additions & 0 deletions pkg/raft/confchange/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ go_library(
"//pkg/raft/quorum",
"//pkg/raft/raftpb",
"//pkg/raft/tracker",
"@com_github_cockroachdb_errors//:errors",
],
)

Expand All @@ -29,5 +30,6 @@ go_test(
"//pkg/raft/raftpb",
"//pkg/raft/tracker",
"@com_github_cockroachdb_datadriven//:datadriven",
"@com_github_cockroachdb_errors//:errors",
],
)
2 changes: 1 addition & 1 deletion pkg/raft/confchange/confchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
package confchange

import (
"errors"
"fmt"
"strings"

"github.com/cockroachdb/cockroach/pkg/raft/quorum"
pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb"
"github.com/cockroachdb/cockroach/pkg/raft/tracker"
"github.com/cockroachdb/errors"
)

// Changer facilitates configuration changes. It exposes methods to handle
Expand Down
2 changes: 1 addition & 1 deletion pkg/raft/confchange/datadriven_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package confchange

import (
"errors"
"fmt"
"strconv"
"strings"
Expand All @@ -28,6 +27,7 @@ import (
pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb"
"github.com/cockroachdb/cockroach/pkg/raft/tracker"
"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/errors"
)

func TestConfChangeDataDriven(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion pkg/raft/raft.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"bytes"
"context"
"crypto/rand"
"errors"
"fmt"
"math"
"math/big"
Expand All @@ -36,6 +35,7 @@ import (
pb "github.com/cockroachdb/cockroach/pkg/raft/raftpb"
"github.com/cockroachdb/cockroach/pkg/raft/raftstoreliveness"
"github.com/cockroachdb/cockroach/pkg/raft/tracker"
"github.com/cockroachdb/errors"
"golang.org/x/exp/maps"
)

Expand Down
2 changes: 1 addition & 1 deletion pkg/raft/rafttest/interaction_env_handler_add_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package rafttest

import (
"context"
"errors"
"fmt"
"reflect"
"testing"
Expand All @@ -31,6 +30,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/errors"
)

func (env *InteractionEnv) handleAddNodes(t *testing.T, d datadriven.TestData) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
package rafttest

import (
"errors"
"fmt"
"testing"

"github.com/cockroachdb/cockroach/pkg/raft"
"github.com/cockroachdb/cockroach/pkg/raft/raftpb"
"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/errors"
)

func (env *InteractionEnv) handleProcessAppendThread(t *testing.T, d datadriven.TestData) error {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
package rafttest

import (
"errors"
"testing"

"github.com/cockroachdb/datadriven"
"github.com/cockroachdb/errors"
)

func (env *InteractionEnv) handleReportUnreachable(t *testing.T, d datadriven.TestData) error {
Expand Down
Loading

0 comments on commit a69a2f3

Please sign in to comment.