diff --git a/tests/fixture/tmpnet/check_monitoring.go b/tests/fixture/tmpnet/check_monitoring.go index 3aa11ec93996..d68aff086ecd 100644 --- a/tests/fixture/tmpnet/check_monitoring.go +++ b/tests/fixture/tmpnet/check_monitoring.go @@ -26,6 +26,7 @@ import ( type getCountFunc func() (int, error) +// waitForCount waits until the provided function returns greater than zero. func waitForCount(ctx context.Context, log logging.Logger, name string, getCount getCountFunc) error { if err := pollUntilContextCancel(ctx, func(_ context.Context) (bool, error) { count, err := getCount() @@ -54,11 +55,14 @@ func CheckLogsExist(ctx context.Context, log logging.Logger, networkUUID string) if err != nil { return fmt.Errorf("failed to get collector credentials: %w", err) } - query, err := getCheckLogsQuery(networkUUID) + + url := getLokiURL() + + selectors, err := getSelectors(networkUUID) if err != nil { return err } - url := getLokiURL() + query := fmt.Sprintf("sum(count_over_time({%s}[1h]))", selectors) log.Info("checking if logs exist", zap.String("url", url), @@ -70,15 +74,6 @@ func CheckLogsExist(ctx context.Context, log logging.Logger, networkUUID string) }) } -// getCheckLogsQuery returns the query to check if logs exist. -func getCheckLogsQuery(networkUUID string) (string, error) { - selectors, err := getSelectors(networkUUID) - if err != nil { - return "", err - } - return fmt.Sprintf("sum(count_over_time({%s}[1h]))", selectors), nil -} - func queryLoki( ctx context.Context, lokiURL string, @@ -159,11 +154,14 @@ func CheckMetricsExist(ctx context.Context, log logging.Logger, networkUUID stri if err != nil { return fmt.Errorf("failed to get collector credentials: %w", err) } - query, err := getCheckMetricsQuery(networkUUID) + + url := getPrometheusURL() + + selectors, err := getSelectors(networkUUID) if err != nil { return err } - url := getPrometheusURL() + query := fmt.Sprintf("count({%s})", selectors) log.Info("checking if metrics exist", zap.String("url", url), @@ -175,15 +173,6 @@ func CheckMetricsExist(ctx context.Context, log logging.Logger, networkUUID stri }) } -// getCheckMetricsQuery returns the query to check if metrics exist. -func getCheckMetricsQuery(networkUUID string) (string, error) { - selectors, err := getSelectors(networkUUID) - if err != nil { - return "", err - } - return fmt.Sprintf("count({%s})", selectors), nil -} - func queryPrometheus( ctx context.Context, log logging.Logger,