wangao1236 commented on code in PR #530:
URL: https://github.com/apache/incubator-uniffle/pull/530#discussion_r1096910003


##########
deploy/kubernetes/operator/pkg/controller/sync/coordinator/coordinator_test.go:
##########
@@ -88,3 +90,49 @@ func TestGenerateDeploy(t *testing.T) {
                })
        }
 }
+
+func TestGenerateSvcForCoordinator(t *testing.T) {
+       for _, tt := range []struct {
+               name          string
+               rss           *uniffleapi.RemoteShuffleService
+               serviceCntMap map[v1.ServiceType]int
+       }{
+               {
+                       name: "with RPCNodePort",
+                       rss:  buildRssWithLabels(),
+                       serviceCntMap: map[v1.ServiceType]int{
+                               "":                     2, // defaults to 
headless service
+                               v1.ServiceTypeNodePort: 2,
+                       },
+               },
+               {
+                       name: "without rpcNodePort",
+                       rss: func() *uniffleapi.RemoteShuffleService {
+                               withoutRPCNodePortRss := buildRssWithLabels()
+                               
withoutRPCNodePortRss.Spec.Coordinator.RPCNodePort = make([]int32, 0)
+                               
withoutRPCNodePortRss.Spec.Coordinator.HTTPNodePort = make([]int32, 0)
+                               return withoutRPCNodePortRss
+                       }(),
+                       serviceCntMap: map[v1.ServiceType]int{
+                               "": 2,
+                       },
+               },
+       } {
+               t.Run(tt.name, func(t *testing.T) {
+                       assertion := assert.New(t)
+                       _, _, services, _ := GenerateCoordinators(tt.rss)
+                       result := make(map[v1.ServiceType]int)
+                       for _, service := range services {
+                               result[service.Spec.Type]++

Review Comment:
   In a real cluster, headless service type is also ClusterIP, perhaps you can 
simply encapsulate a method to determine the svc type?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to