Skip to content

Commit

Permalink
fix ut
Browse files Browse the repository at this point in the history
  • Loading branch information
zoumo authored and shaofan-hs committed Jan 17, 2024
1 parent 200d68c commit d90f42e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 22 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
ENVTEST_K8S_VERSION = 1.22.1
ENVTEST_K8S_VERSION = 1.24.1

.PHONY: fmt
fmt: ## Run go fmt against code.
Expand All @@ -25,4 +25,4 @@ ENVTEST ?= $(LOCALBIN)/setup-envtest
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
4 changes: 0 additions & 4 deletions cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ package cache
import (
"context"
"fmt"
"net/url"
"testing"
"time"

Expand Down Expand Up @@ -186,9 +185,6 @@ func TestCache(t *testing.T) {

var _ = BeforeSuite(func() {
env = &envtest.Environment{}
env.ControlPlane.GetAPIServer().URL = &url.URL{
Host: "127.0.0.1:65221",
}

config, err := env.Start()
Expect(err).NotTo(HaveOccurred())
Expand Down
5 changes: 3 additions & 2 deletions multicluster/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,10 @@ var _ = Describe("multicluster with 1 fed and 4 clusters", func() {
})

It("multiClusterClient get server groups and resources", func() {
serverGroupsAndResourcesClient, ok := clusterClient.(PartialCachedDiscoveryInterface)
mcdiscovery, ok := clusterClient.(MultiClusterDiscovery)
Expect(ok).To(Equal(true))
apiGroups, apiResourceLists, err := serverGroupsAndResourcesClient.ServerGroupsAndResources()
cachedDiscoveryClient := mcdiscovery.MembersCachedDiscoveryInterface()
apiGroups, apiResourceLists, err := cachedDiscoveryClient.ServerGroupsAndResources()
Expect(err).NotTo(HaveOccurred())

groupVersionSets := sets.NewString()
Expand Down
8 changes: 4 additions & 4 deletions multicluster/multi_cluster_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ import (

// MultiClusterDiscovery provides fed and member clusters discovery interface
type MultiClusterDiscovery interface {
GetFedDiscoveryInterface() discovery.DiscoveryInterface
GetMembersCachedDiscoveryInterface() PartialCachedDiscoveryInterface
FedDiscoveryInterface() discovery.DiscoveryInterface
MembersCachedDiscoveryInterface() PartialCachedDiscoveryInterface
}

// PartialCachedDiscoveryInterface is a subset of discovery.DiscoveryInterface.
Expand Down Expand Up @@ -466,11 +466,11 @@ func (mcc *multiClusterClient) getClusterNames(ctx context.Context) (clusters []
return
}

func (mcc *multiClusterClient) GetFedDiscoveryInterface() discovery.DiscoveryInterface {
func (mcc *multiClusterClient) FedDiscoveryInterface() discovery.DiscoveryInterface {
return mcc.fedDiscovery
}

func (mcc *multiClusterClient) GetMembersCachedDiscoveryInterface() PartialCachedDiscoveryInterface {
func (mcc *multiClusterClient) MembersCachedDiscoveryInterface() PartialCachedDiscoveryInterface {
return &cachedMultiClusterDiscoveryClient{
delegate: mcc,
}
Expand Down
16 changes: 6 additions & 10 deletions multicluster/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ package multicluster

import (
"context"
"net/url"
"os"
"testing"
"time"
Expand Down Expand Up @@ -76,9 +75,8 @@ var _ = BeforeSuite(func() {
fedEnv = &envtest.Environment{
Scheme: fedScheme,
}
fedEnv.ControlPlane.GetAPIServer().URL = &url.URL{
Host: "127.0.0.1:10001",
}
fedEnv.ControlPlane.GetAPIServer().SecureServing.Address = "127.0.0.1"
fedEnv.ControlPlane.GetAPIServer().SecureServing.Port = "10001"
fedConfig, err := fedEnv.Start()
Expect(err).NotTo(HaveOccurred())
Expect(fedConfig).NotTo(BeNil())
Expand All @@ -97,9 +95,8 @@ var _ = BeforeSuite(func() {
clusterEnv1 = &envtest.Environment{
Scheme: clusterScheme,
}
clusterEnv1.ControlPlane.GetAPIServer().URL = &url.URL{
Host: "127.0.0.1:10002",
}
clusterEnv1.ControlPlane.GetAPIServer().SecureServing.Address = "127.0.0.1"
clusterEnv1.ControlPlane.GetAPIServer().SecureServing.Port = "10002"
clusterConfig1, err := clusterEnv1.Start()
Expect(err).NotTo(HaveOccurred())
Expect(clusterConfig1).NotTo(BeNil())
Expand All @@ -112,9 +109,8 @@ var _ = BeforeSuite(func() {
clusterEnv2 = &envtest.Environment{
Scheme: clusterScheme,
}
clusterEnv2.ControlPlane.GetAPIServer().URL = &url.URL{
Host: "127.0.0.1:10003",
}
clusterEnv2.ControlPlane.GetAPIServer().SecureServing.Address = "127.0.0.1"
clusterEnv2.ControlPlane.GetAPIServer().SecureServing.Port = "10003"
clusterConfig2, err := clusterEnv2.Start()
Expect(err).NotTo(HaveOccurred())
Expect(clusterConfig2).NotTo(BeNil())
Expand Down

0 comments on commit d90f42e

Please sign in to comment.