Skip to content

Commit

Permalink
PSDL - Fix path manipulation (#855)
Browse files Browse the repository at this point in the history
  • Loading branch information
roypaulin committed Jul 11, 2024
1 parent d2ea80a commit f504804
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
19 changes: 3 additions & 16 deletions cmd/kuttl-step-gen/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,7 @@ import (
"go.uber.org/zap"
)

const (
ConfigArg = iota
NumPositionalArgs
)

const configDir = "/tmp"
const configPath = "/tmp/local-soak.cfg"

func setupLog() logr.Logger {
cfg := zap.Config{
Expand Down Expand Up @@ -70,26 +65,18 @@ func main() {
"The relative directory to the output directory where the repository scripts directory is located.")
flag.Parse()

if flag.NArg() < NumPositionalArgs {
fmt.Println("Not enough positional arguments.")
flag.Usage()
os.Exit(1)
}

configFileName := flag.Arg(ConfigArg)
configPath := fmt.Sprintf("%s/%s", configDir, configFileName)
if !filepath.IsAbs(configPath) {
fmt.Printf("'%s' is not an absolute path", configPath)
os.Exit(1)
}
configRaw, err := os.ReadFile(configPath)
if err != nil {
fmt.Printf("Failed to read config file %s: %s", configFileName, err.Error())
fmt.Printf("Failed to read config file %s: %s", configPath, err.Error())
os.Exit(1)
}
var config kstepgen.Config
if err := yaml.Unmarshal(configRaw, &config); err != nil {
fmt.Printf("Failed to parse config file %s: %s", configFileName, err.Error())
fmt.Printf("Failed to parse config file %s: %s", configPath, err.Error())
os.Exit(1)
}

Expand Down
6 changes: 3 additions & 3 deletions scripts/soak-runner.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ fi

logInfo "Running $ITERATIONS_STR iterations of $TEST_STEPS steps"

cp $CONFIG_FILE /tmp/
tmpfile=/tmp/$CONFIG_FILE
tmpfile=/tmp/local-soak.cfg
cp $CONFIG_FILE $tmpfile
trap "rm $tmpfile" 0 2 3 15 # Ensure deletion on script exit

curIter=0
Expand All @@ -87,7 +87,7 @@ do

# Generate the kuttl test steps for this iteration
logInfo "\tGenerating test steps. Appending output to $KUTTL_STEP_GEN_OUT"
bin/kuttl-step-gen --output-dir=$STEP_OUTPUT_DIR --scripts-dir="../../../scripts" $CONFIG_FILE 2>> $KUTTL_STEP_GEN_OUT
bin/kuttl-step-gen --output-dir=$STEP_OUTPUT_DIR --scripts-dir="../../../scripts" 2>> $KUTTL_STEP_GEN_OUT

KUTTL_CFG="kuttl-soak-test-iteration.yaml"
logInfo "\tRunning kuttl. Appending output to $KUTTL_OUT"
Expand Down

0 comments on commit f504804

Please sign in to comment.