Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Healthcheck tests for metrics susbsystem endpoints #376

Merged
merged 2 commits into from
Feb 9, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 32 additions & 10 deletions run/core/healthcheck/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,16 @@ import (
)

const (
pass = "PASS" // Indicate that a test passed
fail = "FAIL" // Indicate that a test failed
livenessPath = "/minio/health/live"
readinessPath = "/minio/health/ready"
prometheusPath = "/minio/prometheus/metrics"
prometheusPathV2 = "/minio/v2/metrics/cluster"
timeout = time.Duration(30 * time.Second)
pass = "PASS" // Indicate that a test passed
fail = "FAIL" // Indicate that a test failed
livenessPath = "/minio/health/live"
readinessPath = "/minio/health/ready"
prometheusPath = "/minio/prometheus/metrics"
prometheusPathV2Cluster = "/minio/v2/metrics/cluster"
prometheusPathV2Node = "/minio/v2/metrics/node"
prometheusPathV2Bucket = "/minio/v2/metrics/bucket"
prometheusPathV2Resource = "/minio/v2/metrics/resource"
timeout = time.Duration(30 * time.Second)
)

type mintJSONFormatter struct{}
Expand Down Expand Up @@ -200,11 +203,11 @@ func testPrometheusEndpoint(endpoint string) {
defer successLogger(function, nil, startTime).Info()
}

func testPrometheusEndpointV2(endpoint string) {
func testPrometheusEndpointV2(endpoint string, metricsPath string) {
startTime := time.Now()
function := "testPrometheusEndpoint"

u, err := url.Parse(fmt.Sprintf("%s%s", endpoint, prometheusPathV2))
u, err := url.Parse(fmt.Sprintf("%s%s", endpoint, metricsPath))
if err != nil {
// Could not parse URL successfully
failureLog(function, nil, startTime, "", "URL Parsing for Healthcheck Prometheus handler failed", err).Fatal()
Expand Down Expand Up @@ -247,6 +250,22 @@ func testPrometheusEndpointV2(endpoint string) {
defer successLogger(function, nil, startTime).Info()
}

func testClusterPrometheusEndpointV2(endpoint string) {
testPrometheusEndpointV2(endpoint, prometheusPathV2Cluster)
}

func testNodePrometheusEndpointV2(endpoint string) {
testPrometheusEndpointV2(endpoint, prometheusPathV2Node)
}

func testBucketPrometheusEndpointV2(endpoint string) {
testPrometheusEndpointV2(endpoint, prometheusPathV2Bucket)
}

func testResourcePrometheusEndpointV2(endpoint string) {
testPrometheusEndpointV2(endpoint, prometheusPathV2Resource)
}

func main() {
endpoint := os.Getenv("SERVER_ENDPOINT")
secure := os.Getenv("ENABLE_HTTPS")
Expand All @@ -268,5 +287,8 @@ func main() {
testLivenessEndpoint(endpoint)
testReadinessEndpoint(endpoint)
testPrometheusEndpoint(endpoint)
testPrometheusEndpointV2(endpoint)
testClusterPrometheusEndpointV2(endpoint)
testNodePrometheusEndpointV2(endpoint)
testBucketPrometheusEndpointV2(endpoint)
testResourcePrometheusEndpointV2(endpoint)
}
Loading