Skip to content

Commit

Permalink
Update API
Browse files Browse the repository at this point in the history
  • Loading branch information
seokho-son committed Nov 10, 2022
1 parent 02e25e8 commit 54153aa
Show file tree
Hide file tree
Showing 6 changed files with 198 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/api/grpc/server/mcis/control.go
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ func (s *MCISService) InstallBenchmarkAgentToMcis(ctx context.Context, req *pb.M
return nil, gc.ConvGrpcStatusErr(err, "", "MCISService.InstallBenchmarkAgentToMcis()")
}

content, err := mcis.InstallBenchmarkAgentToMcis(req.NsId, req.McisId, &mcisObj)
content, err := mcis.InstallBenchmarkAgentToMcis(req.NsId, req.McisId, &mcisObj, "")
if err != nil {
return nil, gc.ConvGrpcStatusErr(err, "", "MCISService.InstallBenchmarkAgentToMcis()")
}
Expand Down
62 changes: 62 additions & 0 deletions src/api/rest/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1130,6 +1130,59 @@ const docTemplate = `{
}
}
},
"/ns/{nsId}/benchmarkLatency/mcis/{mcisId}": {
"get": {
"description": "Run MCIS benchmark for network latency",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Infra service] MCIS Performance benchmarking (WIP)"
],
"summary": "Run MCIS benchmark for network latency",
"parameters": [
{
"type": "string",
"default": "system-purpose-common-ns",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "probe",
"description": "MCIS ID",
"name": "mcisId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.BenchmarkInfoArray"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
}
}
}
},
"/ns/{nsId}/cmd/mcis/{mcisId}": {
"post": {
"description": "Send a command to specified MCIS",
Expand Down Expand Up @@ -1497,6 +1550,15 @@ const docTemplate = `{
"schema": {
"$ref": "#/definitions/mcis.McisCmdReq"
}
},
{
"enum": [
"update"
],
"type": "string",
"description": "Option for checking update",
"name": "option",
"in": "query"
}
],
"responses": {
Expand Down
62 changes: 62 additions & 0 deletions src/api/rest/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -1122,6 +1122,59 @@
}
}
},
"/ns/{nsId}/benchmarkLatency/mcis/{mcisId}": {
"get": {
"description": "Run MCIS benchmark for network latency",
"consumes": [
"application/json"
],
"produces": [
"application/json"
],
"tags": [
"[Infra service] MCIS Performance benchmarking (WIP)"
],
"summary": "Run MCIS benchmark for network latency",
"parameters": [
{
"type": "string",
"default": "system-purpose-common-ns",
"description": "Namespace ID",
"name": "nsId",
"in": "path",
"required": true
},
{
"type": "string",
"default": "probe",
"description": "MCIS ID",
"name": "mcisId",
"in": "path",
"required": true
}
],
"responses": {
"200": {
"description": "OK",
"schema": {
"$ref": "#/definitions/mcis.BenchmarkInfoArray"
}
},
"404": {
"description": "Not Found",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
},
"500": {
"description": "Internal Server Error",
"schema": {
"$ref": "#/definitions/common.SimpleMsg"
}
}
}
}
},
"/ns/{nsId}/cmd/mcis/{mcisId}": {
"post": {
"description": "Send a command to specified MCIS",
Expand Down Expand Up @@ -1489,6 +1542,15 @@
"schema": {
"$ref": "#/definitions/mcis.McisCmdReq"
}
},
{
"enum": [
"update"
],
"type": "string",
"description": "Option for checking update",
"name": "option",
"in": "query"
}
],
"responses": {
Expand Down
42 changes: 42 additions & 0 deletions src/api/rest/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3137,6 +3137,42 @@ paths:
summary: Run MCIS benchmark for all performance metrics and return results
tags:
- '[Infra service] MCIS Performance benchmarking (WIP)'
/ns/{nsId}/benchmarkLatency/mcis/{mcisId}:
get:
consumes:
- application/json
description: Run MCIS benchmark for network latency
parameters:
- default: system-purpose-common-ns
description: Namespace ID
in: path
name: nsId
required: true
type: string
- default: probe
description: MCIS ID
in: path
name: mcisId
required: true
type: string
produces:
- application/json
responses:
"200":
description: OK
schema:
$ref: '#/definitions/mcis.BenchmarkInfoArray'
"404":
description: Not Found
schema:
$ref: '#/definitions/common.SimpleMsg'
"500":
description: Internal Server Error
schema:
$ref: '#/definitions/common.SimpleMsg'
summary: Run MCIS benchmark for network latency
tags:
- '[Infra service] MCIS Performance benchmarking (WIP)'
/ns/{nsId}/cmd/mcis/{mcisId}:
post:
consumes:
Expand Down Expand Up @@ -3389,6 +3425,12 @@ paths:
required: true
schema:
$ref: '#/definitions/mcis.McisCmdReq'
- description: Option for checking update
enum:
- update
in: query
name: option
type: string
produces:
- application/json
responses:
Expand Down
31 changes: 30 additions & 1 deletion src/api/rest/server/mcis/benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
// @Param nsId path string true "Namespace ID" default(ns01)
// @Param mcisId path string true "MCIS ID" default(mcis01)
// @Param mcisCmdReq body mcis.McisCmdReq true "MCIS Command Request"
// @Param option query string false "Option for checking update" Enums(update)
// @Success 200 {object} mcis.RestPostCmdMcisResponseWrapper
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
Expand All @@ -39,13 +40,14 @@ func RestPostInstallBenchmarkAgentToMcis(c echo.Context) error {

nsId := c.Param("nsId")
mcisId := c.Param("mcisId")
option := c.QueryParam("option")

req := &mcis.McisCmdReq{}
if err := c.Bind(req); err != nil {
return err
}

resultArray, err := mcis.InstallBenchmarkAgentToMcis(nsId, mcisId, req)
resultArray, err := mcis.InstallBenchmarkAgentToMcis(nsId, mcisId, req, option)
if err != nil {
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
Expand Down Expand Up @@ -108,6 +110,33 @@ func RestGetAllBenchmark(c echo.Context) error {
return c.JSON(http.StatusOK, result)
}

// RestGetLatencyBenchmark godoc
// @Summary Run MCIS benchmark for network latency
// @Description Run MCIS benchmark for network latency
// @Tags [Infra service] MCIS Performance benchmarking (WIP)
// @Accept json
// @Produce json
// @Param nsId path string true "Namespace ID" default(system-purpose-common-ns)
// @Param mcisId path string true "MCIS ID" default(probe)
// @Success 200 {object} mcis.BenchmarkInfoArray
// @Failure 404 {object} common.SimpleMsg
// @Failure 500 {object} common.SimpleMsg
// @Router /ns/{nsId}/benchmarkLatency/mcis/{mcisId} [get]
func RestGetBenchmarkLatency(c echo.Context) error {

nsId := c.Param("nsId")
mcisId := c.Param("mcisId")

result, err := mcis.RunLatencyBenchmark(nsId, mcisId, "")
if err != nil {
mapA := map[string]string{"message": err.Error()}
return c.JSON(http.StatusInternalServerError, &mapA)
}

common.PrintJsonPretty(*result)
return c.JSON(http.StatusOK, result)
}

type RestGetBenchmarkRequest struct {
Host string `json:"host"`
}
Expand Down
1 change: 1 addition & 0 deletions src/api/rest/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ func RunServer(port string) {
g.POST("/:nsId/installBenchmarkAgent/mcis/:mcisId", rest_mcis.RestPostInstallBenchmarkAgentToMcis)
g.POST("/:nsId/benchmark/mcis/:mcisId", rest_mcis.RestGetBenchmark)
g.POST("/:nsId/benchmarkAll/mcis/:mcisId", rest_mcis.RestGetAllBenchmark)
g.GET("/:nsId/benchmarkLatency/mcis/:mcisId", rest_mcis.RestGetBenchmarkLatency)

//MCIS AUTO Policy
g.POST("/:nsId/policy/mcis/:mcisId", rest_mcis.RestPostMcisPolicy)
Expand Down

0 comments on commit 54153aa

Please sign in to comment.