mirror of
https://github.com/OpenMaxIO/openmaxio-object-browser
synced 2026-07-01 07:41:18 -07:00
correcting the testing package (#1819)
This commit is contained in:
committed by
GitHub
parent
ee82748aeb
commit
e9cc567977
2
.github/workflows/jobs.yaml
vendored
2
.github/workflows/jobs.yaml
vendored
@@ -1142,7 +1142,7 @@ jobs:
|
|||||||
result=${result%\%}
|
result=${result%\%}
|
||||||
echo "result:"
|
echo "result:"
|
||||||
echo $result
|
echo $result
|
||||||
threshold=54.00
|
threshold=35.20
|
||||||
if (( $(echo "$result >= $threshold" |bc -l) )); then
|
if (( $(echo "$result >= $threshold" |bc -l) )); then
|
||||||
echo "It is equal or greater than threshold, passed!"
|
echo "It is equal or greater than threshold, passed!"
|
||||||
else
|
else
|
||||||
|
|||||||
2
Makefile
2
Makefile
@@ -182,7 +182,7 @@ test-sso-integration:
|
|||||||
test-operator-integration:
|
test-operator-integration:
|
||||||
@(echo "Start cd operator-integration && go test:")
|
@(echo "Start cd operator-integration && go test:")
|
||||||
@(pwd)
|
@(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:
|
test-operator:
|
||||||
@(env bash $(PWD)/portal-ui/tests/scripts/operator.sh)
|
@(env bash $(PWD)/portal-ui/tests/scripts/operator.sh)
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ import (
|
|||||||
|
|
||||||
"github.com/go-openapi/loads"
|
"github.com/go-openapi/loads"
|
||||||
"github.com/minio/console/models"
|
"github.com/minio/console/models"
|
||||||
"github.com/minio/console/restapi"
|
"github.com/minio/console/operatorapi"
|
||||||
"github.com/minio/console/restapi/operations"
|
"github.com/minio/console/operatorapi/operations"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -87,11 +87,11 @@ func printEndFunc(functionName string) {
|
|||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
}
|
}
|
||||||
|
|
||||||
func initConsoleServer() (*restapi.Server, error) {
|
func initConsoleServer() (*operatorapi.Server, error) {
|
||||||
|
|
||||||
//os.Setenv("CONSOLE_MINIO_SERVER", "localhost:9000")
|
//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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@@ -101,24 +101,22 @@ func initConsoleServer() (*restapi.Server, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Initialize MinIO loggers
|
// Initialize MinIO loggers
|
||||||
restapi.LogInfo = noLog
|
operatorapi.LogInfo = noLog
|
||||||
restapi.LogError = noLog
|
operatorapi.LogError = noLog
|
||||||
|
|
||||||
api := operations.NewConsoleAPI(swaggerSpec)
|
api := operations.NewOperatorAPI(swaggerSpec)
|
||||||
api.Logger = noLog
|
api.Logger = noLog
|
||||||
|
|
||||||
server := restapi.NewServer(api)
|
server := operatorapi.NewServer(api)
|
||||||
// register all APIs
|
// register all APIs
|
||||||
server.ConfigureAPI()
|
server.ConfigureAPI()
|
||||||
|
|
||||||
//restapi.GlobalRootCAs, restapi.GlobalPublicCerts, restapi.GlobalTLSCertsManager = globalRootCAs, globalPublicCerts, globalTLSCerts
|
|
||||||
|
|
||||||
consolePort, _ := strconv.Atoi("9090")
|
consolePort, _ := strconv.Atoi("9090")
|
||||||
|
|
||||||
server.Host = "0.0.0.0"
|
server.Host = "0.0.0.0"
|
||||||
server.Port = consolePort
|
server.Port = consolePort
|
||||||
restapi.Port = "9090"
|
operatorapi.Port = "9090"
|
||||||
restapi.Hostname = "0.0.0.0"
|
operatorapi.Hostname = "0.0.0.0"
|
||||||
|
|
||||||
return server, nil
|
return server, nil
|
||||||
}
|
}
|
||||||
@@ -529,3 +527,40 @@ func TestListNodeLabels(t *testing.T) {
|
|||||||
strings.Contains(finalResponse, "beta.kubernetes.io/arch"),
|
strings.Contains(finalResponse, "beta.kubernetes.io/arch"),
|
||||||
finalResponse)
|
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")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user