Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/jobs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1142,7 +1142,7 @@ jobs:
result=${result%\%}
echo "result:"
echo $result
threshold=54.00
threshold=35.20
if (( $(echo "$result >= $threshold" |bc -l) )); then
echo "It is equal or greater than threshold, passed!"
else
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ test-sso-integration:
test-operator-integration:
@(echo "Start cd operator-integration && go test:")
@(pwd)
@(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)
@(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)

test-operator:
@(env bash $(PWD)/portal-ui/tests/scripts/operator.sh)
Expand Down
59 changes: 47 additions & 12 deletions operator-integration/tenant_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ import (

"github.com/go-openapi/loads"
"github.com/minio/console/models"
"github.com/minio/console/restapi"
"github.com/minio/console/restapi/operations"
"github.com/minio/console/operatorapi"
"github.com/minio/console/operatorapi/operations"
"github.com/stretchr/testify/assert"
)

Expand Down Expand Up @@ -87,11 +87,11 @@ func printEndFunc(functionName string) {
fmt.Println("")
}

func initConsoleServer() (*restapi.Server, error) {
func initConsoleServer() (*operatorapi.Server, error) {

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

swaggerSpec, err := loads.Embedded(restapi.SwaggerJSON, restapi.FlatSwaggerJSON)
swaggerSpec, err := loads.Embedded(operatorapi.SwaggerJSON, operatorapi.FlatSwaggerJSON)
if err != nil {
return nil, err
}
Expand All @@ -101,24 +101,22 @@ func initConsoleServer() (*restapi.Server, error) {
}

// Initialize MinIO loggers
restapi.LogInfo = noLog
restapi.LogError = noLog
operatorapi.LogInfo = noLog
operatorapi.LogError = noLog

api := operations.NewConsoleAPI(swaggerSpec)
api := operations.NewOperatorAPI(swaggerSpec)
api.Logger = noLog

server := restapi.NewServer(api)
server := operatorapi.NewServer(api)
// register all APIs
server.ConfigureAPI()

//restapi.GlobalRootCAs, restapi.GlobalPublicCerts, restapi.GlobalTLSCertsManager = globalRootCAs, globalPublicCerts, globalTLSCerts

consolePort, _ := strconv.Atoi("9090")

server.Host = "0.0.0.0"
server.Port = consolePort
restapi.Port = "9090"
restapi.Hostname = "0.0.0.0"
operatorapi.Port = "9090"
operatorapi.Hostname = "0.0.0.0"

return server, nil
}
Expand Down Expand Up @@ -529,3 +527,40 @@ func TestListNodeLabels(t *testing.T) {
strings.Contains(finalResponse, "beta.kubernetes.io/arch"),
finalResponse)
}

func GetPodEvents(nameSpace string, tenant string, podName string) (*http.Response, error) {
/*
Helper function to get events for pod
URL: /namespaces/{namespace}/tenants/{tenant}/pods/{podName}/events
HTTP Verb: GET
*/
request, err := http.NewRequest(
"GET", "http://localhost:9090/api/v1/namespaces/"+nameSpace+"/tenants/"+tenant+"/pods/"+podName+"/events", nil)
if err != nil {
log.Println(err)
}
request.Header.Add("Cookie", fmt.Sprintf("token=%s", token))
request.Header.Add("Content-Type", "application/json")
client := &http.Client{
Timeout: 2 * time.Second,
}
response, err := client.Do(request)
return response, err
}

func TestGetPodEvents(t *testing.T) {
assert := assert.New(t)
namespace := "tenant-lite"
tenant := "storage-lite"
podName := "storage-lite-pool-0-0"
resp, err := GetPodEvents(namespace, tenant, podName)
assert.Nil(err)
if err != nil {
log.Println(err)
return
}
if resp != nil {
assert.Equal(
200, resp.StatusCode, "Status Code is incorrect")
}
}