-
Notifications
You must be signed in to change notification settings - Fork 151
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[INTERNAL] Add test for rule/target renderers #534
- Loading branch information
Showing
8 changed files
with
78 additions
and
6 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
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
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
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,11 @@ | ||
groups: | ||
- name: promgen.example.com | ||
rules: | ||
- alert: example-rule | ||
annotations: | ||
rule: http://promgen.example.com/rule/1 | ||
summary: Example rule summary | ||
expr: up==1 | ||
for: 1s | ||
labels: | ||
severity: high |
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,16 @@ | ||
[ | ||
{ | ||
"labels": { | ||
"__farm_source": "promgen", | ||
"__scheme__": "http", | ||
"__shard": "test-shard", | ||
"farm": "test-farm", | ||
"job": "node", | ||
"project": "test-project", | ||
"service": "test-service" | ||
}, | ||
"targets": [ | ||
"example.com:9100" | ||
] | ||
} | ||
] |
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
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,25 @@ | ||
# Copyright (c) 2024 LINE Corporation | ||
# These sources are released under the terms of the MIT license: see LICENSE | ||
|
||
from django.urls import reverse | ||
from yaml import safe_load | ||
|
||
from promgen import tests | ||
|
||
|
||
class RendererTests(tests.PromgenTest): | ||
fixtures = ["testcases.yaml", "extras.yaml"] | ||
|
||
def test_global_rule(self): | ||
expected = tests.Data("examples", "export.rule.yml").yaml() | ||
response = self.client.get(reverse("api:all-rules")) | ||
self.assertEqual(response.status_code, 200) | ||
# The test client does not have a shortcut to decode yaml | ||
data = safe_load(response.content) | ||
self.assertEqual(data, expected) | ||
|
||
def test_global_targets(self): | ||
expected = tests.Data("examples", "export.targets.json").json() | ||
response = self.client.get(reverse("api:all-targets")) | ||
self.assertEqual(response.status_code, 200) | ||
self.assertEqual(response.json(), expected) |
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