Skip to content

Commit a55fdf0

Browse files
committed
Add false positive package to detect regressions in JSON marshalling
1 parent 05f009b commit a55fdf0

File tree

15 files changed

+153
-6
lines changed

15 files changed

+153
-6
lines changed

internal/testrunner/runners/pipeline/runner.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,6 @@ func (r *runner) run() ([]testrunner.TestResult, error) {
179179
}
180180
startTime := time.Now()
181181

182-
// TODO: Add tests to cover regressive use of json.Unmarshal in loadTestCaseFile.
183-
// See https://github.com/elastic/elastic-package/pull/717.
184182
tc, err := r.loadTestCaseFile(testCaseFile)
185183
if err != nil {
186184
err := fmt.Errorf("loading test case failed: %w", err)
@@ -225,8 +223,6 @@ func (r *runner) run() ([]testrunner.TestResult, error) {
225223
return nil, fmt.Errorf("creating fields validator for data stream failed (path: %s, test case file: %s): %w", dataStreamPath, testCaseFile, err)
226224
}
227225

228-
// TODO: Add tests to cover regressive use of json.Unmarshal in verifyResults.
229-
// See https://github.com/elastic/elastic-package/pull/717.
230226
err = r.verifyResults(testCaseFile, tc.config, result, fieldsValidator)
231227
if e, ok := err.(testrunner.ErrTestCaseFailed); ok {
232228
tr.FailureMsg = e.Error()
@@ -328,8 +324,6 @@ func (r *runner) verifyResults(testCaseFile string, config *testConfig, result *
328324
}
329325

330326
if r.options.GenerateTestResult {
331-
// TODO: Add tests to cover regressive use of json.Unmarshal in writeTestResult.
332-
// See https://github.com/elastic/elastic-package/pull/717.
333327
err := writeTestResult(testCasePath, result, *specVersion)
334328
if err != nil {
335329
return fmt.Errorf("writing test result failed: %w", err)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<failure>test case failed: Expected results are different from actual ones:.*</failure>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dependencies:
2+
ecs:
3+
reference: git@1.10
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Long Integer Tests
2+
3+
{{event "test"}}
4+
5+
{{fields "test"}}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# newer versions go on top
2+
- version: "0.0.1"
3+
changes:
4+
- description: Initial draft of the package
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/1 # FIXME Replace with the real PR link
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
4503599627370497,9007199254740991,9007199254740993,18014398509481985,9223372036854773807
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
fields:
2+
"@warning": "The values in sequence_number must match the values in message."
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"expected": [
3+
{
4+
"@warning": "The values in sequence_number must match the values in message.",
5+
"message": "4503599627370497,9007199254740991,9007199254740993,18014398509481985,9223372036854773807",
6+
"sequence_number": [
7+
4503599627370497,
8+
9007199254740991,
9+
9007199254740992,
10+
18014398509481984,
11+
9223372036854774000
12+
]
13+
}
14+
]
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
paths:
2+
{{#each paths as |path i|}}
3+
- {{path}}
4+
{{/each}}
5+
exclude_files: [".gz$"]
6+
processors:
7+
- add_locale: ~
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
---
2+
description: Pipeline for processing sample logs
3+
processors:
4+
- split:
5+
field: message
6+
separator: ","
7+
target_field: sequence_number
8+
ignore_missing: true
9+
- convert:
10+
field: sequence_number
11+
type: long
12+
13+
on_failure:
14+
- set:
15+
field: error.message
16+
value: '{{ _ingest.on_failure_message }}'

0 commit comments

Comments
 (0)