@@ -7276,3 +7276,82 @@ func TestIsRollingSyncDeletionReversed(t *testing.T) {
72767276 })
72777277 }
72787278}
7279+
7280+ func TestReconcileProgressiveSyncDisabled (t * testing.T ) {
7281+ scheme := runtime .NewScheme ()
7282+ err := v1alpha1 .AddToScheme (scheme )
7283+ require .NoError (t , err )
7284+
7285+ kubeclientset := kubefake .NewSimpleClientset ([]runtime.Object {}... )
7286+
7287+ for _ , cc := range []struct {
7288+ name string
7289+ appSet v1alpha1.ApplicationSet
7290+ enableProgressiveSyncs bool
7291+ expectedAppStatuses []v1alpha1.ApplicationSetApplicationStatus
7292+ }{
7293+ {
7294+ name : "clears applicationStatus when Progressive Sync is disabled" ,
7295+ appSet : v1alpha1.ApplicationSet {
7296+ ObjectMeta : metav1.ObjectMeta {
7297+ Name : "test-appset" ,
7298+ Namespace : "argocd" ,
7299+ },
7300+ Spec : v1alpha1.ApplicationSetSpec {
7301+ Generators : []v1alpha1.ApplicationSetGenerator {},
7302+ Template : v1alpha1.ApplicationSetTemplate {},
7303+ },
7304+ Status : v1alpha1.ApplicationSetStatus {
7305+ ApplicationStatus : []v1alpha1.ApplicationSetApplicationStatus {
7306+ {
7307+ Application : "test-appset-guestbook" ,
7308+ Message : "Application resource became Healthy, updating status from Progressing to Healthy." ,
7309+ Status : "Healthy" ,
7310+ Step : "1" ,
7311+ },
7312+ },
7313+ },
7314+ },
7315+ enableProgressiveSyncs : false ,
7316+ expectedAppStatuses : nil ,
7317+ },
7318+ } {
7319+ t .Run (cc .name , func (t * testing.T ) {
7320+ client := fake .NewClientBuilder ().WithScheme (scheme ).WithObjects (& cc .appSet ).WithStatusSubresource (& cc .appSet ).WithIndex (& v1alpha1.Application {}, ".metadata.controller" , appControllerIndexer ).Build ()
7321+ metrics := appsetmetrics .NewFakeAppsetMetrics ()
7322+
7323+ argodb := db .NewDB ("argocd" , settings .NewSettingsManager (t .Context (), kubeclientset , "argocd" ), kubeclientset )
7324+
7325+ r := ApplicationSetReconciler {
7326+ Client : client ,
7327+ Scheme : scheme ,
7328+ Renderer : & utils.Render {},
7329+ Recorder : record .NewFakeRecorder (1 ),
7330+ Generators : map [string ]generators.Generator {},
7331+ ArgoDB : argodb ,
7332+ KubeClientset : kubeclientset ,
7333+ Metrics : metrics ,
7334+ EnableProgressiveSyncs : cc .enableProgressiveSyncs ,
7335+ }
7336+
7337+ req := ctrl.Request {
7338+ NamespacedName : types.NamespacedName {
7339+ Namespace : cc .appSet .Namespace ,
7340+ Name : cc .appSet .Name ,
7341+ },
7342+ }
7343+
7344+ // Run reconciliation
7345+ _ , err = r .Reconcile (t .Context (), req )
7346+ require .NoError (t , err )
7347+
7348+ // Fetch the updated ApplicationSet
7349+ var updatedAppSet v1alpha1.ApplicationSet
7350+ err = r .Get (t .Context (), req .NamespacedName , & updatedAppSet )
7351+ require .NoError (t , err )
7352+
7353+ // Verify the applicationStatus field
7354+ assert .Equal (t , cc .expectedAppStatuses , updatedAppSet .Status .ApplicationStatus , "applicationStatus should match expected value" )
7355+ })
7356+ }
7357+ }
0 commit comments