-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
In the future, I would like to improve the way we handle some of the rendering, so the first step is to ensure we have some proper test cases to check for when rendering changes. Most of this is updates for test cases, but also add a minor new route as part of a future cleanup of the public api routes.
- Loading branch information
Showing
8 changed files
with
71 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,3 +57,9 @@ | |
service: 1 | ||
shard: 1 | ||
farm: 1 | ||
- model: promgen.exporter | ||
pk: 1 | ||
fields: | ||
project: 1 | ||
job: node | ||
port: 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
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