@@ -773,39 +773,6 @@ def test_unauthorized_user_cannot_modify_config(self, mock_requests):
773773 response = self .client .post (url , body )
774774 self .assertEqual (response .status_code , 403 )
775775
776- def test_healthchecks (self , mock_requests ):
777- """
778- Test that healthchecks can be applied
779- """
780- response = self .client .post ('/v2/apps' )
781- self .assertEqual (response .status_code , 201 , response .data )
782- app_id = response .data ['id' ]
783-
784- # Set a healthcheck option before URL is around (URL is required for full setting)
785- resp = self .client .post (
786- '/v2/apps/{app_id}/config' .format (** locals ()),
787- {'values' : json .dumps ({'HEALTHCHECK_INITIAL_DELAY' : '25' })}
788- )
789- self .assertEqual (resp .status_code , 201 , response .data )
790- self .assertIn ('HEALTHCHECK_INITIAL_DELAY' , resp .data ['values' ])
791- self .assertEqual (resp .data ['values' ]['HEALTHCHECK_INITIAL_DELAY' ], '25' )
792-
793- # Set healthcheck URL to get defaults set
794- resp = self .client .post (
795- '/v2/apps/{app_id}/config' .format (** locals ()),
796- {'values' : json .dumps ({'HEALTHCHECK_URL' : '/health' })}
797- )
798- self .assertEqual (resp .status_code , 201 , response .data )
799- self .assertIn ('HEALTHCHECK_URL' , resp .data ['values' ])
800- self .assertEqual (resp .data ['values' ]['HEALTHCHECK_URL' ], '/health' )
801-
802- # post a new build
803- response = self .client .post (
804- "/v2/apps/{app_id}/builds" .format (** locals ()),
805- {'image' : 'quay.io/autotest/example' }
806- )
807- self .assertEqual (response .status_code , 201 , response .data )
808-
809776 def test_healthchecks_validations (self , mock_requests ):
810777 """
811778 Test that healthchecks validations work
@@ -929,8 +896,8 @@ def test_config_healthchecks_legacy(self, mock_requests):
929896 {'values' : json .dumps ({'HEALTHCHECK_URL' : '/health' })}
930897 )
931898 self .assertEqual (response .status_code , 201 , response .data )
932- self . assertIn ( 'HEALTHCHECK_URL' , response . data [ 'values' ])
933- self .assertEqual ( response .data ['values' ][ 'HEALTHCHECK_URL' ], '/health' )
899+ # this gets migrated to the new healtcheck format
900+ self .assertNotIn ( 'HEALTHCHECK_URL' , response .data ['values' ])
934901 # legacy defaults
935902 expected = {
936903 'livenessProbe' : {
@@ -942,6 +909,16 @@ def test_config_healthchecks_legacy(self, mock_requests):
942909 'httpGet' : {
943910 'path' : '/health'
944911 }
912+ },
913+ 'readinessProbe' : {
914+ 'initialDelaySeconds' : 50 ,
915+ 'timeoutSeconds' : 50 ,
916+ 'periodSeconds' : 10 ,
917+ 'successThreshold' : 1 ,
918+ 'failureThreshold' : 3 ,
919+ 'httpGet' : {
920+ 'path' : '/health'
921+ }
945922 }
946923 }
947924 actual = app .config_set .latest ().healthcheck
@@ -951,6 +928,7 @@ def test_config_healthchecks_legacy(self, mock_requests):
951928 '/v2/apps/{app.id}/config' .format (** locals ()),
952929 {
953930 'values' : json .dumps ({
931+ 'HEALTHCHECK_URL' : '/health' ,
954932 'HEALTHCHECK_INITIAL_DELAY' : '25' ,
955933 'HEALTHCHECK_TIMEOUT' : '10' ,
956934 'HEALTHCHECK_PERIOD_SECONDS' : '5' ,
@@ -959,8 +937,8 @@ def test_config_healthchecks_legacy(self, mock_requests):
959937 }
960938 )
961939 self .assertEqual (response .status_code , 201 , response .data )
962- self . assertIn ( 'HEALTHCHECK_INITIAL_DELAY' , response . data [ 'values' ])
963- self .assertEqual ( response .data ['values' ][ 'HEALTHCHECK_INITIAL_DELAY' ], '25' )
940+ # this gets migrated to the new healtcheck format
941+ self .assertNotIn ( 'HEALTHCHECK_INITIAL_DELAY' , response .data ['values' ])
964942 expected ['livenessProbe' ] = {
965943 'initialDelaySeconds' : 25 ,
966944 'timeoutSeconds' : 10 ,
@@ -971,5 +949,6 @@ def test_config_healthchecks_legacy(self, mock_requests):
971949 'path' : '/health'
972950 }
973951 }
952+ expected ['readinessProbe' ] = expected ['livenessProbe' ]
974953 actual = app .config_set .latest ().healthcheck
975954 self .assertEqual (expected , actual )
0 commit comments