mirror of
https://github.com/coreos/prometheus-operator.git
synced 2026-02-05 06:45:27 +01:00
chore: refactor shared functions in pkg/prometeus
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
@@ -66,6 +66,7 @@ func (f *Framework) NewTestCtx(t *testing.T) *TestCtx {
|
||||
tc.collectAlertmanagers(b, f)
|
||||
tc.collectPrometheuses(b, f)
|
||||
tc.collectThanosRulers(b, f)
|
||||
tc.collectPrometheusAgents(b, f)
|
||||
tc.collectLogs(b, f)
|
||||
tc.collectEvents(b, f)
|
||||
|
||||
@@ -154,6 +155,21 @@ func (ctx *TestCtx) collectPrometheuses(w io.Writer, f *Framework) {
|
||||
}
|
||||
}
|
||||
|
||||
func (ctx *TestCtx) collectPrometheusAgents(w io.Writer, f *Framework) {
|
||||
fmt.Fprintln(w, "=== PrometheusAgents")
|
||||
for _, ns := range ctx.namespaces {
|
||||
ps, err := f.MonClientV1alpha1.PrometheusAgents(ns).List(context.Background(), metav1.ListOptions{})
|
||||
if err != nil {
|
||||
fmt.Fprintf(w, "%s: failed to get prometheusagents: %v\n", ns, err)
|
||||
continue
|
||||
}
|
||||
|
||||
for _, p := range ps.Items {
|
||||
collectConditions(w, fmt.Sprintf("PrometheusAgent=%s/%s", p.Namespace, p.Name), p.Status.Conditions)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (ctx *TestCtx) collectThanosRulers(w io.Writer, f *Framework) {
|
||||
fmt.Fprintln(w, "=== ThanosRulers")
|
||||
for _, ns := range ctx.namespaces {
|
||||
|
||||
@@ -71,6 +71,7 @@ func (f *Framework) WritePodLogs(ctx context.Context, w io.Writer, ns, pod strin
|
||||
|
||||
fmt.Fprintf(w, "=== Logs (pod=%s/%s container=%s)\n", ns, pod, c)
|
||||
_, err = w.Write(resp)
|
||||
fmt.Fprint(w, "\n")
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write logs: %w", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user