@@ -56,6 +56,42 @@ module Diego
5656 expect ( bbs_apps_client ) . not_to have_received ( :stop_app )
5757 expect ( bbs_apps_client ) . to have_received ( :bump_freshness ) . once
5858 end
59+
60+ context 'when the process is a docker app' do
61+ let ( :app ) { AppModel . make ( :docker , droplet : DropletModel . make ( :docker ) ) }
62+ let ( :good_process ) { ProcessModel . make ( :docker , state : 'STARTED' , app : app ) }
63+
64+ context 'when diego_docker is enabled' do
65+ before do
66+ FeatureFlag . create ( name : 'diego_docker' , enabled : true )
67+ end
68+
69+ it 'does not touch lrps that are up to date and correct' do
70+ allow ( bbs_apps_client ) . to receive ( :desire_app )
71+ allow ( bbs_apps_client ) . to receive ( :update_app )
72+ allow ( bbs_apps_client ) . to receive ( :stop_app )
73+
74+ subject . sync
75+
76+ expect ( bbs_apps_client ) . not_to have_received ( :desire_app )
77+ expect ( bbs_apps_client ) . not_to have_received ( :update_app )
78+ expect ( bbs_apps_client ) . not_to have_received ( :stop_app )
79+ expect ( bbs_apps_client ) . to have_received ( :bump_freshness ) . once
80+ end
81+ end
82+
83+ context 'when diego_docker is disabled' do
84+ before do
85+ FeatureFlag . create ( name : 'diego_docker' , enabled : false )
86+ end
87+
88+ it 'deletes the LRP' do
89+ allow ( bbs_apps_client ) . to receive ( :stop_app )
90+ subject . sync
91+ expect ( bbs_apps_client ) . to have_received ( :stop_app ) . with ( ProcessGuid . from_process ( good_process ) )
92+ end
93+ end
94+ end
5995 end
6096
6197 context 'when a diego LRP is stale' do
@@ -85,6 +121,72 @@ module Diego
85121 expect ( bbs_apps_client ) . to have_received ( :bump_freshness ) . once
86122 end
87123
124+ context 'when the process is a cnb app' do
125+ let ( :app ) { AppModel . make ( :cnb , droplet : DropletModel . make ( :cnb ) ) }
126+ let! ( :stale_process ) { ProcessModel . make ( :cnb , state : 'STARTED' , app : app ) }
127+
128+ before do
129+ FeatureFlag . create ( name : 'diego_cnb' , enabled : true )
130+ end
131+
132+ context 'when diego_docker is disabled' do
133+ before do
134+ FeatureFlag . create ( name : 'diego_docker' , enabled : false )
135+ end
136+
137+ it 'updates the stale lrp' do
138+ allow ( bbs_apps_client ) . to receive ( :update_app )
139+ subject . sync
140+ expect ( bbs_apps_client ) . to have_received ( :update_app ) . with ( stale_process , stale_lrp_scheduling_info )
141+ expect ( bbs_apps_client ) . to have_received ( :bump_freshness ) . once
142+ end
143+ end
144+
145+ context 'when diego_docker is enabled' do
146+ before do
147+ FeatureFlag . create ( name : 'diego_docker' , enabled : true )
148+ end
149+
150+ it 'updates the stale lrp' do
151+ allow ( bbs_apps_client ) . to receive ( :update_app )
152+ subject . sync
153+ expect ( bbs_apps_client ) . to have_received ( :update_app ) . with ( stale_process , stale_lrp_scheduling_info )
154+ expect ( bbs_apps_client ) . to have_received ( :bump_freshness ) . once
155+ end
156+ end
157+ end
158+
159+ context 'when the process is a docker app' do
160+ let ( :app ) { AppModel . make ( :docker , droplet : DropletModel . make ( :docker ) ) }
161+ let! ( :stale_process ) { ProcessModel . make ( :docker , state : 'STARTED' , app : app ) }
162+
163+ context 'when diego_docker is enabled' do
164+ before do
165+ FeatureFlag . create ( name : 'diego_docker' , enabled : true )
166+ end
167+
168+ it 'updates the stale lrp' do
169+ allow ( bbs_apps_client ) . to receive ( :update_app )
170+ subject . sync
171+ expect ( bbs_apps_client ) . to have_received ( :update_app ) . with ( stale_process , stale_lrp_scheduling_info )
172+ expect ( bbs_apps_client ) . to have_received ( :bump_freshness ) . once
173+ end
174+ end
175+
176+ context 'when diego_docker is disabled' do
177+ before do
178+ FeatureFlag . create ( name : 'diego_docker' , enabled : false )
179+ end
180+
181+ it 'deletes the lrp' do
182+ allow ( bbs_apps_client ) . to receive ( :stop_app )
183+ subject . sync
184+ expect ( bbs_apps_client ) . to have_received ( :stop_app ) . with ( ProcessGuid . from_process ( stale_process ) )
185+ expect ( bbs_apps_client ) . to have_received ( :bump_freshness ) . once
186+ end
187+ end
188+ end
189+
88190 context 'when updating app fails' do
89191 # bbs_apps_client will raise ApiErrors as of right now, we should think about factoring that out so that
90192 # the background job doesn't have to deal with API concerns
0 commit comments