@@ -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 )
@@ -606,3 +607,30 @@ def test_scale_with_unauthorized_user_returns_403(self):
606607 response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
607608 HTTP_AUTHORIZATION = 'token {}' .format (unauthorized_token ))
608609 self .assertEqual (response .status_code , 403 )
610+
611+ def test_modified_procfile_from_build_removes_containers (self ):
612+ """
613+ When a new procfile is posted which removes a certain process type, deis should stop the
614+ existing containers.
615+ """
616+ url = '/v1/apps'
617+ response = self .client .post (url , HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
618+ self .assertEqual (response .status_code , 201 )
619+ app_id = response .data ['id' ]
620+ # post a new build
621+ build_url = "/v1/apps/{app_id}/builds" .format (** locals ())
622+ body = {'image' : 'autotest/example' , 'sha' : 'a' * 40 ,
623+ 'procfile' : json .dumps ({'web' : 'node server.js' , 'worker' : 'node worker.js' })}
624+ response = self .client .post (build_url , json .dumps (body ), content_type = 'application/json' ,
625+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
626+ url = "/v1/apps/{app_id}/scale" .format (** locals ())
627+ body = {'web' : 4 }
628+ response = self .client .post (url , json .dumps (body ), content_type = 'application/json' ,
629+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
630+ self .assertEqual (response .status_code , 204 )
631+ body = {'image' : 'autotest/example' , 'sha' : 'a' * 40 ,
632+ 'procfile' : json .dumps ({'worker' : 'node worker.js' })}
633+ response = self .client .post (build_url , json .dumps (body ), content_type = 'application/json' ,
634+ HTTP_AUTHORIZATION = 'token {}' .format (self .token ))
635+ self .assertEqual (response .status_code , 201 )
636+ self .assertEqual (Container .objects .filter (type = 'web' ).count (), 0 )
0 commit comments