Skip to content

Commit

Permalink
update kiali workload health API
Browse files Browse the repository at this point in the history
  • Loading branch information
randmonkey committed Jun 11, 2024
1 parent 28567d7 commit 2aafce1
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .github/test_dependencies.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ e2e:
# For Istio, we define combinations of Kind and Istio versions that will be
# used directly in the test matrix `include` section.
istio:
- # renovate: datasource=docker depName=kindest/node versioning=docker
kind: 'v1.30.0'
# renovate: datasource=docker depName=istio/istioctl versioning=docker
istio: '1.22.1'
- # renovate: datasource=docker depName=kindest/node versioning=docker
kind: 'v1.30.0'
# renovate: datasource=docker depName=istio/istioctl versioning=docker
Expand Down
28 changes: 26 additions & 2 deletions test/e2e/istio_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ func TestIstioWithKongIngressGateway(t *testing.T) {
if resp.StatusCode != http.StatusOK {
return false
}
if health, err = getKialiWorkloadHealth(t, kialiAPIUrl, namespace.Name, workload.Name); err != nil {
if health, err = getKialiWorkloadHealthIstio1_22(t, kialiAPIUrl, namespace.Name, workload.Name); err != nil {
return false
}
inboundHTTPRequests = health.Requests.Inbound.HTTP
Expand All @@ -238,7 +238,7 @@ func TestIstioWithKongIngressGateway(t *testing.T) {
if err := verifyStatusForURL(serverErrorURL, http.StatusInternalServerError); err != nil {
return false
}
if health, err = getKialiWorkloadHealth(t, kialiAPIUrl, namespace.Name, workload.Name); err != nil {
if health, err = getKialiWorkloadHealthIstio1_22(t, kialiAPIUrl, namespace.Name, workload.Name); err != nil {
return false
}
inboundHTTPRequests = health.Requests.Inbound.HTTP
Expand Down Expand Up @@ -364,6 +364,25 @@ func getKialiWorkloadHealth(t *testing.T, kialiAPIUrl string, namespace, workloa
return &health, nil
}

func getKialiWorkloadHealthIstio1_22(t *testing.T, kialiAPIUrl string, namespace, workloadName string) (*workloadHealth, error) {
kialiWorkloadURL := fmt.Sprintf("%s/namespaces/%s/workloads/%s", kialiAPIUrl, namespace, workloadName)
resp, err := helpers.DefaultHTTPClient().Get(kialiWorkloadURL)
require.NoErrorf(t, err, "failed to call Kiali workload API %s", kialiWorkloadURL)
defer resp.Body.Close()
// verify the workload response
require.Equalf(t, http.StatusOK, resp.StatusCode, "Got code %d from Kiali workload API %s", resp.StatusCode, kialiWorkloadURL)
b, err := io.ReadAll(resp.Body)
if err != nil {
return nil, err
}
status := workloadStatus{}
err = json.Unmarshal(b, &status)
if err != nil {
return nil, err
}
return &status.Health, nil
}

// -----------------------------------------------------------------------------
// Private Testing Types - Kiali API Responses
// -----------------------------------------------------------------------------
Expand All @@ -388,3 +407,8 @@ type requests struct {
type workloadHealth struct {
Requests requests `json:"requests"`
}

type workloadStatus struct {
Name string `json:"name"`
Health workloadHealth `json:"health"`
}

0 comments on commit 2aafce1

Please sign in to comment.