"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/commons/url"
"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/v1/deployment"
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/v1/healthcheck"
"gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/commons/logger"
)
-var deploymentExecutor deployment.Command
+var (
+ deploymentExecutor deployment.Command
+ healthcheckExecutor healthcheck.Command
+)
func init() {
deploymentExecutor = deployment.Executor{}
+ healthcheckExecutor = healthcheck.Executor{}
}
func setupRouter() (router *gin.Engine) {
}
healthcheck := v1.Group(url.Healthcheck())
- // healthcheck.GET()
+ {
+ healthcheck.GET("", healthcheckExecutor.Ping)
+ }
revision := v1.Group(url.IPS() + url.Revision())
// revision.GET()
--- /dev/null
+/*
+==================================================================================
+
+Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==================================================================================
+*/
+
+package healthcheck
+
+import (
+ "net/http"
+
+ "github.com/gin-gonic/gin"
+
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/commons/utils"
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/commons/logger"
+)
+
+type Command interface {
+ Ping(c *gin.Context)
+}
+
+type Executor struct {
+ Command
+}
+
+func init() {
+}
+
+func (Executor) Ping(c *gin.Context) {
+ logger.Logging(logger.DEBUG, "IN")
+ defer logger.Logging(logger.DEBUG, "OUT")
+
+ utils.WriteSuccess(c.Writer, http.StatusOK, nil)
+}
--- /dev/null
+/*
+==================================================================================
+
+Copyright (c) 2023 Samsung Electronics Co., Ltd. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==================================================================================
+*/
+
+package healthcheck
+
+import (
+ "net/http"
+ "net/http/httptest"
+ "testing"
+
+ "gerrit.o-ran-sc.org/r/aiml-fw/aihp/ips/kserve-adapter/pkg/api/commons/url"
+
+ "github.com/gin-gonic/gin"
+)
+
+func TestReceivedPingRequest_ExpectSuccess(t *testing.T) {
+ w := httptest.NewRecorder()
+
+ r, err := http.NewRequest("GET", url.V1()+url.Healthcheck(), nil)
+ if err != nil {
+ t.Errorf("http.NewRequest return Error : %s", err.Error())
+ }
+ r.Header.Set("Content-Type", "application/json")
+
+ c, _ := gin.CreateTestContext(w)
+ c.Request = r
+
+ status := Executor{}
+ status.Ping(c)
+}