Skip to content

Commit

Permalink
Add bigger timeout for tracing/spans and istioApi queries in integrat…
Browse files Browse the repository at this point in the history
…ion tests (#7995)
  • Loading branch information
mkralik3 authored Dec 12, 2024
1 parent 535bb39 commit 544aed6
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions tests/integration/utils/kiali/kiali_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,11 @@ type MetricsJson struct {
var client = *NewKialiClient()

const (
BOOKINFO = "bookinfo"
ASSETS = "tests/integration/assets"
TIMEOUT = 10 * time.Second
BOOKINFO = "bookinfo"
ASSETS = "tests/integration/assets"
TIMEOUT = 10 * time.Second
TIMEOUT_MEDIUM = 20 * time.Second
TIMEOUT_TRACING = 60 * time.Second
)

func NewKialiClient() (c *KialiClient) {
Expand Down Expand Up @@ -268,7 +270,7 @@ func Traces(objectType, name, namespace string) (*model.TracingResponse, int, er
url := fmt.Sprintf("%s/api/namespaces/%s/%s/%s/traces?startMicros=%d&tags=&limit=100", client.kialiURL, namespace, objectType, name, TimeSince())
traces := new(model.TracingResponse)

code, err := getRequestAndUnmarshalInto(url, traces)
code, err := getRequestAndUnmarshalIntoWithCustomTimeout(url, TIMEOUT_TRACING, traces)
if err == nil {
return traces, code, nil
} else {
Expand All @@ -280,7 +282,7 @@ func Spans(objectType, name, namespace string) ([]model.TracingSpan, int, error)
url := fmt.Sprintf("%s/api/namespaces/%s/%s/%s/spans?startMicros=%d&tags=&limit=100", client.kialiURL, namespace, objectType, name, TimeSince())
spans := new([]model.TracingSpan)

code, err := getRequestAndUnmarshalInto(url, spans)
code, err := getRequestAndUnmarshalIntoWithCustomTimeout(url, TIMEOUT_TRACING, spans)
if err == nil {
return *spans, code, nil
} else {
Expand Down Expand Up @@ -504,7 +506,11 @@ func Grafana() (*models.GrafanaInfo, int, error) {
}

func getRequestAndUnmarshalInto[T any](url string, response *T) (int, error) {
body, code, _, err := httpGETWithRetry(url, client.GetAuth(), TIMEOUT, nil, nil)
return getRequestAndUnmarshalIntoWithCustomTimeout(url, TIMEOUT, response)
}

func getRequestAndUnmarshalIntoWithCustomTimeout[T any](url string, timeout time.Duration, response *T) (int, error) {
body, code, _, err := httpGETWithRetry(url, client.GetAuth(), timeout, nil, nil)
if err != nil {
return code, err
}
Expand Down Expand Up @@ -536,7 +542,7 @@ func IstioApiEnabled() (bool, error) {
url := fmt.Sprintf("%s/api/status", client.kialiURL)
status := new(status.StatusInfo)

_, err := getRequestAndUnmarshalInto(url, status)
_, err := getRequestAndUnmarshalIntoWithCustomTimeout(url, TIMEOUT_MEDIUM, status)
if err == nil {
return status.IstioEnvironment.IstioAPIEnabled, nil
} else {
Expand Down

0 comments on commit 544aed6

Please sign in to comment.