-
Notifications
You must be signed in to change notification settings - Fork 117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Disable normalization validating fields in transforms if synthetics is enabled #2011
Changes from 4 commits
84fc9ac
ab88d3d
1003403
0c8abda
708f4c8
5e96fbc
21e4f27
bb32496
fc042f2
6ed4ed8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -842,14 +842,35 @@ type scenarioTest struct { | |
startTestTime time.Time | ||
} | ||
|
||
type pipelineTrace []string | ||
|
||
func (p *pipelineTrace) UnmarshalJSON(d []byte) error { | ||
var alias interface{} | ||
if err := json.Unmarshal(d, &alias); err != nil { | ||
return err | ||
} | ||
switch v := alias.(type) { | ||
case string: | ||
*p = append(*p, v) | ||
case []any: | ||
// asume it is going to be an array of strings | ||
for _, value := range v { | ||
*p = append(*p, fmt.Sprint(value)) | ||
} | ||
default: | ||
return fmt.Errorf("unexpected type found for pipeline_trace: %T", v) | ||
} | ||
return nil | ||
} | ||
|
||
type failureStoreDocument struct { | ||
Error struct { | ||
Type string `json:"type"` | ||
Message string `json:"message"` | ||
StackTrace string `json:"stack_trace"` | ||
PipelineTrace []string `json:"pipeline_trace"` | ||
Pipeline string `json:"pipeline"` | ||
ProcessorType string `json:"processor_type"` | ||
Type string `json:"type"` | ||
Message string `json:"message"` | ||
StackTrace string `json:"stack_trace"` | ||
PipelineTrace pipelineTrace `json:"pipeline_trace"` | ||
Pipeline string `json:"pipeline"` | ||
ProcessorType string `json:"processor_type"` | ||
} `json:"error"` | ||
} | ||
|
||
|
@@ -1462,7 +1483,7 @@ func (r *tester) validateTestScenario(ctx context.Context, result *testrunner.Re | |
} | ||
|
||
// Check transforms if present | ||
if err := r.checkTransforms(ctx, config, r.pkgManifest, scenario.kibanaDataStream, scenario.dataStream); err != nil { | ||
if err := r.checkTransforms(ctx, config, r.pkgManifest, scenario.kibanaDataStream, scenario.dataStream, scenario.syntheticEnabled); err != nil { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use the same value as in the main data stream. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure what Fleet does with transform indexes. Could we add a test case that would fail without this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll check to run a test package for that use case (with logsdb enabled). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added a new test package |
||
results, _ := result.WithError(err) | ||
return results, nil | ||
} | ||
|
@@ -1793,7 +1814,7 @@ func selectPolicyTemplateByName(policies []packages.PolicyTemplate, name string) | |
return packages.PolicyTemplate{}, fmt.Errorf("policy template %q not found", name) | ||
} | ||
|
||
func (r *tester) checkTransforms(ctx context.Context, config *testConfig, pkgManifest *packages.PackageManifest, ds kibana.PackageDataStream, dataStream string) error { | ||
func (r *tester) checkTransforms(ctx context.Context, config *testConfig, pkgManifest *packages.PackageManifest, ds kibana.PackageDataStream, dataStream string, syntheticEnabled bool) error { | ||
transforms, err := packages.ReadTransformsFromPackageRoot(r.packageRootPath) | ||
if err != nil { | ||
return fmt.Errorf("loading transforms for package failed (root: %s): %w", r.packageRootPath, err) | ||
|
@@ -1839,6 +1860,7 @@ func (r *tester) checkTransforms(ctx context.Context, config *testConfig, pkgMan | |
fields.WithSpecVersion(pkgManifest.SpecVersion), | ||
fields.WithNumericKeywordFields(config.NumericKeywordFields), | ||
fields.WithEnabledImportAllECSSChema(true), | ||
fields.WithDisableNormalization(syntheticEnabled), | ||
) | ||
if err != nil { | ||
return fmt.Errorf("creating fields validator for data stream failed (path: %s): %w", transformRootPath, err) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Support string and slice of strings.
Examples of the response: