@@ -24,13 +24,15 @@ import (
24
24
. "github.com/onsi/ginkgo/v2"
25
25
. "github.com/onsi/gomega"
26
26
corev1 "k8s.io/api/core/v1"
27
+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
28
"sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
28
29
)
29
30
30
31
var (
31
32
_ = Describe ("" , testGeneralServiceImport )
32
33
_ = Describe ("" , Label (ClusterIPLabel ), testClusterIPServiceImport )
33
34
_ = Describe ("" , Label (HeadlessLabel ), testHeadlessServiceImport )
35
+ _ = Describe ("" , Label (ExternalNameLabel ), testExternalNameService )
34
36
)
35
37
36
38
func testGeneralServiceImport () {
@@ -136,8 +138,8 @@ func testGeneralServiceImport() {
136
138
Label (OptionalLabel ), Label (ExportedLabelsLabel ), func () {
137
139
AddReportEntry (SpecRefReportEntry , "https://github.com/kubernetes/enhancements/tree/master/keps/sig-multicluster/1645-multi-cluster-services-api#labels-and-annotations" )
138
140
139
- t .awaitServiceExportCondition (& clients [0 ], v1alpha1 .ServiceExportConflict )
140
- t .awaitServiceExportCondition (& clients [1 ], v1alpha1 .ServiceExportConflict )
141
+ t .awaitServiceExportCondition (& clients [0 ], v1alpha1 .ServiceExportConflict , metav1 . ConditionTrue )
142
+ t .awaitServiceExportCondition (& clients [1 ], v1alpha1 .ServiceExportConflict , metav1 . ConditionTrue )
141
143
142
144
serviceImport := t .awaitServiceImport (& clients [0 ], t .helloService .Name , func (serviceImport * v1alpha1.ServiceImport ) bool {
143
145
return len (serviceImport .Labels ) > 0
@@ -263,8 +265,8 @@ func testClusterIPServiceImport() {
263
265
Specify ("should apply the conflict resolution policy and report a Conflict condition on each ServiceExport" , func () {
264
266
AddReportEntry (SpecRefReportEntry , "https://github.com/kubernetes/enhancements/tree/master/keps/sig-multicluster/1645-multi-cluster-services-api#service-port" )
265
267
266
- t .awaitServiceExportCondition (& clients [0 ], v1alpha1 .ServiceExportConflict )
267
- t .awaitServiceExportCondition (& clients [1 ], v1alpha1 .ServiceExportConflict )
268
+ t .awaitServiceExportCondition (& clients [0 ], v1alpha1 .ServiceExportConflict , metav1 . ConditionTrue )
269
+ t .awaitServiceExportCondition (& clients [1 ], v1alpha1 .ServiceExportConflict , metav1 . ConditionTrue )
268
270
269
271
serviceImport := t .awaitServiceImport (& clients [0 ], t .helloService .Name , func (serviceImport * v1alpha1.ServiceImport ) bool {
270
272
return len (serviceImport .Spec .Ports ) == len (t .helloService .Spec .Ports )
@@ -323,3 +325,24 @@ func testHeadlessServiceImport() {
323
325
}).Within (5 * time .Second ).ProbeEvery (time .Second ).Should (BeEmpty (), reportNonConformant ("" ))
324
326
})
325
327
}
328
+
329
+ func testExternalNameService () {
330
+ t := newTestDriver ()
331
+
332
+ BeforeEach (func () {
333
+ t .helloService .Spec .Type = corev1 .ServiceTypeExternalName
334
+ t .helloService .Spec .ExternalName = "example.com"
335
+ })
336
+
337
+ JustBeforeEach (func () {
338
+ t .createServiceExport (& clients [0 ], newHelloServiceExport ())
339
+ })
340
+
341
+ Specify ("Exporting an ExternalName service should set ServiceExport Valid condition to False" , Label (RequiredLabel ), func () {
342
+ AddReportEntry (SpecRefReportEntry , "https://github.com/kubernetes/enhancements/blob/master/keps/sig-multicluster/1645-multi-cluster-services-api/README.md#service-types" )
343
+
344
+ t .awaitServiceExportCondition (& clients [0 ], v1alpha1 .ServiceExportValid , metav1 .ConditionFalse )
345
+ t .ensureNoServiceImport (& clients [0 ], helloServiceName ,
346
+ "the ServiceImport should not exist for an ExternalName service" )
347
+ })
348
+ }
0 commit comments