Skip to content

Commit

Permalink
misc changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanyzhang committed Jun 20, 2024
1 parent bb61566 commit f21bf29
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion stage/map.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@ func ParseStage(stage *Stage, stages Map) (*Stage, error) {
nextStagePath = filepath.Join(stage.BaseDir, nextStagePath)
stage.NextStagePaths[i] = nextStagePath
}
if _, err := os.Stat(nextStagePath); err != nil {
if fileInfo, err := os.Stat(nextStagePath); err != nil {
return nil, fmt.Errorf("%s links to an invalid next stage file %s: %w", stage.Id, nextStagePath, err)
} else if fileInfo.IsDir() {
return nil, fmt.Errorf("%s links to a directory as next stage: %s", stage.Id, nextStagePath)
}
}
stages[stage.Id] = stage
Expand Down
7 changes: 4 additions & 3 deletions stage/stage.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ func (s *Stage) run(ctx context.Context) (returnErr error) {
s.prepareClient()
s.propagateStates()
if len(s.Queries)+len(s.QueryFiles) > 0 {
if s.RandomExecution != nil && *s.RandomExecution {
if *s.RandomExecution {
returnErr = s.runRandomly(ctx)
} else {
returnErr = s.runSequentially(ctx)
Expand Down Expand Up @@ -271,7 +271,7 @@ func (s *Stage) runSequentially(ctx context.Context) (returnErr error) {
}

func (s *Stage) runQueryFile(ctx context.Context, queryFile string, expectedRowCountStartIndex *int, fileAlias *string) error {
file, err := os.Open(queryFile)
// fileAlias is the query file name we will report. We try to make it short, so try to use relative path when possible.
if fileAlias == nil {
if relPath, relErr := filepath.Rel(s.BaseDir, queryFile); relErr == nil {
fileAlias = &relPath
Expand All @@ -280,6 +280,7 @@ func (s *Stage) runQueryFile(ctx context.Context, queryFile string, expectedRowC
}
}

file, err := os.Open(queryFile)
var queries []string
if err == nil {
queries, err = presto.SplitQueries(file)
Expand Down Expand Up @@ -320,7 +321,7 @@ func (s *Stage) runRandomly(ctx context.Context) error {
} else {
err := fmt.Errorf("failed to parse randomly_execute_until %s", *s.RandomlyExecuteUntil)
if *s.AbortOnError {
s.States.exitCode.CompareAndSwap(0, 5)
s.States.exitCode.CompareAndSwap(0, 2) // syntax error
return err
} else {
log.Error().Err(err).Send()
Expand Down
3 changes: 3 additions & 0 deletions stage/stage_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,9 @@ func (s *Stage) prepareClient() {

func (s *Stage) setDefaults() {
falseValue := false
if s.RandomExecution == nil {
s.RandomExecution = &falseValue
}
if s.AbortOnError == nil {
s.AbortOnError = &falseValue
}
Expand Down

0 comments on commit f21bf29

Please sign in to comment.