Skip to content

Commit

Permalink
bootstrap federatedinformermanager tests
Browse files Browse the repository at this point in the history
  • Loading branch information
limhawjia committed Jul 7, 2023
1 parent 825be64 commit e33b2e2
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 15 deletions.
53 changes: 49 additions & 4 deletions pkg/util/informermanager/federatedinformermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,63 @@ package informermanager

import "testing"

func TestClientAvailableForExistingClusters(t *testing.T) {
func TestFederatedInformerManagerClientAvailableForExistingClusters(t *testing.T) {

}

func TestClientAvailableForNewCluster(t *testing.T) {
func TestFederatedInformerManagerClientAvailableForNewCluster(t *testing.T) {

}

func TestListerAvailableForExistingFTCsAndClusters(t *testing.T) {
func TestFederatedInformerManagerListerAvailableForExistingFTCsAndClusters(t *testing.T) {

}

func TestListerAvailableForNewFTCAndCluster(t *testing.T) {
func TestFederatedInformerManagerListerAvailableForNewFTC(t *testing.T) {

}

func TestFederatedInformerManagerListerAvailableForNewCluster(t *testing.T) {

}

func TestFederatedInformerManagerEventHandlerRegistrationForExistingFTCsAndClusters(t *testing.T) {

}

func TestFederatedInformerManagerEventHandlerRegistrationForNewFTC(t *testing.T) {

}

func TestFederatedInformerManagerEventHandlerRegistrationOnFTCUpdate(t *testing.T) {

}

func TestFederatedInformerManagerEventHandlerRegistrationOnFTCDelete(t *testing.T) {

}

func TestFederatedInformerManagerEventHandlerRegistrationForNewCluster(t *testing.T) {

}

func TestFederatedInformerManagerEventHandlerRegistrationOnClusterDelete(t *testing.T) {

}

func TestFederatedInformerManagerClusterEventHandlerForExistingClusters(t *testing.T) {

}

func TestFederatedInformerManagerClusterEventHandlerForNewCluster(t *testing.T) {

}

func TestFederatedInformerManagerClusterEventHandlerOnClusterUpdate(t *testing.T) {

}

func TestFederatedInformerManagerClusterEventHandlerOnClusterDelete(t *testing.T) {

}

14 changes: 7 additions & 7 deletions pkg/util/informermanager/informermanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import (
schemautil "github.com/kubewharf/kubeadmiral/pkg/controllers/util/schema"
)

func TestListerAvailableForExistingFTCs(t *testing.T) {
func TestInformerManagerListerAvailableForExistingFTCs(t *testing.T) {
g := gomega.NewGomegaWithT(t)

defaultFTCs := []*fedcorev1a1.FederatedTypeConfig{deploymentFTC, configmapFTC, secretFTC}
Expand Down Expand Up @@ -66,7 +66,7 @@ func TestListerAvailableForExistingFTCs(t *testing.T) {
g.Expect(informerSynced).To(gomega.BeNil())
}

func TestListerAvailableForNewFTC(t *testing.T) {
func TestInformerManagerListerAvailableForNewFTC(t *testing.T) {
g := gomega.NewGomegaWithT(t)

manager, _, fedClient := boostrapInformerManagerWithFakeClients([]*fedcorev1a1.FederatedTypeConfig{}, []*unstructured.Unstructured{})
Expand Down Expand Up @@ -106,7 +106,7 @@ func TestListerAvailableForNewFTC(t *testing.T) {
g.Expect(informerSynced).To(gomega.BeNil())
}

func TestEventHandlerRegistrationForExistingFTCs(t *testing.T) {
func TestInformerManagerEventHandlerRegistrationForExistingFTCs(t *testing.T) {
g := gomega.NewGomegaWithT(t)

dp1 := getDeployment("dp-1", "default")
Expand Down Expand Up @@ -186,7 +186,7 @@ func TestEventHandlerRegistrationForExistingFTCs(t *testing.T) {
}).WithTimeout(time.Second * 2).Should(gomega.Succeed())
}

func TestEventHandlerRegistrationForNewFTC(t *testing.T) {
func TestInformerManagerEventHandlerRegistrationForNewFTC(t *testing.T) {
g := gomega.NewGomegaWithT(t)

dm1 := getDaemonSet("dm-1", "default")
Expand Down Expand Up @@ -268,7 +268,7 @@ func TestEventHandlerRegistrationForNewFTC(t *testing.T) {
}).WithTimeout(time.Second * 2).Should(gomega.Succeed())
}

func TestEventHandlerRegistrationOnFTCUpdate(t *testing.T) {
func TestInformerManagerEventHandlerRegistrationOnFTCUpdate(t *testing.T) {
g := gomega.NewGomegaWithT(t)

ftc := deploymentFTC.DeepCopy()
Expand Down Expand Up @@ -396,7 +396,7 @@ func TestEventHandlerRegistrationOnFTCUpdate(t *testing.T) {
}).WithTimeout(time.Second * 2).Should(gomega.Succeed())
}

func TestEventHandlerRegistrationOnFTCDelete(t *testing.T) {
func TestInformerManagerEventHandlerRegistrationOnFTCDelete(t *testing.T) {
g := gomega.NewGomegaWithT(t)

dp1 := getDeployment("dp-1", "default")
Expand Down Expand Up @@ -479,7 +479,7 @@ func TestEventHandlerRegistrationOnFTCDelete(t *testing.T) {
}).WithTimeout(time.Second * 2).Should(gomega.Succeed())
}

func TestEventHandlerRegistrationAfterInformerShutdown(t *testing.T) {
func TestInformerManagerEventHandlerRegistrationOnShutdown(t *testing.T) {
g := gomega.NewGomegaWithT(t)

dp1 := getDeployment("dp-1", "default")
Expand Down
11 changes: 7 additions & 4 deletions pkg/util/informermanager/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ type EventHandlerGenerator struct {
// objects based on FederatedTypeConfigs. InformerManager will listen to FTC events and maintain informers for the
// source type of each FTC.
//
// Having multiple FTCs with the same source type is not supported and will cause InformerManager to behave incorrectly.
// Updating FTC source types is also not supported and will also cause InformerManager to behave incorrectly.
// Having multiple FTCs with the same source type is not supported and may cause InformerManager to behave incorrectly.
// Updating FTC source types is also not supported and may also cause InformerManager to behave incorrectly.
type InformerManager interface {
// Adds an EventHandler used to generate and register ResourceEventHandlers for each FTC's source type informer.
AddEventHandlerGenerator(generator *EventHandlerGenerator) error
Expand Down Expand Up @@ -66,8 +66,11 @@ type ClusterEventPredicate func(oldCluster, newCluster *fedcorev1a1.FederatedClu
// access objects in member clusters based on FederatedTypeConfigs. FederatedInformerManager will listen to FTC events
// and maintian informers for each FTC's source type and joined member cluster.
//
// Having multiple FTCs with the same source type is not supported and will cause FederatedInformerManager to behave
// incorrectly. Updating FTC source types is also not supported and will also cause InformerManager to behave
// Having multiple FTCs with the same source type is not supported and may cause FederatedInformerManager to behave
// incorrectly. Updating FTC source types is also not supported and may also cause FederatedInformerManager to behave
// incorrectly.
//
// Updating Cluster connection details is also not supported and may cause FederatedInformerManager to behave
// incorrectly.
type FederatedInformerManager interface {
// Adds an EventHandler used to generate and register ResourceEventHandlers for each FTC's source type informer.
Expand Down

0 comments on commit e33b2e2

Please sign in to comment.