@@ -24,8 +24,10 @@ import (
24
24
"net"
25
25
"net/http"
26
26
"os"
27
+ "path"
27
28
rt "runtime"
28
29
"runtime/pprof"
30
+ "strings"
29
31
"sync"
30
32
"time"
31
33
@@ -944,7 +946,8 @@ var _ = Describe("manger.Manager", func() {
944
946
Expect (err ).NotTo (HaveOccurred ())
945
947
946
948
res := fmt .Errorf ("not ready yet" )
947
- err = m .AddReadyzCheck ("check" , func (_ * http.Request ) error { return res })
949
+ namedCheck := "check"
950
+ err = m .AddReadyzCheck (namedCheck , func (_ * http.Request ) error { return res })
948
951
Expect (err ).NotTo (HaveOccurred ())
949
952
950
953
s := make (chan struct {})
@@ -967,6 +970,20 @@ var _ = Describe("manger.Manager", func() {
967
970
resp , err = http .Get (readinessEndpoint )
968
971
Expect (err ).NotTo (HaveOccurred ())
969
972
Expect (resp .StatusCode ).To (Equal (http .StatusOK ))
973
+
974
+ // Check readiness path without trailing slash
975
+ readinessEndpoint = fmt .Sprint ("http://" , listener .Addr ().String (), strings .TrimSuffix (defaultReadinessEndpoint , "/" ))
976
+ res = nil
977
+ resp , err = http .Get (readinessEndpoint )
978
+ Expect (err ).NotTo (HaveOccurred ())
979
+ Expect (resp .StatusCode ).To (Equal (http .StatusOK ))
980
+
981
+ // Check readiness path for individual check
982
+ readinessEndpoint = fmt .Sprint ("http://" , listener .Addr ().String (), path .Join (defaultReadinessEndpoint , namedCheck ))
983
+ res = nil
984
+ resp , err = http .Get (readinessEndpoint )
985
+ Expect (err ).NotTo (HaveOccurred ())
986
+ Expect (resp .StatusCode ).To (Equal (http .StatusOK ))
970
987
})
971
988
972
989
It ("should serve liveness endpoint" , func (done Done ) {
@@ -975,7 +992,8 @@ var _ = Describe("manger.Manager", func() {
975
992
Expect (err ).NotTo (HaveOccurred ())
976
993
977
994
res := fmt .Errorf ("not alive" )
978
- err = m .AddHealthzCheck ("check" , func (_ * http.Request ) error { return res })
995
+ namedCheck := "check"
996
+ err = m .AddHealthzCheck (namedCheck , func (_ * http.Request ) error { return res })
979
997
Expect (err ).NotTo (HaveOccurred ())
980
998
981
999
s := make (chan struct {})
@@ -998,6 +1016,20 @@ var _ = Describe("manger.Manager", func() {
998
1016
resp , err = http .Get (livenessEndpoint )
999
1017
Expect (err ).NotTo (HaveOccurred ())
1000
1018
Expect (resp .StatusCode ).To (Equal (http .StatusOK ))
1019
+
1020
+ // Check liveness path without trailing slash
1021
+ livenessEndpoint = fmt .Sprint ("http://" , listener .Addr ().String (), strings .TrimSuffix (defaultLivenessEndpoint , "/" ))
1022
+ res = nil
1023
+ resp , err = http .Get (livenessEndpoint )
1024
+ Expect (err ).NotTo (HaveOccurred ())
1025
+ Expect (resp .StatusCode ).To (Equal (http .StatusOK ))
1026
+
1027
+ // Check readiness path for individual check
1028
+ livenessEndpoint = fmt .Sprint ("http://" , listener .Addr ().String (), path .Join (defaultLivenessEndpoint , namedCheck ))
1029
+ res = nil
1030
+ resp , err = http .Get (livenessEndpoint )
1031
+ Expect (err ).NotTo (HaveOccurred ())
1032
+ Expect (resp .StatusCode ).To (Equal (http .StatusOK ))
1001
1033
})
1002
1034
})
1003
1035
0 commit comments