@@ -24,13 +24,15 @@ import (
2424 . "github.com/onsi/ginkgo/v2"
2525 . "github.com/onsi/gomega"
2626 corev1 "k8s.io/api/core/v1"
27+ metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2728 "sigs.k8s.io/mcs-api/pkg/apis/v1alpha1"
2829)
2930
3031var (
3132 _ = Describe ("" , testGeneralServiceImport )
3233 _ = Describe ("" , Label (ClusterIPLabel ), testClusterIPServiceImport )
3334 _ = Describe ("" , Label (HeadlessLabel ), testHeadlessServiceImport )
35+ _ = Describe ("" , Label (ExternalNameLabel ), testExternalNameService )
3436)
3537
3638func testGeneralServiceImport () {
@@ -136,8 +138,8 @@ func testGeneralServiceImport() {
136138 Label (OptionalLabel ), Label (ExportedLabelsLabel ), func () {
137139 AddReportEntry (SpecRefReportEntry , "https://github.com/kubernetes/enhancements/tree/master/keps/sig-multicluster/1645-multi-cluster-services-api#labels-and-annotations" )
138140
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 )
141143
142144 serviceImport := t .awaitServiceImport (& clients [0 ], t .helloService .Name , func (serviceImport * v1alpha1.ServiceImport ) bool {
143145 return len (serviceImport .Labels ) > 0
@@ -263,8 +265,8 @@ func testClusterIPServiceImport() {
263265 Specify ("should apply the conflict resolution policy and report a Conflict condition on each ServiceExport" , func () {
264266 AddReportEntry (SpecRefReportEntry , "https://github.com/kubernetes/enhancements/tree/master/keps/sig-multicluster/1645-multi-cluster-services-api#service-port" )
265267
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 )
268270
269271 serviceImport := t .awaitServiceImport (& clients [0 ], t .helloService .Name , func (serviceImport * v1alpha1.ServiceImport ) bool {
270272 return len (serviceImport .Spec .Ports ) == len (t .helloService .Spec .Ports )
@@ -323,3 +325,24 @@ func testHeadlessServiceImport() {
323325 }).Within (5 * time .Second ).ProbeEvery (time .Second ).Should (BeEmpty (), reportNonConformant ("" ))
324326 })
325327}
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