forked from cloudflare/pint
-
Notifications
You must be signed in to change notification settings - Fork 0
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
26 changed files
with
479 additions
and
71 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
File renamed without changes.
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,107 @@ | ||
http response prometheus1m /api/v1/status/flags 200 {"status":"success","data":{"--storage.tsdb.retention.time": "1d"}} | ||
http response prometheus1m /api/v1/metadata 200 {"status":"success","data":{}} | ||
http response prometheus1m /api/v1/status/config 200 {"status":"success","data":{"yaml":"global:\n scrape_interval: 1m\n"}} | ||
http response prometheus1m /api/v1/query_range 200 {"status":"success","data":{"resultType":"matrix","result":[]}} | ||
http response prometheus1m /api/v1/query 200 {"status":"success","data":{"resultType":"vector","result":[]}} | ||
http start prometheus1m 127.0.0.1:1094 | ||
|
||
http response prometheus5m /api/v1/status/flags 200 {"status":"success","data":{"--storage.tsdb.retention.time": "1d"}} | ||
http response prometheus5m /api/v1/metadata 200 {"status":"success","data":{}} | ||
http response prometheus5m /api/v1/status/config 200 {"status":"success","data":{"yaml":"global:\n scrape_interval: 5m\n"}} | ||
http response prometheus5m /api/v1/query_range 200 {"status":"success","data":{"resultType":"matrix","result":[]}} | ||
http response prometheus5m /api/v1/query 200 {"status":"success","data":{"resultType":"vector","result":[]}} | ||
http start prometheus5m 127.0.0.1:2094 | ||
|
||
http response bitbucket / 200 OK | ||
http start bitbucket 127.0.0.1:6094 | ||
|
||
mkdir testrepo | ||
cd testrepo | ||
exec git init --initial-branch=main . | ||
|
||
cp ../src/v1.yml rules.yml | ||
exec ln -s rules.yml symlink.yml | ||
exec ln -s symlink.yml double.yml | ||
cp ../src/.pint.hcl . | ||
env GIT_AUTHOR_NAME=pint | ||
env GIT_AUTHOR_EMAIL=pint@example.com | ||
env GIT_COMMITTER_NAME=pint | ||
env GIT_COMMITTER_EMAIL=pint@example.com | ||
exec git add . | ||
exec git commit -am 'import rules and config' | ||
|
||
exec git checkout -b v2 | ||
cp ../src/v2.yml rules.yml | ||
exec git commit -am 'v2' | ||
|
||
env BITBUCKET_AUTH_TOKEN="12345" | ||
pint.error -l debug -d promql/series --no-color ci | ||
! stdout . | ||
|
||
stderr 'path=rules.yml rule=rule1' | ||
stderr 'path=rules.yml rule=rule2' | ||
stderr 'path=symlink.yml rule=rule1' | ||
stderr 'path=symlink.yml rule=rule2' | ||
stderr 'path=double.yml rule=rule1' | ||
stderr 'path=double.yml rule=rule2' | ||
|
||
stderr 'level=info msg="Problems found" Bug=4' | ||
stderr 'result\\":\\"FAIL\\"' | ||
|
||
! stderr '^rules.yml:5: duration for rate' | ||
! stderr '^rules.yml:7: duration for rate' | ||
stderr 'symlink.yml ~> rules.yml:5: duration for rate' | ||
stderr 'symlink.yml ~> rules.yml:7: duration for rate' | ||
stderr 'double.yml ~> rules.yml:5: duration for rate' | ||
stderr 'double.yml ~> rules.yml:7: duration for rate' | ||
|
||
stderr '{\\"path\\":\\"rules.yml\\",\\"line\\":5,' | ||
stderr '{\\"path\\":\\"rules.yml\\",\\"line\\":7,' | ||
! stderr '{\\"path\\":\\"symlink.yml\\"' | ||
! stderr '{\\"path\\":\\"double.yml\\"' | ||
|
||
stderr 'Problem detected on symlinked file symlink.yml:' | ||
stderr 'Problem detected on symlinked file double.yml:' | ||
|
||
-- src/v1.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: rule1 | ||
expr: rate(errors_total[5m]) > 0 | ||
- alert: rule2 | ||
expr: rate(errors_total[5m]) > 0 | ||
|
||
-- src/v2.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: rule1 | ||
expr: rate(errors_total[2m]) > 0 | ||
- alert: rule2 | ||
expr: rate(errors_total[2m]) > 0 | ||
|
||
-- src/.pint.hcl -- | ||
ci { | ||
baseBranch = "main" | ||
} | ||
repository { | ||
bitbucket { | ||
uri = "http://127.0.0.1:6094" | ||
timeout = "10s" | ||
project = "prometheus" | ||
repository = "rules" | ||
} | ||
} | ||
prometheus "1m" { | ||
uri = "http://127.0.0.1:1094" | ||
timeout = "5s" | ||
required = true | ||
include = ["rules.yml"] | ||
} | ||
prometheus "5m" { | ||
uri = "http://127.0.0.1:2094" | ||
timeout = "5s" | ||
required = true | ||
include = ["symlink.yml", "double.yml"] | ||
} |
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 @@ | ||
mkdir rules/strict | ||
exec ln -s ../relaxed/1.yml rules/strict/symlink.yml | ||
|
||
pint.ok -l debug --no-color lint rules | ||
! stdout . | ||
cmp stderr stderr.txt | ||
|
||
-- stderr.txt -- | ||
level=info msg="Loading configuration file" path=.pint.hcl | ||
level=debug msg="File parsed" path=rules/relaxed/1.yml rules=1 | ||
level=debug msg="Found recording rule" lines=1-2 path=rules/relaxed/1.yml record=foo | ||
level=debug msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/relaxed/1.yml rule=foo | ||
level=debug msg="Found recording rule" lines=1-2 path=rules/strict/symlink.yml record=foo | ||
level=debug msg="Configured checks for rule" enabled=["promql/syntax","alerts/for","alerts/comparison","alerts/template","promql/fragile","promql/regexp"] path=rules/strict/symlink.yml rule=foo | ||
-- rules/relaxed/1.yml -- | ||
- record: foo | ||
expr: up == 0 | ||
-- .pint.hcl -- | ||
parser { | ||
relaxed = ["rules/relaxed/.*"] | ||
} |
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,9 @@ | ||
mkdir rules | ||
exec ln -s ../bad.yml rules/symlink.yml | ||
|
||
pint.error -l debug --no-color lint rules | ||
! stdout . | ||
cmp stderr stderr.txt | ||
|
||
-- stderr.txt -- | ||
level=fatal msg="Fatal error" error="lstat rules/../bad.yml: no such file or directory" |
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,45 @@ | ||
mkdir testrepo | ||
cd testrepo | ||
exec git init --initial-branch=main . | ||
|
||
cp ../src/v1.yml rules.yml | ||
exec ln -s xxx.yml symlink.yml | ||
cp ../src/.pint.hcl . | ||
env GIT_AUTHOR_NAME=pint | ||
env GIT_AUTHOR_EMAIL=pint@example.com | ||
env GIT_COMMITTER_NAME=pint | ||
env GIT_COMMITTER_EMAIL=pint@example.com | ||
exec git add . | ||
exec git commit -am 'import rules and config' | ||
|
||
exec git checkout -b v2 | ||
cp ../src/v2.yml rules.yml | ||
exec git commit -am 'v2' | ||
|
||
pint.error -l debug -d promql/series --no-color ci | ||
! stdout . | ||
stderr 'level=fatal msg="Fatal error" error="symlink.yml is a symlink but target file cannot be evaluated: lstat xxx.yml: no such file or directory"' | ||
|
||
-- src/v1.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: rule1 | ||
expr: rate(errors_total[5m]) > 0 | ||
- alert: rule2 | ||
expr: rate(errors_total[5m]) > 0 | ||
|
||
-- src/v2.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: rule1 | ||
expr: rate(errors_total[2m]) > 0 | ||
- alert: rule2 | ||
expr: rate(errors_total[2m]) > 0 | ||
|
||
-- src/.pint.hcl -- | ||
ci { | ||
baseBranch = "main" | ||
} | ||
|
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,57 @@ | ||
http response github / 200 {} | ||
http start github 127.0.0.1:6098 | ||
|
||
mkdir testrepo | ||
cd testrepo | ||
exec git init --initial-branch=main . | ||
|
||
cp ../src/v1.yml rules.yml | ||
exec ln -s rules.yml symlink.yml | ||
cp ../src/.pint.hcl . | ||
env GIT_AUTHOR_NAME=pint | ||
env GIT_AUTHOR_EMAIL=pint@example.com | ||
env GIT_COMMITTER_NAME=pint | ||
env GIT_COMMITTER_EMAIL=pint@example.com | ||
exec git add . | ||
exec git commit -am 'import rules and config' | ||
|
||
exec git checkout -b v2 | ||
cp ../src/v2.yml rules.yml | ||
exec git commit -am 'v2' | ||
|
||
env GITHUB_AUTH_TOKEN=12345 | ||
env GITHUB_PULL_REQUEST_NUMBER=1 | ||
pint.ok -l debug -d promql/series --no-color ci | ||
! stdout . | ||
stderr 'level=info msg="Report submitted" status="200 OK"' | ||
|
||
-- src/v1.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: rule1 | ||
expr: rate(errors_total[5m]) > 0 | ||
- alert: rule2 | ||
expr: rate(errors_total[5m]) > 0 | ||
|
||
-- src/v2.yml -- | ||
groups: | ||
- name: foo | ||
rules: | ||
- alert: rule1 | ||
expr: rate(errors_total[2m]) > 0 | ||
- alert: rule2 | ||
expr: rate(errors_total[2m]) | ||
|
||
-- src/.pint.hcl -- | ||
ci { | ||
baseBranch = "main" | ||
} | ||
repository { | ||
github { | ||
baseuri = "http://127.0.0.1:6098" | ||
uploaduri = "http://127.0.0.1:6098" | ||
owner = "cloudflare" | ||
repo = "pint" | ||
} | ||
} |
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
Oops, something went wrong.