@@ -262,7 +262,8 @@ def test_container_release(self):
262262 self .assertEqual (response .data ['results' ][0 ]['release' ], 'v2' )
263263 # post a new build
264264 url = "/v1/apps/{app_id}/builds" .format (** locals ())
265- body = {'image' : 'autotest/example' }
265+ # a web proctype must exist on the second build or else the container will be removed
266+ body = {'image' : 'autotest/example' , 'procfile' : {'web' : 'echo hi' }}
266267 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
267268 HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
268269 self .assertEqual (response .status_code , 201 )
@@ -565,3 +566,30 @@ def test_scale_with_unauthorized_user_returns_403(self):
565566 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
566567 HTTP_AUTHORIZATION = 'token {}' .format (unauthorized_token ))
567568 self .assertEqual (response .status_code , 403 )
569+
570+ def test_modified_procfile_from_build_removes_containers (self ):
571+ """
572+ When a new procfile is posted which removes a certain process type, deis should stop the
573+ existing containers.
574+ """
575+ url = '/v1/apps'
576+ response = self .client .post (url , HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
577+ self .assertEqual (response .status_code , 201 )
578+ app_id = response .data ['id' ]
579+ # post a new build
580+ build_url = "/v1/apps/{app_id}/builds" .format (** locals ())
581+ body = {'image' : 'autotest/example' , 'sha' : 'a' * 40 ,
582+ 'procfile' : json .dumps ({'web' : 'node server.js' , 'worker' : 'node worker.js' })}
583+ response = self .client .post (build_url , json .dumps (body ), content_type = 'application/json' ,
584+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
585+ url = "/v1/apps/{app_id}/scale" .format (** locals ())
586+ body = {'web' : 4 }
587+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
588+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
589+ self .assertEqual (response .status_code , 204 )
590+ body = {'image' : 'autotest/example' , 'sha' : 'a' * 40 ,
591+ 'procfile' : json .dumps ({'worker' : 'node worker.js' })}
592+ response = self .client .post (build_url , json .dumps (body ), content_type = 'application/json' ,
593+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
594+ self .assertEqual (response .status_code , 201 )
595+ self .assertEqual (Container .objects .filter (type = 'web' ).count (), 0 )
0 commit comments