Skip to content

Commit

Permalink
dev: ensure libdir is created and populated when running roachprod-st…
Browse files Browse the repository at this point in the history
…ress

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

This code change copies them into their own directory.

Closes #87643

Release note: None
  • Loading branch information
healthy-pod committed Sep 9, 2022
1 parent 2b5d87f commit b756923
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 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
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

0 comments on commit b756923

Please sign in to comment.