Skip to content

Commit

Permalink
Run validation mappings before validating ignored fields (#2389)
Browse files Browse the repository at this point in the history
Reorder validation performed in system tests to execute validation
based on mappings just after the validation based on fields.
  • Loading branch information
mrodm authored Feb 10, 2025
1 parent b7445a2 commit 23420eb
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions internal/testrunner/runners/system/tester.go
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,8 @@ func (r *tester) prepareScenario(ctx context.Context, config *testConfig, stackC
return hits.size() > 0, nil
}, 1*time.Second, waitForDataTimeout)

// before checking "waitErr" error , it is necessary to check if the service has finished with error
// to report it as a test case failed
if service != nil && config.Service != "" && !config.IgnoreServiceError {
exited, code, err := service.ExitCode(ctx, config.Service)
if err != nil && !errors.Is(err, servicedeployer.ErrNotSupported) {
Expand Down Expand Up @@ -1637,16 +1639,6 @@ func (r *tester) validateTestScenario(ctx context.Context, result *testrunner.Re
})
}

stackVersion, err := semver.NewVersion(r.stackVersion.Number)
if err != nil {
return result.WithErrorf("failed to parse stack version: %w", err)
}

err = validateIgnoredFields(stackVersion, scenario, config)
if err != nil {
return result.WithError(err)
}

if r.fieldValidationMethod == mappingsMethod {
logger.Warn("Validation based on mappings enabled (technical preview)")
exceptionFields := listExceptionFields(scenario.docs, fieldsValidator)
Expand All @@ -1669,6 +1661,16 @@ func (r *tester) validateTestScenario(ctx context.Context, result *testrunner.Re
}
}

stackVersion, err := semver.NewVersion(r.stackVersion.Number)
if err != nil {
return result.WithErrorf("failed to parse stack version: %w", err)
}

err = validateIgnoredFields(stackVersion, scenario, config)
if err != nil {
return result.WithError(err)
}

docs := scenario.docs
if scenario.syntheticEnabled {
docs, err = fieldsValidator.SanitizeSyntheticSourceDocs(scenario.docs)
Expand Down

0 comments on commit 23420eb

Please sign in to comment.