-
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 all 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 commentThe reason will be displayed to describe this comment to others. Learn more. Added a new file to be able "source" it in the script in charge of testing false positives ( |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#!/usr/bin/env bash | ||
|
||
stack_version_args() { | ||
if [[ -z "${PACKAGE_UNDER_TEST:-""}" ]]; then | ||
# Don't force stack version if we are testing multiple packages. | ||
return | ||
fi | ||
|
||
local package_root=test/packages/${PACKAGE_TEST_TYPE:-false_positives}/${PACKAGE_UNDER_TEST}/ | ||
local stack_version_file="${package_root%/}.stack_version" | ||
if [[ ! -f "$stack_version_file" ]]; then | ||
return | ||
fi | ||
|
||
echo -n "--version $(cat "$stack_version_file")" | ||
} | ||
|
||
stack_provider_args() { | ||
if [[ -z "${PACKAGE_UNDER_TEST:-""}" ]]; then | ||
# Don't force stack version if we are testing multiple packages. | ||
return | ||
fi | ||
|
||
local package_root=test/packages/${PACKAGE_TEST_TYPE:-false_positives}/${PACKAGE_UNDER_TEST}/ | ||
local parameters="${package_root%/}.stack_provider_settings" | ||
if [[ ! -f "$parameters" ]]; then | ||
return | ||
fi | ||
|
||
echo -n "-U $(cat "${parameters}" | tr '\n' ',' | tr -d ' ' | sed 's/,$//')" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,9 @@ | ||
#!/bin/bash | ||
|
||
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) | ||
|
||
source "${SCRIPT_DIR}/stack_parameters.sh" | ||
|
||
set -euxo pipefail | ||
|
||
function cleanup() { | ||
|
@@ -76,31 +80,20 @@ function check_build_output() { | |
) | ||
} | ||
|
||
function stack_version_args() { | ||
if [[ -z "$PACKAGE_UNDER_TEST" ]]; then | ||
# Don't force stack version if we are testing multiple packages. | ||
return | ||
fi | ||
|
||
local package_root=test/packages/${PACKAGE_TEST_TYPE:-false_positives}/${PACKAGE_UNDER_TEST}/ | ||
local stack_version_file="${package_root%/}.stack_version" | ||
if [[ ! -f $stack_version_file ]]; then | ||
return | ||
fi | ||
|
||
echo -n "--version $(cat $stack_version_file)" | ||
} | ||
|
||
trap cleanup EXIT | ||
|
||
ELASTIC_PACKAGE_LINKS_FILE_PATH="$(pwd)/scripts/links_table.yml" | ||
export ELASTIC_PACKAGE_LINKS_FILE_PATH | ||
|
||
stack_args=$(stack_version_args) | ||
stack_args=$(stack_version_args) # --version <version> | ||
|
||
# Update the stack | ||
elastic-package stack update -v ${stack_args} | ||
Comment on lines
+88
to
91
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.
|
||
|
||
# NOTE: if any provider argument is defined, the stack must be shutdown first to ensure | ||
# that all parameters are taken into account by the services | ||
stack_args="${stack_args} $(stack_provider_args)" # -U <setting=1,settings=2> | ||
|
||
# Boot up the stack | ||
elastic-package stack up -d -v ${stack_args} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
dependencies: | ||
ecs: | ||
reference: git@8.7 | ||
reference: "git@v8.11.0" |
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. Updated test package with the latest contents from integrations repository. |
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: