mirror of
https://github.com/open-cluster-management-io/ocm.git
synced 2026-02-14 18:09:57 +00:00
🌱 add e2e tests for addon manager (#199)
* add e2e tests for addon manager Signed-off-by: zhujian <jiazhu@redhat.com> * test image override and node placement for addon manager Signed-off-by: zhujian <jiazhu@redhat.com> --------- Signed-off-by: zhujian <jiazhu@redhat.com>
This commit is contained in:
@@ -92,7 +92,7 @@ func NewAddonTemplateController(
|
||||
|
||||
func (c *addonTemplateController) stopUnusedManagers(
|
||||
ctx context.Context, syncCtx factory.SyncContext, addOnName string) {
|
||||
|
||||
// TODO: check if all managed cluster addon instances are deleted
|
||||
stopFunc, ok := c.addonManagers[addOnName]
|
||||
if ok {
|
||||
stopFunc()
|
||||
@@ -111,6 +111,7 @@ func (c *addonTemplateController) sync(ctx context.Context, syncCtx factory.Sync
|
||||
cma, err := c.cmaLister.Get(addonName)
|
||||
if err != nil {
|
||||
if errors.IsNotFound(err) {
|
||||
c.stopUnusedManagers(ctx, syncCtx, addonName)
|
||||
return nil
|
||||
}
|
||||
return err
|
||||
|
||||
@@ -167,6 +167,10 @@ func TestAddonTemplateAgent_Manifests(t *testing.T) {
|
||||
if !ok {
|
||||
t.Errorf("expected object to be *appsv1.Deployment, but got %T", objects[0])
|
||||
}
|
||||
image := object.Spec.Template.Spec.Containers[0].Image
|
||||
if image != "quay.io/ocm/addon-examples:v1" {
|
||||
t.Errorf("unexpected image %v", image)
|
||||
}
|
||||
|
||||
nodeSelector := object.Spec.Template.Spec.NodeSelector
|
||||
expectedNodeSelector := map[string]string{"host": "ssd"}
|
||||
|
||||
@@ -316,7 +316,7 @@ func TestSyncDeploy(t *testing.T) {
|
||||
|
||||
// Check if resources are created as expected
|
||||
// We expect create the namespace twice respectively in the management cluster and the hub cluster.
|
||||
testingcommon.AssertEqualNumber(t, len(createKubeObjects), 27)
|
||||
testingcommon.AssertEqualNumber(t, len(createKubeObjects), 29)
|
||||
for _, object := range createKubeObjects {
|
||||
ensureObject(t, object, clusterManager)
|
||||
}
|
||||
@@ -356,7 +356,7 @@ func TestSyncDeployNoWebhook(t *testing.T) {
|
||||
|
||||
// Check if resources are created as expected
|
||||
// We expect create the namespace twice respectively in the management cluster and the hub cluster.
|
||||
testingcommon.AssertEqualNumber(t, len(createKubeObjects), 28)
|
||||
testingcommon.AssertEqualNumber(t, len(createKubeObjects), 30)
|
||||
for _, object := range createKubeObjects {
|
||||
ensureObject(t, object, clusterManager)
|
||||
}
|
||||
@@ -398,7 +398,7 @@ func TestSyncDelete(t *testing.T) {
|
||||
deleteKubeActions = append(deleteKubeActions, deleteKubeAction)
|
||||
}
|
||||
}
|
||||
testingcommon.AssertEqualNumber(t, len(deleteKubeActions), 27) // delete namespace both from the hub cluster and the mangement cluster
|
||||
testingcommon.AssertEqualNumber(t, len(deleteKubeActions), 29) // delete namespace both from the hub cluster and the mangement cluster
|
||||
|
||||
deleteCRDActions := []clienttesting.DeleteActionImpl{}
|
||||
crdActions := tc.apiExtensionClient.Actions()
|
||||
|
||||
@@ -39,6 +39,8 @@ var (
|
||||
"cluster-manager/hub/cluster-manager-work-webhook-clusterrole.yaml",
|
||||
"cluster-manager/hub/cluster-manager-work-webhook-clusterrolebinding.yaml",
|
||||
"cluster-manager/hub/cluster-manager-work-webhook-serviceaccount.yaml",
|
||||
// work executor admin
|
||||
"cluster-manager/hub/cluster-manager-work-executor-admin-clusterrole.yaml",
|
||||
// placement
|
||||
"cluster-manager/hub/cluster-manager-placement-clusterrole.yaml",
|
||||
"cluster-manager/hub/cluster-manager-placement-clusterrolebinding.yaml",
|
||||
@@ -56,6 +58,7 @@ var (
|
||||
// addon-manager
|
||||
"cluster-manager/hub/cluster-manager-addon-manager-clusterrole.yaml",
|
||||
"cluster-manager/hub/cluster-manager-addon-manager-clusterrolebinding.yaml",
|
||||
"cluster-manager/hub/cluster-manager-addon-manager-work-executor-admin-clusterrolebinding.yaml",
|
||||
"cluster-manager/hub/cluster-manager-addon-manager-serviceaccount.yaml",
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user