From 83cf119c2a1b08eea1865d86bda655bac9c3b85c Mon Sep 17 00:00:00 2001 From: Thuan Vo Date: Wed, 3 Jul 2024 23:15:29 -0700 Subject: [PATCH] test(scorecard): increase nginx proxy size limit --- internal/test/scorecard/clients.go | 6 +++--- internal/test/scorecard/common_utils.go | 1 + internal/test/scorecard/tests.go | 4 ++-- internal/test/scorecard/types.go | 13 ++++++------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/test/scorecard/clients.go b/internal/test/scorecard/clients.go index 3e8e513a..108394d3 100644 --- a/internal/test/scorecard/clients.go +++ b/internal/test/scorecard/clients.go @@ -236,7 +236,7 @@ func NewCryostatRESTClientset(base *url.URL) *CryostatRESTClientset { }, GrafanaClient: &GrafanaClient{ commonCryostatRESTClient: commonClient, - Prefix: "grafana", + BasePath: "grafana", }, } } @@ -598,12 +598,12 @@ func (client *CredentialClient) Create(ctx context.Context, credential *Credenti // Client for Grafana API type GrafanaClient struct { - Prefix string + BasePath string *commonCryostatRESTClient } func (client *GrafanaClient) GetDatasourceByName(ctx context.Context, name string) (*DataSource, error) { - url := client.Base.JoinPath(client.Prefix, "api/datasources/name", GRAFANA_DATASOURCE_NAME) + url := client.Base.JoinPath(client.BasePath, "api/datasources/name", GRAFANA_DATASOURCE_NAME) header := make(http.Header) header.Add("Accept", "*/*") diff --git a/internal/test/scorecard/common_utils.go b/internal/test/scorecard/common_utils.go index 7cd60bb2..f223c77f 100644 --- a/internal/test/scorecard/common_utils.go +++ b/internal/test/scorecard/common_utils.go @@ -299,6 +299,7 @@ func configureIngress(name string, cryostatSpec *operatorv1beta2.CryostatSpec) { CoreConfig: &operatorv1beta2.NetworkConfiguration{ Annotations: map[string]string{ "nginx.ingress.kubernetes.io/backend-protocol": "HTTPS", + "nginx.ingress.kubernetes.io/proxy-body-size": "10m", }, IngressSpec: &netv1.IngressSpec{ TLS: []netv1.IngressTLS{{}}, diff --git a/internal/test/scorecard/tests.go b/internal/test/scorecard/tests.go index cf011c0c..ad6c986e 100644 --- a/internal/test/scorecard/tests.go +++ b/internal/test/scorecard/tests.go @@ -23,7 +23,7 @@ import ( operatorv1beta2 "github.com/cryostatio/cryostat-operator/api/v1beta2" scapiv1alpha3 "github.com/operator-framework/api/pkg/apis/scorecard/v1alpha3" apimanifests "github.com/operator-framework/api/pkg/manifests" - v1 "k8s.io/apimachinery/pkg/apis/meta/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( @@ -341,7 +341,7 @@ func CryostatGrafanaTest(bundle *apimanifests.Bundle, namespace string, openShif apiClient := NewCryostatRESTClientset(base) // Get JFR data - cm, err := r.Client.CoreV1().ConfigMaps(namespace).Get(context.Background(), jfrConfigMapName, v1.GetOptions{}) + cm, err := r.Client.CoreV1().ConfigMaps(namespace).Get(context.Background(), jfrConfigMapName, metav1.GetOptions{}) if err != nil { return r.fail(fmt.Sprintf("failed to get ConfigMap containing JFR data: %s", err.Error())) } diff --git a/internal/test/scorecard/types.go b/internal/test/scorecard/types.go index 42b65ae1..e8b9cf72 100644 --- a/internal/test/scorecard/types.go +++ b/internal/test/scorecard/types.go @@ -155,13 +155,14 @@ type ArchiveGraphQLResponse struct { } const ( + GRAFANA_DASHBOARD_UID = "main" + GRAFANA_DASHBOARD_TITLE = "Cryostat Dashboard" GRAFANA_DATASOURCE_NAME = "jfr-datasource" - GRAFANA_DATASOURCE_URL = "http://127.0.0.1:8989" GRAFANA_DATASOURCE_TYPE = "grafana-simple-json-datasource" GRAFANA_DATASOURCE_ACCESS = "proxy" ) -// Grafana types +// DataSource represents a Grafana data source type DataSource struct { ID int64 `json:"id"` UID string `json:"uid"` @@ -172,8 +173,6 @@ type DataSource struct { URL string `json:"url"` Access string `json:"access"` - ReadOnly bool `json:"readOnly"` - IsDefault bool `json:"isDefault"` BasicAuth bool `json:"basicAuth"` } @@ -186,12 +185,12 @@ func (ds *DataSource) Valid() error { return fmt.Errorf("expected datasource type %s, but got %s", GRAFANA_DATASOURCE_TYPE, ds.Type) } - if ds.URL != GRAFANA_DATASOURCE_URL { - return fmt.Errorf("expected datasource url %s, but got %s", GRAFANA_DATASOURCE_URL, ds.URL) + if len(ds.URL) == 0 { + return errors.New("expected datasource url, but got empty") } if ds.Access != GRAFANA_DATASOURCE_ACCESS { - return fmt.Errorf("expected datasource access %s, but got %s", GRAFANA_DATASOURCE_ACCESS, ds.Access) + return fmt.Errorf("expected datasource access mode %s, but got %s", GRAFANA_DATASOURCE_ACCESS, ds.Access) } if ds.BasicAuth {