@@ -25,19 +25,19 @@ func TestReadServerVersion(t *testing.T) {
2525 hc := NewDefaultHealthCheck (nil , newHealthCheckConfigForTest (), lg )
2626 backend , info := newBackendServer (t )
2727 backend .setServerVersion ("1.0" )
28- health := hc .Check (context .Background (), backend .sqlAddr , info )
28+ health := hc .Check (context .Background (), backend .sqlAddr , info , nil )
2929 require .Equal (t , "1.0" , health .ServerVersion )
3030 backend .stopSQLServer ()
3131 backend .setServerVersion ("2.0" )
3232 backend .startSQLServer ()
33- health = hc .Check (context .Background (), backend .sqlAddr , info )
33+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
3434 require .Equal (t , "2.0" , health .ServerVersion )
3535 backend .stopSQLServer ()
3636
3737 //test for respBody not ok
38- backend .mockHttpHandler .setHTTPRespBody ("" )
38+ backend .mockHttpHandler .setStatusRespBody ("" )
3939 backend .startSQLServer ()
40- health = hc .Check (context .Background (), backend .sqlAddr , info )
40+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
4141 require .False (t , health .Healthy )
4242 require .NotNil (t , health .PingErr )
4343 require .Equal (t , true , strings .Contains (health .PingErr .Error (), "unexpected end of JSON input" ))
@@ -52,37 +52,47 @@ func TestHealthCheck(t *testing.T) {
5252 hc := NewDefaultHealthCheck (nil , cfg , lg )
5353 backend , info := newBackendServer (t )
5454 backend .setServerVersion ("1.0" )
55- health := hc .Check (context .Background (), backend .sqlAddr , info )
55+ backend .setHasSigningCert (true )
56+ health := hc .Check (context .Background (), backend .sqlAddr , info , nil )
5657 require .True (t , health .Healthy )
5758
5859 backend .stopSQLServer ()
59- health = hc .Check (context .Background (), backend .sqlAddr , info )
60+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
6061 require .False (t , health .Healthy )
6162 backend .startSQLServer ()
62- health = hc .Check (context .Background (), backend .sqlAddr , info )
63+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
6364 require .True (t , health .Healthy )
64-
6565 backend .setHTTPResp (false )
66- health = hc .Check (context .Background (), backend .sqlAddr , info )
66+
67+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
6768 require .False (t , health .Healthy )
6869 require .NotContains (t , text .String (), "unmarshal body" )
6970 backend .setHTTPResp (true )
70- health = hc .Check (context .Background (), backend .sqlAddr , info )
71+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
7172 require .True (t , health .Healthy )
7273
7374 backend .setHTTPWait (time .Second + cfg .DialTimeout )
74- health = hc .Check (context .Background (), backend .sqlAddr , info )
75+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
7576 require .False (t , health .Healthy )
7677 backend .setHTTPWait (time .Duration (0 ))
77- health = hc .Check (context .Background (), backend .sqlAddr , info )
78+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
7879 require .True (t , health .Healthy )
7980
8081 backend .setSqlResp (false )
81- health = hc .Check (context .Background (), backend .sqlAddr , info )
82+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
8283 require .False (t , health .Healthy )
8384 backend .setSqlResp (true )
84- health = hc .Check (context .Background (), backend .sqlAddr , info )
85+ health = hc .Check (context .Background (), backend .sqlAddr , info , nil )
8586 require .True (t , health .Healthy )
87+
88+ require .True (t , health .SupportRedirection )
89+ health .lastCheckSigningCertTime = time.Time {}
90+ health = hc .Check (context .Background (), backend .sqlAddr , info , health )
91+ require .True (t , health .SupportRedirection )
92+ backend .setHasSigningCert (false )
93+ health .lastCheckSigningCertTime = time.Time {}
94+ health = hc .Check (context .Background (), backend .sqlAddr , info , health )
95+ require .False (t , health .SupportRedirection )
8696 backend .close ()
8797}
8898
@@ -105,7 +115,7 @@ func newBackendServer(t *testing.T) (*backendServer, *BackendInfo) {
105115 }
106116 backend .startHTTPServer ()
107117 backend .setHTTPResp (true )
108- backend .setHTTPRespBody ("" )
118+ backend .setStatusRespBody ("" )
109119 backend .setSqlResp (true )
110120 backend .startSQLServer ()
111121 return backend , & BackendInfo {
@@ -120,7 +130,7 @@ func (srv *backendServer) setServerVersion(version string) {
120130 GitHash : "" ,
121131 }
122132 body , _ := json .Marshal (resp )
123- srv .mockHttpHandler .setHTTPRespBody (string (body ))
133+ srv .mockHttpHandler .setStatusRespBody (string (body ))
124134}
125135
126136func (srv * backendServer ) startHTTPServer () {
0 commit comments