@@ -59,6 +59,21 @@ func newRegistrationDeployment(desiredReplica, availableReplica int32) *appsv1.D
5959	}
6060}
6161
62+ func  newRegistrationWebhookDeployment (desiredReplica , availableReplica  int32 ) * appsv1.Deployment  {
63+ 	return  & appsv1.Deployment {
64+ 		ObjectMeta : metav1.ObjectMeta {
65+ 			Name :      fmt .Sprintf ("%s-registration-webhook" , testClusterManagerName ),
66+ 			Namespace : "open-cluster-management-hub" ,
67+ 		},
68+ 		Spec : appsv1.DeploymentSpec {
69+ 			Replicas : & desiredReplica ,
70+ 		},
71+ 		Status : appsv1.DeploymentStatus {
72+ 			AvailableReplicas : availableReplica ,
73+ 		},
74+ 	}
75+ }
76+ 
6277func  newPlacementDeployment (desiredReplica , availableReplica  int32 ) * appsv1.Deployment  {
6378	return  & appsv1.Deployment {
6479		ObjectMeta : metav1.ObjectMeta {
@@ -145,11 +160,33 @@ func TestSyncStatus(t *testing.T) {
145160				testinghelper .AssertOnlyConditions (t , klusterlet , appliedCond , expectedCondition1 , expectedCondition2 )
146161			},
147162		},
163+ 		{
164+ 			name :            "unavailable registration webhook pods and placement functional" ,
165+ 			queueKey :        testClusterManagerName ,
166+ 			clusterManagers : []runtime.Object {newClusterManager ()},
167+ 			deployments : []runtime.Object {
168+ 				newRegistrationDeployment (3 , 3 ),
169+ 				newRegistrationWebhookDeployment (3 , 0 ),
170+ 				newPlacementDeployment (3 , 3 ),
171+ 			},
172+ 			validateActions : func (t  * testing.T , actions  []clienttesting.Action ) {
173+ 				testingcommon .AssertActions (t , actions , "patch" )
174+ 				klusterlet  :=  & operatorapiv1.Klusterlet {}
175+ 				patchData  :=  actions [0 ].(clienttesting.PatchActionImpl ).Patch 
176+ 				err  :=  json .Unmarshal (patchData , klusterlet )
177+ 				if  err  !=  nil  {
178+ 					t .Fatal (err )
179+ 				}
180+ 				expectedCondition1  :=  testinghelper .NamedCondition (operatorapiv1 .ConditionHubRegistrationDegraded , "UnavailableRegistrationPod" , metav1 .ConditionTrue )
181+ 				expectedCondition2  :=  testinghelper .NamedCondition (operatorapiv1 .ConditionHubPlacementDegraded , "PlacementFunctional" , metav1 .ConditionFalse )
182+ 				testinghelper .AssertOnlyConditions (t , klusterlet , appliedCond , expectedCondition1 , expectedCondition2 )
183+ 			},
184+ 		},
148185		{
149186			name :            "registration functional and no placement deployment" ,
150187			queueKey :        testClusterManagerName ,
151188			clusterManagers : []runtime.Object {newClusterManager ()},
152- 			deployments :     []runtime.Object {newRegistrationDeployment (3 , 3 )},
189+ 			deployments :     []runtime.Object {newRegistrationDeployment (3 , 3 ),  newRegistrationWebhookDeployment ( 3 ,  3 ) },
153190			validateActions : func (t  * testing.T , actions  []clienttesting.Action ) {
154191				testingcommon .AssertActions (t , actions , "patch" )
155192				klusterlet  :=  & operatorapiv1.Klusterlet {}
0 commit comments