mirror of
https://github.com/containers/podman.git
synced 2025-06-26 12:56:45 +08:00
Merge pull request #7165 from jwhonce/issues/7008
Add versioned _ping endpoint
This commit is contained in:
@ -9,9 +9,8 @@ import (
|
||||
|
||||
func (s *APIServer) registerPingHandlers(r *mux.Router) error {
|
||||
|
||||
r.Handle("/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodGet)
|
||||
r.Handle("/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodHead)
|
||||
|
||||
r.Handle("/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead)
|
||||
r.Handle(VersionedPath("/_ping"), s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead)
|
||||
// swagger:operation GET /libpod/_ping libpod libpodPingGet
|
||||
// ---
|
||||
// summary: Ping service
|
||||
@ -62,7 +61,7 @@ func (s *APIServer) registerPingHandlers(r *mux.Router) error {
|
||||
// determine if talking to Podman engine or another engine
|
||||
// 500:
|
||||
// $ref: "#/responses/InternalError"
|
||||
r.Handle("/libpod/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodGet)
|
||||
r.Handle("/libpod/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodHead)
|
||||
r.Handle("/libpod/_ping", s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead)
|
||||
r.Handle(VersionedPath("/libpod/_ping"), s.APIHandler(compat.Ping)).Methods(http.MethodGet, http.MethodHead)
|
||||
return nil
|
||||
}
|
||||
|
@ -5,9 +5,15 @@
|
||||
|
||||
# NOTE: paths with a leading slash will be interpreted as-is;
|
||||
# paths without will have '/v1.40/' prepended.
|
||||
t GET /_ping 200 OK
|
||||
t GET /_ping 200 OK
|
||||
t HEAD /_ping 200
|
||||
t GET /libpod/_ping 200 OK
|
||||
t HEAD /libpod/_ping 200
|
||||
|
||||
t GET _ping 200 OK
|
||||
t HEAD _ping 200
|
||||
t GET libpod/_ping 200 OK
|
||||
t HEAD libpod/_ping 200
|
||||
|
||||
for i in /version version; do
|
||||
t GET $i 200 \
|
||||
|
@ -13,9 +13,11 @@ from multiprocessing import Process
|
||||
import requests
|
||||
from dateutil.parser import parse
|
||||
|
||||
PODMAN_URL = "http://localhost:8080"
|
||||
|
||||
|
||||
def _url(path):
|
||||
return "http://localhost:8080/v1.0.0/libpod" + path
|
||||
return PODMAN_URL + "/v1.0.0/libpod" + path
|
||||
|
||||
|
||||
def podman():
|
||||
@ -205,7 +207,21 @@ class TestApi(unittest.TestCase):
|
||||
search.join(timeout=10)
|
||||
self.assertFalse(search.is_alive(), "/images/search took too long")
|
||||
|
||||
def validateObjectFields(self, buffer):
|
||||
def test_ping(self):
|
||||
r = requests.get(PODMAN_URL + "/_ping")
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
|
||||
r = requests.head(PODMAN_URL + "/_ping")
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
|
||||
r = requests.get(_url("/_ping"))
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
|
||||
r = requests.get(_url("/_ping"))
|
||||
self.assertEqual(r.status_code, 200, r.text)
|
||||
|
||||
|
||||
def validateObjectFields(self, buffer):
|
||||
objs = json.loads(buffer)
|
||||
if not isinstance(objs, dict):
|
||||
for o in objs:
|
||||
@ -214,6 +230,5 @@ class TestApi(unittest.TestCase):
|
||||
_ = objs["Id"]
|
||||
return objs
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user