@@ -34,8 +34,8 @@ import (
34
34
35
35
"github.com/go-openapi/loads"
36
36
"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"
39
39
"github.com/stretchr/testify/assert"
40
40
)
41
41
@@ -87,11 +87,11 @@ func printEndFunc(functionName string) {
87
87
fmt .Println ("" )
88
88
}
89
89
90
- func initConsoleServer () (* restapi .Server , error ) {
90
+ func initConsoleServer () (* operatorapi .Server , error ) {
91
91
92
92
//os.Setenv("CONSOLE_MINIO_SERVER", "localhost:9000")
93
93
94
- swaggerSpec , err := loads .Embedded (restapi .SwaggerJSON , restapi .FlatSwaggerJSON )
94
+ swaggerSpec , err := loads .Embedded (operatorapi .SwaggerJSON , operatorapi .FlatSwaggerJSON )
95
95
if err != nil {
96
96
return nil , err
97
97
}
@@ -101,24 +101,22 @@ func initConsoleServer() (*restapi.Server, error) {
101
101
}
102
102
103
103
// Initialize MinIO loggers
104
- restapi .LogInfo = noLog
105
- restapi .LogError = noLog
104
+ operatorapi .LogInfo = noLog
105
+ operatorapi .LogError = noLog
106
106
107
- api := operations .NewConsoleAPI (swaggerSpec )
107
+ api := operations .NewOperatorAPI (swaggerSpec )
108
108
api .Logger = noLog
109
109
110
- server := restapi .NewServer (api )
110
+ server := operatorapi .NewServer (api )
111
111
// register all APIs
112
112
server .ConfigureAPI ()
113
113
114
- //restapi.GlobalRootCAs, restapi.GlobalPublicCerts, restapi.GlobalTLSCertsManager = globalRootCAs, globalPublicCerts, globalTLSCerts
115
-
116
114
consolePort , _ := strconv .Atoi ("9090" )
117
115
118
116
server .Host = "0.0.0.0"
119
117
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"
122
120
123
121
return server , nil
124
122
}
@@ -529,3 +527,40 @@ func TestListNodeLabels(t *testing.T) {
529
527
strings .Contains (finalResponse , "beta.kubernetes.io/arch" ),
530
528
finalResponse )
531
529
}
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