5
5
package v1alpha1
6
6
7
7
import (
8
+ "time"
9
+
8
10
. "github.com/onsi/ginkgo"
9
11
. "github.com/onsi/gomega"
10
12
v1 "k8s.io/api/core/v1"
@@ -13,7 +15,6 @@ import (
13
15
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
16
"k8s.io/apimachinery/pkg/types"
15
17
"sigs.k8s.io/controller-runtime/pkg/client"
16
- "time"
17
18
)
18
19
19
20
var _ = Describe ("KuberlogicService controller" , func () {
@@ -48,6 +49,7 @@ var _ = Describe("KuberlogicService controller", func() {
48
49
Type : "docker-compose" ,
49
50
Replicas : defaultReplicas ,
50
51
Limits : defaultLimits ,
52
+ Domain : "kls.com" ,
51
53
},
52
54
}
53
55
@@ -59,20 +61,21 @@ var _ = Describe("KuberlogicService controller", func() {
59
61
Spec : KuberLogicServiceSpec {
60
62
Type : "docker-compose" ,
61
63
Replicas : defaultReplicas ,
64
+ Domain : "default-resources.com" ,
62
65
},
63
66
}
64
67
65
68
It ("Should create KuberLogicService resource" , func () {
66
69
By ("By creating a new KuberLogicService" )
67
70
68
- Expect (k8sClient .Create (ctx , kls )).Should (Succeed ())
71
+ Expect (testK8sClient .Create (ctx , kls )).Should (Succeed ())
69
72
70
73
By ("By checking a new KuberLogicService" )
71
74
lookupKlsKey := types.NamespacedName {Name : klsName , Namespace : klsNamespace }
72
75
createdKls := & KuberLogicService {}
73
76
74
77
Eventually (func () error {
75
- return k8sClient .Get (ctx , lookupKlsKey , createdKls )
78
+ return testK8sClient .Get (ctx , lookupKlsKey , createdKls )
76
79
}, timeout , interval ).Should (Not (HaveOccurred ()))
77
80
78
81
log .Info ("resources" , "res" , createdKls .Spec .Limits )
@@ -82,30 +85,30 @@ var _ = Describe("KuberlogicService controller", func() {
82
85
83
86
By ("By creating a new KuberLogicService with default limits" )
84
87
85
- Expect (k8sClient .Create (ctx , defaultResourceKls )).Should (Succeed ())
88
+ Expect (testK8sClient .Create (ctx , defaultResourceKls )).Should (Succeed ())
86
89
87
90
By ("By checking default plugin resources" )
88
91
Eventually (func () error {
89
- return k8sClient .Get (ctx , client .ObjectKeyFromObject (defaultResourceKls ), createdKls )
92
+ return testK8sClient .Get (ctx , client .ObjectKeyFromObject (defaultResourceKls ), createdKls )
90
93
}, timeout , interval ).Should (Not (HaveOccurred ()))
91
94
92
95
log .Info ("resources" , "res" , createdKls .Spec .Limits )
93
96
Expect (createdKls .Spec .Limits ["storage" ]).Should (Equal (resource .MustParse ("1Gi" )))
94
97
95
98
By ("Volume downsize is not supported" )
96
99
defaultResourceKls .Spec .Limits ["storage" ] = resource .MustParse ("1Mi" )
97
- Expect (k8sClient .Update (ctx , defaultResourceKls ).Error ()).Should (ContainSubstring ("volume downsize forbidden" ))
100
+ Expect (testK8sClient .Update (ctx , defaultResourceKls ).Error ()).Should (ContainSubstring ("volume downsize forbidden" ))
98
101
})
99
102
It ("Should remove KuberLogicService resource" , func () {
100
103
By ("Removing KuberLogicService resource" )
101
104
102
105
for _ , item := range []* KuberLogicService {kls , defaultResourceKls } {
103
- Expect (k8sClient .Delete (ctx , item )).Should (Succeed ())
106
+ Expect (testK8sClient .Delete (ctx , item )).Should (Succeed ())
104
107
105
108
By ("By checking a new KuberLogicService" )
106
109
removedKls := & KuberLogicService {}
107
110
Eventually (func () bool {
108
- return errors .IsNotFound (k8sClient .Get (ctx , client .ObjectKeyFromObject (item ), removedKls ))
111
+ return errors .IsNotFound (testK8sClient .Get (ctx , client .ObjectKeyFromObject (item ), removedKls ))
109
112
}, timeout , interval ).Should (BeTrue ())
110
113
}
111
114
})
0 commit comments