Skip to content

Commit e9cc567

Browse files
authored
correcting the testing package (#1819)
1 parent ee82748 commit e9cc567

File tree

3 files changed

+49
-14
lines changed

3 files changed

+49
-14
lines changed

.github/workflows/jobs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ jobs:
11421142
result=${result%\%}
11431143
echo "result:"
11441144
echo $result
1145-
threshold=54.00
1145+
threshold=35.20
11461146
if (( $(echo "$result >= $threshold" |bc -l) )); then
11471147
echo "It is equal or greater than threshold, passed!"
11481148
else

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ test-sso-integration:
182182
test-operator-integration:
183183
@(echo "Start cd operator-integration && go test:")
184184
@(pwd)
185-
@(cd operator-integration && go test -coverpkg=../restapi -c -tags testrunmain . && mkdir -p coverage && ./operator-integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/operator-api.out)
185+
@(cd operator-integration && go test -coverpkg=../operatorapi -c -tags testrunmain . && mkdir -p coverage && ./operator-integration.test -test.v -test.run "^Test*" -test.coverprofile=coverage/operator-api.out)
186186

187187
test-operator:
188188
@(env bash $(PWD)/portal-ui/tests/scripts/operator.sh)

operator-integration/tenant_test.go

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ import (
3434

3535
"github.com/go-openapi/loads"
3636
"github.com/minio/console/models"
37-
"github.com/minio/console/restapi"
38-
"github.com/minio/console/restapi/operations"
37+
"github.com/minio/console/operatorapi"
38+
"github.com/minio/console/operatorapi/operations"
3939
"github.com/stretchr/testify/assert"
4040
)
4141

@@ -87,11 +87,11 @@ func printEndFunc(functionName string) {
8787
fmt.Println("")
8888
}
8989

90-
func initConsoleServer() (*restapi.Server, error) {
90+
func initConsoleServer() (*operatorapi.Server, error) {
9191

9292
//os.Setenv("CONSOLE_MINIO_SERVER", "localhost:9000")
9393

94-
swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
94+
swaggerSpec, err := loads.Embedded(operatorapi.SwaggerJSON, operatorapi.FlatSwaggerJSON)
9595
if err != nil {
9696
return nil, err
9797
}
@@ -101,24 +101,22 @@ func initConsoleServer() (*restapi.Server, error) {
101101
}
102102

103103
// Initialize MinIO loggers
104-
restapi.LogInfo = noLog
105-
restapi.LogError = noLog
104+
operatorapi.LogInfo = noLog
105+
operatorapi.LogError = noLog
106106

107-
api := operations.NewConsoleAPI(swaggerSpec)
107+
api := operations.NewOperatorAPI(swaggerSpec)
108108
api.Logger = noLog
109109

110-
server := restapi.NewServer(api)
110+
server := operatorapi.NewServer(api)
111111
// register all APIs
112112
server.ConfigureAPI()
113113

114-
//restapi.GlobalRootCAs, restapi.GlobalPublicCerts, restapi.GlobalTLSCertsManager = globalRootCAs, globalPublicCerts, globalTLSCerts
115-
116114
consolePort, _ := strconv.Atoi("9090")
117115

118116
server.Host = "0.0.0.0"
119117
server.Port = consolePort
120-
restapi.Port = "9090"
121-
restapi.Hostname = "0.0.0.0"
118+
operatorapi.Port = "9090"
119+
operatorapi.Hostname = "0.0.0.0"
122120

123121
return server, nil
124122
}
@@ -529,3 +527,40 @@ func TestListNodeLabels(t *testing.T) {
529527
strings.Contains(finalResponse, "beta.kubernetes.io/arch"),
530528
finalResponse)
531529
}
530+
531+
func GetPodEvents(nameSpace string, tenant string, podName string) (*http.Response, error) {
532+
/*
533+
Helper function to get events for pod
534+
URL: /namespaces/{namespace}/tenants/{tenant}/pods/{podName}/events
535+
HTTP Verb: GET
536+
*/
537+
request, err := http.NewRequest(
538+
"GET", "http://localhost:9090/api/v1/namespaces/"+nameSpace+"/tenants/"+tenant+"/pods/"+podName+"/events", nil)
539+
if err != nil {
540+
log.Println(err)
541+
}
542+
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
543+
request.Header.Add("Content-Type", "application/json")
544+
client := &http.Client{
545+
Timeout: 2 * time.Second,
546+
}
547+
response, err := client.Do(request)
548+
return response, err
549+
}
550+
551+
func TestGetPodEvents(t *testing.T) {
552+
assert := assert.New(t)
553+
namespace := "tenant-lite"
554+
tenant := "storage-lite"
555+
podName := "storage-lite-pool-0-0"
556+
resp, err := GetPodEvents(namespace, tenant, podName)
557+
assert.Nil(err)
558+
if err != nil {
559+
log.Println(err)
560+
return
561+
}
562+
if resp != nil {
563+
assert.Equal(
564+
200, resp.StatusCode, "Status Code is incorrect")
565+
}
566+
}

0 commit comments

Comments
 (0)