You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2020/09/07 14:30:19 UTC

[GitHub] [apisix-dashboard] liuxiran opened a new pull request #450: feat: add publish status to route in manager api

liuxiran opened a new pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450


   Please answer these questions before submitting a pull request
   
   - Why submit this pull request?
   - [ ] Bug fix
   - [ ] New feature provided
   - [ ] Improve performance
   
   - Related issues
   issue #437 manage api
   ___
   ### Bugfix
   - Description
   
   - How to fix?
   
   ___
   ### New feature or improvement
   - Describe the details and related test reports.
   
   1. add a Column to route, called `status`
   
   1. `status = true`, means create a new route in both mysql and apisix;  `status=false`: means create a route only in mysql
   
   1. modified the logic of editing and deleting route at the same time, 
   
   1. add manager apis to support change route `status`


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r485304213



##########
File path: api/route/route.go
##########
@@ -34,10 +34,10 @@ func AppendRoute(r *gin.Engine) *gin.Engine {
 	r.GET("/apisix/admin/routes/:rid", findRoute)
 	r.GET("/apisix/admin/routes", listRoute)
 	r.PUT("/apisix/admin/routes/:rid", updateRoute)
-	r.PUT("/apisix/admin/publishroutes/:rid", publishRoute)
+	r.PUT("/apisix/admin/routes/:rid/publish", publishRoute)
 	r.DELETE("/apisix/admin/routes/:rid", deleteRoute)
 	r.GET("/apisix/admin/notexist/routes", isRouteExist)
-	r.PUT("/apisix/admin/offlineroutes/:rid", offlineRoute)
+	r.PUT("/apisix/admin/routes/:rid/offline", offlineRoute)

Review comment:
       seems work well :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r486077100



##########
File path: api/script/db/schema.sql
##########
@@ -18,7 +18,7 @@ CREATE TABLE `routes` (
   `update_time` bigint(20),
   `route_group_id` varchar(64) NOT NULL,
   `route_group_name` varchar(64) NOT NULL,
-
+  `status` tinyint(1),

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-689467089


   the reason for ci failed is the same with https://github.com/apache/apisix-dashboard/issues/452#issuecomment-688666125 , we updated the logic of routeGroup. this pr is depend on pr #460 
   
   @juzhiyuan so sorry for the interdependence between these prs. I'll pay attention next time~!


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r488259506



##########
File path: api/route/route_test.go
##########
@@ -98,39 +153,41 @@ func TestCreateRouteWithCreateNewGroup(t *testing.T) {
       "vars":[],
       "upstream":{"type":"roundrobin","nodes":{"127.0.0.1:443":1},
       "timeout":{"connect":6000,"send":6000,"read":6000}},
-      "upstream_header":{},
-      "route_group_id":"",
-      "route_group_name":"route-create-test-create-group"
+      "upstream_header":{}
 }`).Expect(t).
-		Status(http.StatusOK).
-		End()
+	Status(http.StatusOK).
+	End()
+	route, _ := getRouteByName("api-test")
+	// publish route
+	handler.Put(uriPrefix + "/routes/" + route.ID.String() + "/publish").Expect(t).Status(http.StatusOK).End()
 }
 
-func TestCreateRouteWithDuplicateGroupName(t *testing.T) {
-	// create route with duplicate route group name
+func TestOfflineRoute(t *testing.T) {
+	// create route
 	handler.Post(uriPrefix+"/routes").
 		Header("Authorization", token).
 		JSON(`{
-      "name":"api-test",
-      "desc":"api-test",
+      "name":"api-test-published",
+      "desc":"",
       "priority":0,
       "protocols":["http"],
-      "hosts":["test.com"],
+      "hosts":["test1.com"],
       "paths":["/*"],
       "methods":["GET","HEAD","POST","PUT","DELETE","OPTIONS","PATCH"],
-      "status":false,
+      "status":true,

Review comment:
       'offline' is a `PUT` type API, so create a route online first, then we could  do `offline` :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-689477596


   > @liuxiran ok, so just waiting for others' review :DD
   
   thanks for your time~


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan merged pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
juzhiyuan merged pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r485300682



##########
File path: api/route/route.go
##########
@@ -34,10 +34,10 @@ func AppendRoute(r *gin.Engine) *gin.Engine {
 	r.GET("/apisix/admin/routes/:rid", findRoute)
 	r.GET("/apisix/admin/routes", listRoute)
 	r.PUT("/apisix/admin/routes/:rid", updateRoute)
-	r.PUT("/apisix/admin/publishroutes/:rid", publishRoute)
+	r.PUT("/apisix/admin/routes/:rid/publish", publishRoute)
 	r.DELETE("/apisix/admin/routes/:rid", deleteRoute)
 	r.GET("/apisix/admin/notexist/routes", isRouteExist)
-	r.PUT("/apisix/admin/offlineroutes/:rid", offlineRoute)
+	r.PUT("/apisix/admin/routes/:rid/offline", offlineRoute)

Review comment:
       not sure if `r.GET("/apisix/admin/notexist/routes", isRouteExist)` will overrite this line, if it doesn't, then looks good to me :D




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] moonming commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
moonming commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-688604763


   nice work @liuxiran 👍 
   it will be better if you can add some test cases.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-691470306






----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r486072028



##########
File path: api/route/route.go
##########
@@ -34,11 +34,100 @@ func AppendRoute(r *gin.Engine) *gin.Engine {
 	r.GET("/apisix/admin/routes/:rid", findRoute)
 	r.GET("/apisix/admin/routes", listRoute)
 	r.PUT("/apisix/admin/routes/:rid", updateRoute)
+	r.PUT("/apisix/admin/routes/:rid/publish", publishRoute)
 	r.DELETE("/apisix/admin/routes/:rid", deleteRoute)
 	r.GET("/apisix/admin/notexist/routes", isRouteExist)
+	r.PUT("/apisix/admin/routes/:rid/offline", offlineRoute)
 	return r
 }
 
+func publishRoute(c *gin.Context) {
+	rid := c.Param("rid")
+	r := &service.Route{}
+	tx := conf.DB().Begin()
+	if err := tx.Model(&service.Route{}).Where("id = ?", rid).Update("status", true).Find(&r).Error; err != nil {
+		tx.Rollback()
+		e := errno.FromMessage(errno.RoutePublishError, err.Error())
+		logger.Error(e.Msg)
+		c.AbortWithStatusJSON(http.StatusInternalServerError, e.Response())
+		return
+	} else {
+		routeRequest := &service.RouteRequest{}
+		if err := json.Unmarshal([]byte(r.Content), routeRequest); err != nil {
+			tx.Rollback()
+			e := errno.FromMessage(errno.RoutePublishError, err.Error())
+			logger.Error(e.Msg)
+			c.AbortWithStatusJSON(http.StatusInternalServerError, e.Response())
+			return
+		}
+		arr := service.ToApisixRequest(routeRequest)
+		var resp *service.ApisixRouteResponse
+		if resp, err = arr.Create(rid); err != nil {

Review comment:
       in this pr, we divided the process of creating a route into two steps:
   create a route (without publish)only in mysql, and do `publish` to create a route in apisix.
   
   so here we use `create`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r488259506



##########
File path: api/route/route_test.go
##########
@@ -98,39 +153,41 @@ func TestCreateRouteWithCreateNewGroup(t *testing.T) {
       "vars":[],
       "upstream":{"type":"roundrobin","nodes":{"127.0.0.1:443":1},
       "timeout":{"connect":6000,"send":6000,"read":6000}},
-      "upstream_header":{},
-      "route_group_id":"",
-      "route_group_name":"route-create-test-create-group"
+      "upstream_header":{}
 }`).Expect(t).
-		Status(http.StatusOK).
-		End()
+	Status(http.StatusOK).
+	End()
+	route, _ := getRouteByName("api-test")
+	// publish route
+	handler.Put(uriPrefix + "/routes/" + route.ID.String() + "/publish").Expect(t).Status(http.StatusOK).End()
 }
 
-func TestCreateRouteWithDuplicateGroupName(t *testing.T) {
-	// create route with duplicate route group name
+func TestOfflineRoute(t *testing.T) {
+	// create route
 	handler.Post(uriPrefix+"/routes").
 		Header("Authorization", token).
 		JSON(`{
-      "name":"api-test",
-      "desc":"api-test",
+      "name":"api-test-published",
+      "desc":"",
       "priority":0,
       "protocols":["http"],
-      "hosts":["test.com"],
+      "hosts":["test1.com"],
       "paths":["/*"],
       "methods":["GET","HEAD","POST","PUT","DELETE","OPTIONS","PATCH"],
-      "status":false,
+      "status":true,

Review comment:
       create a route online first, then we could  do `offline` :)




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
nic-chen commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-689980972


   > > the reason for ci failed is the same with [#452 (comment)](https://github.com/apache/apisix-dashboard/issues/452#issuecomment-688666125) , we updated the logic of routeGroup. this pr is depend on pr #460
   > 
   > > 
   > 
   > > @juzhiyuan so sorry for the interdependence between these prs. I'll pay attention next time~!
   > 
   > 
   > 
   > @nic-chen maybe this reason?
   
   maybe.so we should handle that pr first.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-689924915


   > the reason for ci failed is the same with [#452 (comment)](https://github.com/apache/apisix-dashboard/issues/452#issuecomment-688666125) , we updated the logic of routeGroup. this pr is depend on pr #460
   > 
   > @juzhiyuan so sorry for the interdependence between these prs. I'll pay attention next time~!
   
   @nic-chen maybe this reason?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-691470306


   @nic-chen https://github.com/apache/apisix-dashboard/pull/460 has been merged, please take a look.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r488057502



##########
File path: api/route/route_test.go
##########
@@ -98,39 +153,41 @@ func TestCreateRouteWithCreateNewGroup(t *testing.T) {
       "vars":[],
       "upstream":{"type":"roundrobin","nodes":{"127.0.0.1:443":1},
       "timeout":{"connect":6000,"send":6000,"read":6000}},
-      "upstream_header":{},
-      "route_group_id":"",
-      "route_group_name":"route-create-test-create-group"
+      "upstream_header":{}
 }`).Expect(t).
-		Status(http.StatusOK).
-		End()
+	Status(http.StatusOK).
+	End()
+	route, _ := getRouteByName("api-test")
+	// publish route
+	handler.Put(uriPrefix + "/routes/" + route.ID.String() + "/publish").Expect(t).Status(http.StatusOK).End()
 }
 
-func TestCreateRouteWithDuplicateGroupName(t *testing.T) {
-	// create route with duplicate route group name
+func TestOfflineRoute(t *testing.T) {
+	// create route
 	handler.Post(uriPrefix+"/routes").
 		Header("Authorization", token).
 		JSON(`{
-      "name":"api-test",
-      "desc":"api-test",
+      "name":"api-test-published",
+      "desc":"",
       "priority":0,
       "protocols":["http"],
-      "hosts":["test.com"],
+      "hosts":["test1.com"],
       "paths":["/*"],
       "methods":["GET","HEAD","POST","PUT","DELETE","OPTIONS","PATCH"],
-      "status":false,
+      "status":true,

Review comment:
       why is true for offline ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
nic-chen commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r486000136



##########
File path: api/route/route_test.go
##########
@@ -0,0 +1,51 @@
+package route
+
+import (
+	"github.com/apisix/manager-api/conf"
+	"github.com/apisix/manager-api/service"
+	"net/http"
+	"testing"
+)
+
+// publish route
+func TestPublishRoute(t *testing.T) {
+
+	// create route
+	handler.Post(uriPrefix+"/routes").
+		Header("Authorization", token).
+		JSON(`{
+      "name":"api-test",
+      "desc":"",
+      "priority":0,
+      "protocols":["http"],
+      "hosts":["test1.com"],
+      "paths":["/*"],
+      "methods":["GET","HEAD","POST","PUT","DELETE","OPTIONS","PATCH"],
+      "status":false,
+      "upstream_protocol":"keep",
+      "plugins":{},
+      "uris":["/*"],
+      "vars":[],
+      "upstream":{"type":"roundrobin","nodes":{"127.0.0.1:443":1},
+      "timeout":{"connect":6000,"send":6000,"read":6000}},
+      "upstream_header":{}
+}`).Expect(t).
+		Status(http.StatusOK).
+		End()
+	route, _ := getRouteByName("api-test")
+
+	// publish route
+	handler.Put(uriPrefix + "/routes/" + route.ID.String() + "publish").Expect(t).Status(http.StatusOK).End()
+	// offline route
+	handler.Put(uriPrefix + "/routes/" + route.ID.String() + "offline").Expect(t).Status(http.StatusOK).End()
+
+}
+

Review comment:
       `offline` also requires test cases
   

##########
File path: api/script/db/schema.sql
##########
@@ -18,7 +18,7 @@ CREATE TABLE `routes` (
   `update_time` bigint(20),
   `route_group_id` varchar(64) NOT NULL,
   `route_group_name` varchar(64) NOT NULL,
-
+  `status` tinyint(1),

Review comment:
       deed a default value ​​for compatibility.

##########
File path: api/route/route.go
##########
@@ -34,11 +34,100 @@ func AppendRoute(r *gin.Engine) *gin.Engine {
 	r.GET("/apisix/admin/routes/:rid", findRoute)
 	r.GET("/apisix/admin/routes", listRoute)
 	r.PUT("/apisix/admin/routes/:rid", updateRoute)
+	r.PUT("/apisix/admin/routes/:rid/publish", publishRoute)
 	r.DELETE("/apisix/admin/routes/:rid", deleteRoute)
 	r.GET("/apisix/admin/notexist/routes", isRouteExist)
+	r.PUT("/apisix/admin/routes/:rid/offline", offlineRoute)
 	return r
 }
 
+func publishRoute(c *gin.Context) {
+	rid := c.Param("rid")
+	r := &service.Route{}
+	tx := conf.DB().Begin()
+	if err := tx.Model(&service.Route{}).Where("id = ?", rid).Update("status", true).Find(&r).Error; err != nil {
+		tx.Rollback()
+		e := errno.FromMessage(errno.RoutePublishError, err.Error())
+		logger.Error(e.Msg)
+		c.AbortWithStatusJSON(http.StatusInternalServerError, e.Response())
+		return
+	} else {
+		routeRequest := &service.RouteRequest{}
+		if err := json.Unmarshal([]byte(r.Content), routeRequest); err != nil {
+			tx.Rollback()
+			e := errno.FromMessage(errno.RoutePublishError, err.Error())
+			logger.Error(e.Msg)
+			c.AbortWithStatusJSON(http.StatusInternalServerError, e.Response())
+			return
+		}
+		arr := service.ToApisixRequest(routeRequest)
+		var resp *service.ApisixRouteResponse
+		if resp, err = arr.Create(rid); err != nil {

Review comment:
       a little confused about `Create`, it should be `Update` or something here. 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] nic-chen commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
nic-chen commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-689904687


   api ci not pass


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-689433677


   > @liuxiran CI failed, please take a look
   
   fixing :)


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-689432449


   @liuxiran CI failed, please take a look


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] juzhiyuan commented on pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
juzhiyuan commented on pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#issuecomment-689468983


   @liuxiran ok, so just waiting for others' review :DD


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix-dashboard] liuxiran commented on a change in pull request #450: feat: add publish status to route in manager api

Posted by GitBox <gi...@apache.org>.
liuxiran commented on a change in pull request #450:
URL: https://github.com/apache/apisix-dashboard/pull/450#discussion_r486457935



##########
File path: api/route/route_test.go
##########
@@ -0,0 +1,51 @@
+package route
+
+import (
+	"github.com/apisix/manager-api/conf"
+	"github.com/apisix/manager-api/service"
+	"net/http"
+	"testing"
+)
+
+// publish route
+func TestPublishRoute(t *testing.T) {
+
+	// create route
+	handler.Post(uriPrefix+"/routes").
+		Header("Authorization", token).
+		JSON(`{
+      "name":"api-test",
+      "desc":"",
+      "priority":0,
+      "protocols":["http"],
+      "hosts":["test1.com"],
+      "paths":["/*"],
+      "methods":["GET","HEAD","POST","PUT","DELETE","OPTIONS","PATCH"],
+      "status":false,
+      "upstream_protocol":"keep",
+      "plugins":{},
+      "uris":["/*"],
+      "vars":[],
+      "upstream":{"type":"roundrobin","nodes":{"127.0.0.1:443":1},
+      "timeout":{"connect":6000,"send":6000,"read":6000}},
+      "upstream_header":{}
+}`).Expect(t).
+		Status(http.StatusOK).
+		End()
+	route, _ := getRouteByName("api-test")
+
+	// publish route
+	handler.Put(uriPrefix + "/routes/" + route.ID.String() + "publish").Expect(t).Status(http.StatusOK).End()
+	// offline route
+	handler.Put(uriPrefix + "/routes/" + route.ID.String() + "offline").Expect(t).Status(http.StatusOK).End()
+
+}
+

Review comment:
       done




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org