-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
86 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
change_type: enhancement | ||
component: docs | ||
note: Add note on tooling limitations for attribute names and enforce attribute name format and uniqueness. | ||
note: Add note on tooling limitations for attribute names and enforce name format. | ||
issues: [1124] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package attribute_name_collisions_test | ||
|
||
import data.attribute_name_collisions | ||
import future.keywords | ||
|
||
test_fails_on_const_name_collision if { | ||
collision := {"groups": [ | ||
{"id": "test1", "attributes": [{"name": "foo.bar.baz"}]}, | ||
{"id": "test2", "attributes": [{"name": "foo.bar_baz"}]} | ||
]} | ||
# each attribute counts as a collision, so there are 2 collisions | ||
count(attribute_name_collisions.deny) == 2 with input as collision | ||
} | ||
|
||
test_fails_on_namespace_collision if { | ||
collision := {"groups": [ | ||
{"id": "test1", "attributes": [{"name": "foo.bar.baz"}]}, | ||
{"id": "test2", "attributes": [{"name": "foo.bar"}]} | ||
]} | ||
count(attribute_name_collisions.deny) == 1 with input as collision | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package yaml_schema_test | ||
|
||
import data.yaml_schema | ||
import future.keywords | ||
|
||
test_fails_on_invalid_attribute_name if { | ||
every name in invalid_names { | ||
count(yaml_schema.deny) == 1 with input as {"groups": create_attribute_group(name)} | ||
} | ||
} | ||
|
||
test_fails_on_invalid_metric_name if { | ||
every name in invalid_names { | ||
count(yaml_schema.deny) == 1 with input as {"groups": create_metric(name)} | ||
} | ||
} | ||
|
||
test_fails_on_invalid_event_name if { | ||
every name in invalid_names { | ||
count(yaml_schema.deny) == 1 with input as {"groups": create_event(name)} | ||
} | ||
} | ||
|
||
test_passes_on_valid_names if { | ||
every name in valid_names { | ||
count(yaml_schema.deny) == 0 with input as {"groups": create_attribute_group(name)} | ||
count(yaml_schema.deny) == 0 with input as {"groups": create_metric(name)} | ||
count(yaml_schema.deny) == 0 with input as {"groups": create_event(name)} | ||
} | ||
} | ||
|
||
create_attribute_group(attr) = json { | ||
json := [{"id": "yaml_schema.test", "attributes": [{"id": attr}]}] | ||
} | ||
|
||
create_metric(name) = json { | ||
json := [{"id": "yaml_schema.test", "type": "metric", "metric_name": name}] | ||
} | ||
|
||
create_event(name) = json { | ||
json := [{"id": "yaml_schema.test", "type": "event", "name": name}] | ||
} | ||
|
||
invalid_names := [ | ||
"1foo.bar", | ||
"_foo.bar", | ||
".foo.bar", | ||
"foo.bar_", | ||
"foo.bar.", | ||
"foo..bar", | ||
"foo._bar", | ||
"foo__bar", | ||
"foo_.bar", | ||
"foo,bar", | ||
"fü.bär", | ||
] | ||
|
||
valid_names := [ | ||
"foo.bar", | ||
"foo.1bar", | ||
"foo_1.bar", | ||
"foo.bar.baz", | ||
"foo.bar_baz", | ||
] |