Skip to content

Commit

Permalink
Add basic test case for #707
Browse files Browse the repository at this point in the history
  • Loading branch information
jacksontj committed Feb 6, 2025
1 parent 1e7aec2 commit 8c64be6
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 12 deletions.
6 changes: 0 additions & 6 deletions cmd/promxy/demo_robust.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ global:
external_labels:
source: promxy

# Rule files specifies a list of globs. Rules and alerts are read from
# all matching files.
rule_files:
- "*rule"


##
### Promxy configuration
##
Expand Down
14 changes: 8 additions & 6 deletions pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ func NewApacheLoggingHandler(handler http.Handler, logHandlers ...LogRecordHandl
}

func (h *ApacheLoggingHandler) runHandler(rw http.ResponseWriter, r *http.Request) (err error) {
defer func() {
if rec := recover(); rec != nil {
// Just return a stack trace always
err = errors.Wrap(errors.New(string(debug.Stack())), "Error running handler")
}
}()
if false {
defer func() {
if rec := recover(); rec != nil {
// Just return a stack trace always
err = errors.Wrap(errors.New(string(debug.Stack())), "Error running handler")
}
}()
}
h.handler.ServeHTTP(rw, r)
return
}
Expand Down
35 changes: 35 additions & 0 deletions pkg/promclient/iterators_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package promclient

import (
"strconv"
"testing"

"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/model/labels"
)

func TestIterators(t *testing.T) {
tests := []struct {
val interface{} // value
labels labels.Labels
}{
{
val: &model.Scalar{
Value: 0,
Timestamp: 0,
},
},
}

for i, test := range tests {
t.Run(strconv.Itoa(i), func(t *testing.T) {
it := NewSeriesIterator(test.val)

labels := it.Labels()
if labels.String() != test.labels.String() {
t.Fatalf("Mismatch in labels expected=%+v actual=%+v", test.labels, labels)
}
})
}

}

0 comments on commit 8c64be6

Please sign in to comment.