Skip to content

Commit

Permalink
Merge pull request #1122 from cloudflare/unary
Browse files Browse the repository at this point in the history
Add unary to parse
  • Loading branch information
prymitive authored Sep 30, 2024
2 parents 2a5d28e + 56d40cc commit e801589
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 28 deletions.
6 changes: 6 additions & 0 deletions cmd/pint/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ func parseNode(node parser.Node, level int) {
printNode(level, "StringLiteral:")
level += levelStep
printNode(level, "* Type: %v", n.Type())
case *parser.UnaryExpr:
printNode(level, "UnaryExpr:")
level += levelStep
printNode(level, "* Type: %v", n.Type())
printNode(level, "* Op: %v", n.Op)
printNode(level, "* Expr: %v", n.Expr)
default:
printNode(level, "! Unsupported node")
}
Expand Down
29 changes: 1 addition & 28 deletions cmd/pint/tests/0170_watch_rule_files_error.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,16 @@ http start prometheus 127.0.0.1:7170

exec bash -x ./test.sh &

exec pint --no-color -l debug watch --interval=5s --listen=127.0.0.1:6170 --pidfile=pint.pid rule_files prom
exec pint --no-color -l error watch --interval=5s --listen=127.0.0.1:6170 --pidfile=pint.pid rule_files prom
cmp stderr stderr.txt

-- stderr.txt --
level=INFO msg="Loading configuration file" path=.pint.hcl
level=DEBUG msg="Adding pint config to the parser exclude list" path=.pint.hcl
level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[]
level=DEBUG msg="Starting query workers" name=prom uri=http://localhost:7170 workers=16
level=DEBUG msg="Starting rule_fules watch" name=prom
level=INFO msg="Pidfile created" path=pint.pid
level=INFO msg="Started HTTP server" address=127.0.0.1:6170
level=INFO msg="Configured new Prometheus server" name=prom uris=1 uptime=up tags=[] include=[] exclude=[]
level=DEBUG msg="Starting query workers" name=prom uri=http://localhost:7170 workers=16
level=INFO msg="Will continuously run checks until terminated" interval=5s
level=DEBUG msg="Running checks"
level=DEBUG msg="Scheduling Prometheus configuration query" uri=http://localhost:7170
level=DEBUG msg="Getting prometheus configuration" uri=http://localhost:7170
level=DEBUG msg="Trying to parse Prometheus error response" code=500
level=ERROR msg="Query returned an error" err= uri=http://localhost:7170 query=/api/v1/status/config
level=ERROR msg="Got an error when running checks" err="failed to get the list of paths to check: failed to query \"prom\" Prometheus configuration: unknown: "
level=DEBUG msg="Running checks"
level=DEBUG msg="Scheduling Prometheus configuration query" uri=http://localhost:7170
level=DEBUG msg="Getting prometheus configuration" uri=http://localhost:7170
level=DEBUG msg="Trying to parse Prometheus error response" code=500
level=ERROR msg="Query returned an error" err= uri=http://localhost:7170 query=/api/v1/status/config
level=ERROR msg="Got an error when running checks" err="failed to get the list of paths to check: failed to query \"prom\" Prometheus configuration: unknown: "
level=DEBUG msg="Running checks"
level=DEBUG msg="Scheduling Prometheus configuration query" uri=http://localhost:7170
level=DEBUG msg="Getting prometheus configuration" uri=http://localhost:7170
level=DEBUG msg="Trying to parse Prometheus error response" code=500
level=ERROR msg="Query returned an error" err= uri=http://localhost:7170 query=/api/v1/status/config
level=ERROR msg="Got an error when running checks" err="failed to get the list of paths to check: failed to query \"prom\" Prometheus configuration: unknown: "
level=INFO msg="Shutting down"
level=INFO msg="Waiting for all background tasks to finish"
level=INFO msg="Background worker finished"
level=DEBUG msg="Stopping query workers" name=prom uri=http://localhost:7170
level=INFO msg="Pidfile removed" path=pint.pid
-- test.sh --
sleep 7
mv more/*.yaml rules/
Expand Down
10 changes: 10 additions & 0 deletions cmd/pint/tests/0193_parse_unary.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
exec pint parse -- '-up'
cmp stdout stdout.txt
! stderr .

-- stdout.txt --
++ node: -up
UnaryExpr:
* Type: vector
* Op: -
* Expr: up

0 comments on commit e801589

Please sign in to comment.