-
Notifications
You must be signed in to change notification settings - Fork 175
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
185 additions
and
0 deletions.
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package after_resolution | ||
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(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(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,24 @@ | ||
package after_resolution | ||
import future.keywords | ||
|
||
test_fails_on_experimental_not_opt_in_attribute_in_stable_group if { | ||
count(deny) == 1 with input as {"groups": [{ "id": "span.foo", | ||
"type": "span", | ||
"stability": "stable", | ||
"attributes": [{ | ||
"name": "test.experimental", | ||
"stability": "experimental", | ||
"requirement_level": "required" | ||
}]}]} | ||
} | ||
|
||
test_passes_on_experimental_opt_in_attribute_in_stable_group if { | ||
count(deny) == 0 with input as {"groups": [{ "id": "span.foo", | ||
"type": "span", | ||
"stability": "stable", | ||
"attributes": [{ | ||
"name": "test.experimental", | ||
"stability": "experimental", | ||
"requirement_level": "opt_in" | ||
}]}]} | ||
} |
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,142 @@ | ||
package before_resolution | ||
|
||
import future.keywords | ||
|
||
test_fails_on_invalid_attribute_name if { | ||
every name in invalid_names { | ||
count(deny) >= 1 with input as {"groups": create_attribute_group(name)} | ||
} | ||
} | ||
|
||
test_fails_on_attribute_name_without_namespace if { | ||
count(deny) >= 1 with input as {"groups": create_attribute_group("foo")} | ||
} | ||
|
||
test_fails_on_invalid_metric_name if { | ||
every name in invalid_names { | ||
count(deny) >= 1 with input as {"groups": create_metric(name)} | ||
} | ||
} | ||
|
||
test_fails_on_invalid_metric_id if { | ||
invalid_ids := [ | ||
"foo.bar", | ||
"metric..foo.bar", | ||
"metric.123", | ||
"metric.foo.bar.deprecated", | ||
] | ||
every id in invalid_ids { | ||
count(deny) >= 1 with input as {"groups": [{"id": id, "type": "metric", "metric_name": "foo.bar"}]} | ||
} | ||
} | ||
|
||
test_fails_on_invalid_event_name if { | ||
every name in invalid_names { | ||
count(deny) >= 1 with input as {"groups": create_event(name)} | ||
} | ||
} | ||
|
||
test_fails_on_invalid_event_id if { | ||
invalid_ids := [ | ||
"foo.bar", | ||
"event..foo.bar", | ||
"event.123", | ||
"evnt.foo.bar.deprecated", | ||
] | ||
every id in invalid_ids { | ||
count(deny) >= 1 with input as {"groups": [{"id": id, "type": "event", "name": "foo.bar"}]} | ||
} | ||
} | ||
|
||
test_fails_on_referenced_event_name_on_event if { | ||
event := [{ "id": "event.foo", | ||
"type": "event", | ||
"name": "foo", | ||
"attributes": [{"ref": "event.name"}]}] | ||
count(deny) == 1 with input as {"groups": event} | ||
} | ||
|
||
test_fails_on_invalid_resource_name if { | ||
every name in invalid_names { | ||
count(deny) >= 1 with input as {"groups": create_resource(name)} | ||
} | ||
} | ||
|
||
test_fails_on_missing_resource_name if { | ||
count(deny) >= 1 with input as {"groups": [{"id": "resource.", "type": "resource", "name": null}]} | ||
} | ||
|
||
test_passes_on_valid_names if { | ||
every name in valid_names { | ||
count(deny) == 0 with input as {"groups": create_attribute_group(name)} | ||
count(deny) == 0 with input as {"groups": create_metric(name)} | ||
count(deny) == 0 with input as {"groups": create_event(name)} | ||
} | ||
} | ||
|
||
test_fails_if_prefix_is_present if { | ||
count(deny) == 1 with input as {"groups": [{"id": "test", "prefix": "foo"}]} | ||
} | ||
|
||
test_fails_on_invalid_span_id if { | ||
invalid_ids := [ | ||
"foo.bar", | ||
"span.foo.bar", | ||
"span.foo.bar.client.deprecated", | ||
] | ||
every id in invalid_ids { | ||
count(deny) >= 1 with input as {"groups": [{"id": id, "type": "span", "span_kind": "client"}]} | ||
} | ||
} | ||
|
||
test_fails_on_invalid_resource_id if { | ||
invalid_ids := [ | ||
"foo.bar", | ||
"resource..foo.bar", | ||
"resource.foo.bar.deprecated", | ||
] | ||
every id in invalid_ids { | ||
count(deny) >= 1 with input as {"groups": [{"id": id, "type": "resource", "name": "foo.bar"}]} | ||
} | ||
} | ||
|
||
create_attribute_group(attr) = json { | ||
json := [{"id": "yaml_schema.test", "attributes": [{"id": attr}]}] | ||
} | ||
|
||
create_metric(name) = json { | ||
id := sprintf("metric.%s", [name]) | ||
json := [{"id": id, "type": "metric", "metric_name": name}] | ||
} | ||
|
||
create_event(name) = json { | ||
id := sprintf("event.%s", [name]) | ||
json := [{"id": id, "type": "event", "name": name}] | ||
} | ||
|
||
create_resource(name) = json { | ||
id := sprintf("resource.%s", [name]) | ||
json := [{"id": id, "type": "resource", "name": name}] | ||
} | ||
|
||
invalid_names := [ | ||
"1foo.bar", | ||
"_foo.bar", | ||
".foo.bar", | ||
"foo.bar_", | ||
"foo.bar.", | ||
"foo..bar", | ||
"foo._bar", | ||
"foo.bar__baz", | ||
"foo_.bar", | ||
"foo.bar,baz", | ||
"fü.bär", | ||
] | ||
|
||
valid_names := [ | ||
"foo.bar", | ||
"foo.1bar", | ||
"foo_1.bar", | ||
"foo.bar.baz", | ||
"foo.bar_baz", | ||
] |