Skip to content

Commit

Permalink
Merge #87659 #87660
Browse files Browse the repository at this point in the history
87659: dev: ensure libdir is created and populated when running roachprod-stress r=rickystewart a=healthy-pod

Previously, `geos libs` were created under the `artifacts` directory.

This code change copies them into their own directory.
Closes #87643

Release note: None

87660: dev: build more stuff with linting turned on as part of `dev lint` r=healthy-pod a=rickystewart

This will find more failures in more components.

Release note: None

Co-authored-by: healthy-pod <[email protected]>
Co-authored-by: Ricky Stewart <[email protected]>
  • Loading branch information
3 people committed Sep 9, 2022
3 parents be989ac + b756923 + d367637 commit 11414d7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 11 deletions.
2 changes: 1 addition & 1 deletion dev
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ fi
set -euo pipefail

# Bump this counter to force rebuilding `dev` on all machines.
DEV_VERSION=57
DEV_VERSION=58

THIS_DIR=$(cd "$(dirname "$0")" && pwd)
BINARY_DIR=$THIS_DIR/bin/dev-versions
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/dev/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ var buildTargetMapping = map[string]string{
"goimports": "@com_github_cockroachdb_gostdlib//x/tools/cmd/goimports:goimports",
"label-merged-pr": "//pkg/cmd/label-merged-pr:label-merged-pr",
"geos": geosTarget,
"langgen": "//pkg/sql/opt/optgen/cmd/langgen:langgen",
"libgeos": geosTarget,
"obsservice": "//pkg/obsservice/cmd/obsservice",
"obsservice": "//pkg/obsservice/cmd/obsservice:obsservice",
"optgen": "//pkg/sql/opt/optgen/cmd/optgen:optgen",
"optfmt": "//pkg/sql/opt/optgen/cmd/optfmt:optfmt",
"oss": "//pkg/cmd/cockroach-oss:cockroach-oss",
"langgen": "//pkg/sql/opt/optgen/cmd/langgen:langgen",
"reduce": "//pkg/cmd/reduce:reduce",
"roachprod": "//pkg/cmd/roachprod:roachprod",
"roachprod-stress": "//pkg/cmd/roachprod-stress:roachprod-stress",
Expand Down
10 changes: 9 additions & 1 deletion pkg/cmd/dev/lint.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,15 @@ func (d *dev) lint(cmd *cobra.Command, commandLine []string) error {
return err
}
if !short && filter == "" {
args := []string{"build", "//pkg/cmd/cockroach-short", "--//build/toolchains:nogo_flag"}
args := []string{
"build",
"//pkg/cmd/cockroach-short",
"//pkg/cmd/dev",
"//pkg/obsservice/cmd/obsservice",
"//pkg/cmd/roachprod",
"//pkg/cmd/roachtest",
"--//build/toolchains:nogo_flag",
}
if numCPUs != 0 {
args = append(args, fmt.Sprintf("--local_cpu_resources=%d", numCPUs))
}
Expand Down
32 changes: 27 additions & 5 deletions pkg/cmd/dev/roachprod_stress.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ package main

import (
"fmt"
"path"
"path/filepath"
"strings"

Expand Down Expand Up @@ -87,13 +88,15 @@ func (d *dev) roachprodStress(cmd *cobra.Command, commandLine []string) error {
// List of targets we need to cross-build.
crossTargets := []string{testTarget, stressTarget}
// Check whether this target depends on libgeos.
dependsOnGeos := false
queryArgs := []string{"query", fmt.Sprintf("somepath(%s, //c-deps:libgeos)", testTarget)}
queryOutput, err := d.exec.CommandContextSilent(ctx, "bazel", queryArgs...)
if err != nil {
return fmt.Errorf("could not run `bazel %s` (%w)", shellescape.QuoteCommand(queryArgs), err)
}
if strings.TrimSpace(string(queryOutput)) != "" {
// If the test depends on geos we additionally want to cross-build it.
dependsOnGeos = true
crossTargets = append(crossTargets, "//c-deps:libgeos")
}

Expand All @@ -109,24 +112,43 @@ func (d *dev) roachprodStress(cmd *cobra.Command, commandLine []string) error {
return err
}

testTargetBasename := strings.Split(targets[0].fullName, ":")[1]
// Build roachprod-stress and roachprod.
args, buildTargets, err := d.getBasicBuildArgs(ctx, []string{"//pkg/cmd/roachprod-stress"})
// Build roachprod-stress.
args, roachprodStressTarget, err := d.getBasicBuildArgs(ctx, []string{"//pkg/cmd/roachprod-stress"})
if err != nil {
return err
}
if _, err := d.exec.CommandContextSilent(ctx, "bazel", args...); err != nil {
return err
}
if err := d.stageArtifacts(ctx, buildTargets); err != nil {
if err := d.stageArtifacts(ctx, roachprodStressTarget); err != nil {
return err
}

workspace, err := d.getWorkspace(ctx)
if err != nil {
return err
}

libdir := path.Join(workspace, "artifacts", "libgeos", "lib")
if dependsOnGeos {
if err = d.os.MkdirAll(libdir); err != nil {
return err
}
for _, libWithExt := range []string{"libgeos.so", "libgeos_c.so"} {
src := filepath.Join(workspace, "artifacts", libWithExt)
dst := filepath.Join(libdir, libWithExt)
if err := d.os.CopyFile(src, dst); err != nil {
return err
}
if err := d.os.Remove(src); err != nil {
return err
}
}
}

testTargetBasename := strings.Split(targets[0].fullName, ":")[1]
// Run roachprod-stress.
roachprodStressArgs := []string{cluster, fmt.Sprintf("./%s", pkg), "-testbin", filepath.Join(workspace, "artifacts", testTargetBasename), "-stressbin", filepath.Join(workspace, "artifacts", "stress"), "-libdir", filepath.Join(workspace, "artifacts", "libgeos", "lib")}
roachprodStressArgs := []string{cluster, fmt.Sprintf("./%s", pkg), "-testbin", filepath.Join(workspace, "artifacts", testTargetBasename), "-stressbin", filepath.Join(workspace, "artifacts", "stress"), "-libdir", libdir}
roachprodStressArgs = append(roachprodStressArgs, strings.Fields(stressCmdArgs)...)
roachprodStressArgs = append(roachprodStressArgs, "--")
roachprodStressArgs = append(roachprodStressArgs, testArgs...)
Expand Down
4 changes: 2 additions & 2 deletions pkg/cmd/dev/testdata/datadriven/lint
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ exec
dev lint
----
bazel run --config=test //build/bazelutil:lint -- -test.v
bazel build //pkg/cmd/cockroach-short --//build/toolchains:nogo_flag
bazel build //pkg/cmd/cockroach-short //pkg/cmd/dev //pkg/obsservice/cmd/obsservice //pkg/cmd/roachprod //pkg/cmd/roachtest --//build/toolchains:nogo_flag

exec
dev lint --short --timeout=5m
Expand All @@ -24,7 +24,7 @@ exec
dev lint --cpus 4
----
bazel run --config=test //build/bazelutil:lint --local_cpu_resources=4 -- -test.v
bazel build //pkg/cmd/cockroach-short --//build/toolchains:nogo_flag --local_cpu_resources=4
bazel build //pkg/cmd/cockroach-short //pkg/cmd/dev //pkg/obsservice/cmd/obsservice //pkg/cmd/roachprod //pkg/cmd/roachtest --//build/toolchains:nogo_flag --local_cpu_resources=4

exec
dev lint pkg/cmd/dev pkg/spanconfig
Expand Down

0 comments on commit 11414d7

Please sign in to comment.