@@ -4081,6 +4081,207 @@ func TestSetResourcePlacementStatusPerCluster(t *testing.T) {
40814081 },
40824082 },
40834083 },
4084+ {
4085+ name : "drifts and configuration diffs" ,
4086+ binding : & fleetv1beta1.ClusterResourceBinding {
4087+ ObjectMeta : metav1.ObjectMeta {
4088+ Name : bindingName ,
4089+ Generation : 1 ,
4090+ },
4091+ Spec : fleetv1beta1.ResourceBindingSpec {
4092+ ResourceSnapshotName : resourceSnapshotName ,
4093+ ResourceOverrideSnapshots : []fleetv1beta1.NamespacedName {},
4094+ ClusterResourceOverrideSnapshots : []string {},
4095+ SchedulingPolicySnapshotName : fmt .Sprintf (fleetv1beta1 .PolicySnapshotNameFmt , testName , 0 ),
4096+ TargetCluster : cluster ,
4097+ },
4098+ Status : fleetv1beta1.ResourceBindingStatus {
4099+ FailedPlacements : []fleetv1beta1.FailedResourcePlacement {
4100+ {
4101+ ResourceIdentifier : fleetv1beta1.ResourceIdentifier {
4102+ Group : "" ,
4103+ Version : "v1" ,
4104+ Kind : "ConfigMap" ,
4105+ Name : "cm-1" ,
4106+ Namespace : "ns-1" ,
4107+ },
4108+ Condition : metav1.Condition {
4109+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
4110+ Status : metav1 .ConditionFalse ,
4111+ },
4112+ },
4113+ },
4114+ DriftedPlacements : []fleetv1beta1.DriftedResourcePlacement {
4115+ {
4116+ ResourceIdentifier : fleetv1beta1.ResourceIdentifier {
4117+ Group : "" ,
4118+ Version : "v1" ,
4119+ Kind : "ConfigMap" ,
4120+ Name : "cm-1" ,
4121+ Namespace : "ns-1" ,
4122+ },
4123+ ObservationTime : metav1.Time {Time : time .Now ()},
4124+ TargetClusterObservedGeneration : 1 ,
4125+ FirstDriftedObservedTime : metav1.Time {Time : time .Now ()},
4126+ ObservedDrifts : []fleetv1beta1.PatchDetail {
4127+ {
4128+ Path : "/data" ,
4129+ ValueInMember : "k=1" ,
4130+ ValueInHub : "k=2" ,
4131+ },
4132+ },
4133+ },
4134+ },
4135+ DiffedPlacements : []fleetv1beta1.DiffedResourcePlacement {
4136+ {
4137+ ResourceIdentifier : fleetv1beta1.ResourceIdentifier {
4138+ Group : "apps" ,
4139+ Version : "v1" ,
4140+ Kind : "Deployment" ,
4141+ Name : "app-1" ,
4142+ Namespace : "ns-1" ,
4143+ },
4144+ ObservationTime : metav1.Time {Time : time .Now ()},
4145+ TargetClusterObservedGeneration : 2 ,
4146+ FirstDiffedObservedTime : metav1.Time {Time : time .Now ()},
4147+ ObservedDiffs : []fleetv1beta1.PatchDetail {
4148+ {
4149+ Path : "/spec/replicas" ,
4150+ ValueInMember : "1" ,
4151+ ValueInHub : "2" ,
4152+ },
4153+ },
4154+ },
4155+ },
4156+ Conditions : []metav1.Condition {
4157+ {
4158+ Status : metav1 .ConditionTrue ,
4159+ Type : string (fleetv1beta1 .ResourceBindingRolloutStarted ),
4160+ Reason : condition .RolloutStartedReason ,
4161+ ObservedGeneration : 1 ,
4162+ },
4163+ {
4164+ Status : metav1 .ConditionTrue ,
4165+ Type : string (fleetv1beta1 .ResourceBindingOverridden ),
4166+ Reason : condition .OverriddenSucceededReason ,
4167+ ObservedGeneration : 1 ,
4168+ },
4169+ {
4170+ Status : metav1 .ConditionTrue ,
4171+ Type : string (fleetv1beta1 .ResourceBindingWorkSynchronized ),
4172+ Reason : condition .WorkSynchronizedReason ,
4173+ ObservedGeneration : 1 ,
4174+ },
4175+ {
4176+ Status : metav1 .ConditionFalse ,
4177+ Type : string (fleetv1beta1 .ResourceBindingApplied ),
4178+ Reason : condition .ApplySucceededReason ,
4179+ ObservedGeneration : 1 ,
4180+ },
4181+ {
4182+ Status : metav1 .ConditionFalse ,
4183+ Type : string (fleetv1beta1 .ResourceBindingAvailable ),
4184+ Reason : condition .NotAvailableYetReason ,
4185+ ObservedGeneration : 1 ,
4186+ },
4187+ },
4188+ },
4189+ },
4190+ want : []metav1.ConditionStatus {
4191+ metav1 .ConditionTrue ,
4192+ metav1 .ConditionTrue ,
4193+ metav1 .ConditionTrue ,
4194+ metav1 .ConditionFalse ,
4195+ },
4196+ wantStatus : fleetv1beta1.ResourcePlacementStatus {
4197+ ClusterName : cluster ,
4198+ ApplicableResourceOverrides : []fleetv1beta1.NamespacedName {},
4199+ ApplicableClusterResourceOverrides : []string {},
4200+ FailedPlacements : []fleetv1beta1.FailedResourcePlacement {
4201+ {
4202+ ResourceIdentifier : fleetv1beta1.ResourceIdentifier {
4203+ Group : "" ,
4204+ Version : "v1" ,
4205+ Kind : "ConfigMap" ,
4206+ Name : "cm-1" ,
4207+ Namespace : "ns-1" ,
4208+ },
4209+ Condition : metav1.Condition {
4210+ Type : fleetv1beta1 .WorkConditionTypeApplied ,
4211+ Status : metav1 .ConditionFalse ,
4212+ },
4213+ },
4214+ },
4215+ DriftedPlacements : []fleetv1beta1.DriftedResourcePlacement {
4216+ {
4217+ ResourceIdentifier : fleetv1beta1.ResourceIdentifier {
4218+ Group : "" ,
4219+ Version : "v1" ,
4220+ Kind : "ConfigMap" ,
4221+ Name : "cm-1" ,
4222+ Namespace : "ns-1" ,
4223+ },
4224+ ObservationTime : metav1.Time {Time : time .Now ()},
4225+ TargetClusterObservedGeneration : 1 ,
4226+ FirstDriftedObservedTime : metav1.Time {Time : time .Now ()},
4227+ ObservedDrifts : []fleetv1beta1.PatchDetail {
4228+ {
4229+ Path : "/data" ,
4230+ ValueInMember : "k=1" ,
4231+ ValueInHub : "k=2" ,
4232+ },
4233+ },
4234+ },
4235+ },
4236+ DiffedPlacements : []fleetv1beta1.DiffedResourcePlacement {
4237+ {
4238+ ResourceIdentifier : fleetv1beta1.ResourceIdentifier {
4239+ Group : "apps" ,
4240+ Version : "v1" ,
4241+ Kind : "Deployment" ,
4242+ Name : "app-1" ,
4243+ Namespace : "ns-1" ,
4244+ },
4245+ ObservationTime : metav1.Time {Time : time .Now ()},
4246+ TargetClusterObservedGeneration : 2 ,
4247+ FirstDiffedObservedTime : metav1.Time {Time : time .Now ()},
4248+ ObservedDiffs : []fleetv1beta1.PatchDetail {
4249+ {
4250+ Path : "/spec/replicas" ,
4251+ ValueInMember : "1" ,
4252+ ValueInHub : "2" ,
4253+ },
4254+ },
4255+ },
4256+ },
4257+ Conditions : []metav1.Condition {
4258+ {
4259+ Status : metav1 .ConditionTrue ,
4260+ Type : string (fleetv1beta1 .ResourceBindingRolloutStarted ),
4261+ Reason : condition .RolloutStartedReason ,
4262+ ObservedGeneration : crpGeneration ,
4263+ },
4264+ {
4265+ Status : metav1 .ConditionTrue ,
4266+ Type : string (fleetv1beta1 .ResourceBindingOverridden ),
4267+ Reason : condition .OverriddenSucceededReason ,
4268+ ObservedGeneration : crpGeneration ,
4269+ },
4270+ {
4271+ Status : metav1 .ConditionTrue ,
4272+ Type : string (fleetv1beta1 .ResourceBindingWorkSynchronized ),
4273+ Reason : condition .WorkSynchronizedReason ,
4274+ ObservedGeneration : crpGeneration ,
4275+ },
4276+ {
4277+ Status : metav1 .ConditionFalse ,
4278+ Type : string (fleetv1beta1 .ResourceBindingApplied ),
4279+ Reason : condition .ApplySucceededReason ,
4280+ ObservedGeneration : crpGeneration ,
4281+ },
4282+ },
4283+ },
4284+ },
40844285 }
40854286 for _ , tc := range tests {
40864287 t .Run (tc .name , func (t * testing.T ) {
0 commit comments