Skip to content

Commit e41c804

Browse files
authored
Test list of claims (#2069)
1 parent 6f7a46e commit e41c804

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed

.github/workflows/jobs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1521,7 +1521,7 @@ jobs:
15211521
go tool cover -func=all.out | grep total > tmp2
15221522
result=`cat tmp2 | awk 'END {print $3}'`
15231523
result=${result%\%}
1524-
threshold=50.6
1524+
threshold=50.9
15251525
echo "Result:"
15261526
echo "$result%"
15271527
if (( $(echo "$result >= $threshold" |bc -l) )); then

operator-integration/tenant_test.go

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,3 +673,57 @@ func TestGetMultipleCSRs(t *testing.T) {
673673
assert.Equal(strings.Contains(finalResponse, element), true)
674674
}
675675
}
676+
677+
func ListPVCsForTenant(nameSpace string, tenant string) (*http.Response, error) {
678+
/*
679+
URL: /namespaces/{namespace}/tenants/{tenant}/pvcs
680+
HTTP Verb: GET
681+
*/
682+
request, err := http.NewRequest(
683+
"GET", "http://localhost:9090/api/v1/namespaces/"+nameSpace+"/tenants/"+tenant+"/pvcs/", nil)
684+
if err != nil {
685+
log.Println(err)
686+
}
687+
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
688+
request.Header.Add("Content-Type", "application/json")
689+
client := &http.Client{
690+
Timeout: 2 * time.Second,
691+
}
692+
response, err := client.Do(request)
693+
return response, err
694+
}
695+
696+
func TestListPVCsForTenant(t *testing.T) {
697+
/*
698+
Function to list and verify the Tenant's Persistent Volume Claims
699+
*/
700+
assert := assert.New(t)
701+
namespace := "tenant-lite"
702+
tenant := "storage-lite"
703+
resp, err := ListPVCsForTenant(namespace, tenant)
704+
bodyResponse := resp.Body
705+
assert.Nil(err)
706+
if err != nil {
707+
log.Println(err)
708+
return
709+
}
710+
if resp != nil {
711+
assert.Equal(
712+
200, resp.StatusCode, "failed")
713+
}
714+
bodyBytes, _ := ioutil.ReadAll(bodyResponse)
715+
listObjs := models.ListPVCsResponse{}
716+
err = json.Unmarshal(bodyBytes, &listObjs)
717+
if err != nil {
718+
log.Println(err)
719+
assert.Nil(err)
720+
}
721+
var pvcArray [4]string
722+
pvcArray[0] = "data0-storage-lite-pool-0-0"
723+
pvcArray[1] = "data0-storage-lite-pool-0-1"
724+
pvcArray[2] = "data0-storage-lite-pool-0-2"
725+
pvcArray[3] = "data0-storage-lite-pool-0-3"
726+
for i := 0; i < len(pvcArray); i++ {
727+
assert.Equal(strings.Contains(listObjs.Pvcs[i].Name, pvcArray[i]), true)
728+
}
729+
}

0 commit comments

Comments
 (0)