github.com/verrazzano/verrazzano@v1.7.1/tools/psr/tests/scenarios/common/metrics.go (about)

     1  // Copyright (c) 2022, Oracle and/or its affiliates.
     2  // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl.
     3  
     4  package common
     5  
     6  import (
     7  	"github.com/hashicorp/go-retryablehttp"
     8  	"github.com/verrazzano/verrazzano/tests/e2e/pkg"
     9  	"io"
    10  )
    11  
    12  // HTTPGet issues an HTTP GET request with basic auth to the specified URL. httpGet returns the HTTP status code
    13  // and an error.
    14  func HTTPGet(url string, httpClient *retryablehttp.Client, credentials *pkg.UsernamePassword) (int, error) {
    15  	req, err := retryablehttp.NewRequest("GET", url, nil)
    16  	if err != nil {
    17  		return 0, err
    18  	}
    19  	req.SetBasicAuth(credentials.Username, credentials.Password)
    20  	resp, err := httpClient.Do(req)
    21  	if err != nil {
    22  		return 0, err
    23  	}
    24  	io.ReadAll(resp.Body)
    25  	resp.Body.Close()
    26  
    27  	return resp.StatusCode, nil
    28  }
    29  
    30  func GetMetricLabels(_ string) map[string]string {
    31  	return map[string]string{
    32  		//"app_oam_dev_component": podName,
    33  		"verrazzano_cluster": "local",
    34  	}
    35  }