This is an automated email from the ASF dual-hosted git repository.

juzhiyuan pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/apisix-dashboard.git


The following commit(s) were added to refs/heads/master by this push:
     new 9a92ff9  feat: sync fields of `upstream` from APISIX (#1557)
9a92ff9 is described below

commit 9a92ff95ddbe43432247a8b49ba63a9de115e726
Author: nic-chen <[email protected]>
AuthorDate: Tue Mar 9 20:39:45 2021 +0800

    feat: sync fields of `upstream` from APISIX (#1557)
---
 api/internal/core/entity/entity.go        | 29 ++++++++++----------
 api/test/e2enew/upstream/upstream_test.go | 44 +++++++++++++++++++++++++++++++
 2 files changed, 59 insertions(+), 14 deletions(-)

diff --git a/api/internal/core/entity/entity.go 
b/api/internal/core/entity/entity.go
index b53fb4f..feac18b 100644
--- a/api/internal/core/entity/entity.go
+++ b/api/internal/core/entity/entity.go
@@ -157,20 +157,21 @@ type HealthChecker struct {
 }
 
 type UpstreamDef struct {
-       Nodes        interface{}       `json:"nodes,omitempty"`
-       Retries      int               `json:"retries,omitempty"`
-       Timeout      interface{}       `json:"timeout,omitempty"`
-       K8sInfo      interface{}       `json:"k8s_deployment_info,omitempty"`
-       Type         string            `json:"type,omitempty"`
-       Checks       interface{}       `json:"checks,omitempty"`
-       HashOn       string            `json:"hash_on,omitempty"`
-       Key          string            `json:"key,omitempty"`
-       PassHost     string            `json:"pass_host,omitempty"`
-       UpstreamHost string            `json:"upstream_host,omitempty"`
-       Name         string            `json:"name,omitempty"`
-       Desc         string            `json:"desc,omitempty"`
-       ServiceName  string            `json:"service_name,omitempty"`
-       Labels       map[string]string `json:"labels,omitempty"`
+       Nodes         interface{}       `json:"nodes,omitempty"`
+       Retries       int               `json:"retries,omitempty"`
+       Timeout       interface{}       `json:"timeout,omitempty"`
+       Type          string            `json:"type,omitempty"`
+       Checks        interface{}       `json:"checks,omitempty"`
+       HashOn        string            `json:"hash_on,omitempty"`
+       Key           string            `json:"key,omitempty"`
+       Scheme        string            `json:"scheme,omitempty"`
+       DiscoveryType string            `json:"discovery_type,omitempty"`
+       PassHost      string            `json:"pass_host,omitempty"`
+       UpstreamHost  string            `json:"upstream_host,omitempty"`
+       Name          string            `json:"name,omitempty"`
+       Desc          string            `json:"desc,omitempty"`
+       ServiceName   string            `json:"service_name,omitempty"`
+       Labels        map[string]string `json:"labels,omitempty"`
 }
 
 // swagger:model Upstream
diff --git a/api/test/e2enew/upstream/upstream_test.go 
b/api/test/e2enew/upstream/upstream_test.go
index 0707d74..35a9406 100644
--- a/api/test/e2enew/upstream/upstream_test.go
+++ b/api/test/e2enew/upstream/upstream_test.go
@@ -466,6 +466,41 @@ var _ = ginkgo.Describe("Upstream chash remote addr", 
func() {
                        Sleep:        base.SleepTime,
                })
        })
+       ginkgo.It("create chash upstream u2", func() {
+               base.RunTestCase(base.HttpTestCase{
+                       Object: base.ManagerApiExpect(),
+                       Method: http.MethodPut,
+                       Path:   "/apisix/admin/upstreams/u2",
+                       Body: `{
+                               "retries": 1,
+                               "timeout": {
+                                       "connect":15,
+                                       "send":15,
+                                       "read":15
+                               },
+                               "type":"roundrobin",
+                               "scheme": "https",
+                               "service_name": "USER-SERVICE",
+                               "discovery_type": "eureka",
+                               "name": "upstream-for-test",
+                               "desc": "hello world"
+                       }`,
+                       Headers:      map[string]string{"Authorization": 
base.GetToken()},
+                       ExpectStatus: http.StatusOK,
+               })
+       })
+
+       ginkgo.It("get the upstream to verify config", func() {
+               base.RunTestCase(base.HttpTestCase{
+                       Object:       base.ManagerApiExpect(),
+                       Method:       http.MethodGet,
+                       Path:         "/apisix/admin/upstreams/u2",
+                       Headers:      map[string]string{"Authorization": 
base.GetToken()},
+                       ExpectStatus: http.StatusOK,
+                       ExpectBody:   
`"type":"roundrobin","scheme":"https","discovery_type":"eureka"`,
+                       Sleep:        base.SleepTime,
+               })
+       })
        ginkgo.It("delete route", func() {
                base.RunTestCase(base.HttpTestCase{
                        Object:       base.ManagerApiExpect(),
@@ -484,6 +519,15 @@ var _ = ginkgo.Describe("Upstream chash remote addr", 
func() {
                        ExpectStatus: http.StatusOK,
                })
        })
+       ginkgo.It("delete upstream u2", func() {
+               base.RunTestCase(base.HttpTestCase{
+                       Object:       base.ManagerApiExpect(),
+                       Method:       http.MethodDelete,
+                       Path:         "/apisix/admin/upstreams/u2",
+                       Headers:      map[string]string{"Authorization": 
base.GetToken()},
+                       ExpectStatus: http.StatusOK,
+               })
+       })
        ginkgo.It("hit the route just deleted", func() {
                base.RunTestCase(base.HttpTestCase{
                        Object:       base.APISIXExpect(),

Reply via email to