-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
[Ingest Manager] Guard against empty stream.datasource and namespace #18769
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,86 @@ func TestRules(t *testing.T) { | |
expectedYAML string | ||
rule Rule | ||
}{ | ||
"fix streams": { | ||
givenYAML: ` | ||
datasources: | ||
- name: All default | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/error.log | ||
- name: Specified namespace | ||
namespace: nsns | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
- name: Specified dataset | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: dsds | ||
- name: All specified | ||
namespace: nsns | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: dsds | ||
- name: All specified with empty strings | ||
namespace: "" | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: "" | ||
`, | ||
expectedYAML: ` | ||
datasources: | ||
- name: All default | ||
namespace: default | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/error.log | ||
dataset: generic | ||
- name: Specified namespace | ||
namespace: nsns | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: generic | ||
- name: Specified dataset | ||
namespace: default | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: dsds | ||
- name: All specified | ||
namespace: nsns | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: dsds | ||
- name: All specified with empty strings | ||
namespace: default | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: generic | ||
`, | ||
rule: &RuleList{ | ||
Rules: []Rule{ | ||
FixStream(), | ||
}, | ||
}, | ||
}, | ||
|
||
"inject index": { | ||
givenYAML: ` | ||
datasources: | ||
|
@@ -49,6 +129,13 @@ datasources: | |
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: dsds | ||
- name: All specified with empty strings | ||
namespace: "" | ||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: "" | ||
`, | ||
expectedYAML: ` | ||
datasources: | ||
|
@@ -80,6 +167,14 @@ datasources: | |
- paths: /var/log/mysql/access.log | ||
dataset: dsds | ||
index: mytype-dsds-nsns | ||
- name: All specified with empty strings | ||
namespace: "" | ||
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. Shouldn't the expected now be 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. this is test for injecting index, it does not change existing values. 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. we need both. values and index must match. In a follow up we can discuss, if we should even error if it is "". 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. @michalpristas I also thought the result should be default? 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 think we can fix it but outside of injectIndex rule, what this should do is injecting index and not modifying anything on top of that. |
||
inputs: | ||
- type: file | ||
streams: | ||
- paths: /var/log/mysql/access.log | ||
dataset: "" | ||
index: mytype-generic-default | ||
`, | ||
rule: &RuleList{ | ||
Rules: []Rule{ | ||
|
@@ -564,6 +659,7 @@ func TestSerialization(t *testing.T) { | |
InjectStreamProcessor("insert_after", "index-type"), | ||
CopyToList("t1", "t2", "insert_after"), | ||
CopyAllToList("t2", "insert_before", "a", "b"), | ||
FixStream(), | ||
) | ||
|
||
y := `- rename: | ||
|
@@ -623,6 +719,7 @@ func TestSerialization(t *testing.T) { | |
- a | ||
- b | ||
on_conflict: insert_before | ||
- fix_stream: {} | ||
` | ||
|
||
t.Run("serialize_rules", func(t *testing.T) { | ||
|
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.
double entry?
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.
no i'm just fixing format of previous one