tao12345666333 commented on code in PR #1064:
URL: 
https://github.com/apache/apisix-ingress-controller/pull/1064#discussion_r899909068


##########
pkg/apisix/cache/memdb.go:
##########
@@ -152,6 +156,14 @@ func (c *dbCache) GetPluginConfig(name string) 
(*v1.PluginConfig, error) {
        return obj.(*v1.PluginConfig).DeepCopy(), nil
 }
 
+func (c *dbCache) GetUpstreamServiceRelation(serverName string) 
(*v1.UpstreamServiceRelation, error) {

Review Comment:
   I think it should be named `serviceName`, right?



##########
pkg/apisix/cache/memdb_test.go:
##########
@@ -462,3 +462,50 @@ func TestMemDBCachePluginConfig(t *testing.T) {
        }
        assert.Error(t, ErrNotFound, c.DeletePluginConfig(pc4))
 }
+
+func TestMemDBCacheUpstreamServiceRelation(t *testing.T) {
+       c, err := NewMemDBCache()
+       assert.Nil(t, err, "NewMemDBCache")
+
+       us1 := &v1.UpstreamServiceRelation{
+               ServiceName: "1",
+       }
+       assert.Nil(t, c.InsertUpstreamServiceRelation(us1), "inserting route 1")

Review Comment:
   Not route 



##########
pkg/apisix/cache/memdb_test.go:
##########
@@ -462,3 +462,50 @@ func TestMemDBCachePluginConfig(t *testing.T) {
        }
        assert.Error(t, ErrNotFound, c.DeletePluginConfig(pc4))
 }
+
+func TestMemDBCacheUpstreamServiceRelation(t *testing.T) {
+       c, err := NewMemDBCache()
+       assert.Nil(t, err, "NewMemDBCache")
+
+       us1 := &v1.UpstreamServiceRelation{
+               ServiceName: "1",
+       }
+       assert.Nil(t, c.InsertUpstreamServiceRelation(us1), "inserting route 1")
+
+       us, err := c.GetUpstreamServiceRelation("1")
+       assert.Nil(t, err)
+       assert.Equal(t, us1, us)
+
+       us2 := &v1.UpstreamServiceRelation{
+               ServiceName: "2",
+       }
+       assert.Nil(t, c.InsertUpstreamServiceRelation(us2), "inserting route 1")

Review Comment:
   Ditto 



##########
pkg/apisix/cache/memdb_test.go:
##########
@@ -462,3 +462,50 @@ func TestMemDBCachePluginConfig(t *testing.T) {
        }
        assert.Error(t, ErrNotFound, c.DeletePluginConfig(pc4))
 }
+
+func TestMemDBCacheUpstreamServiceRelation(t *testing.T) {
+       c, err := NewMemDBCache()
+       assert.Nil(t, err, "NewMemDBCache")
+
+       us1 := &v1.UpstreamServiceRelation{
+               ServiceName: "1",
+       }
+       assert.Nil(t, c.InsertUpstreamServiceRelation(us1), "inserting route 1")
+
+       us, err := c.GetUpstreamServiceRelation("1")
+       assert.Nil(t, err)
+       assert.Equal(t, us1, us)
+
+       us2 := &v1.UpstreamServiceRelation{
+               ServiceName: "2",
+       }
+       assert.Nil(t, c.InsertUpstreamServiceRelation(us2), "inserting route 1")
+
+       us, err = c.GetUpstreamServiceRelation("2")
+       assert.Nil(t, err)
+       assert.Equal(t, us2, us)
+
+       uss, err := c.ListUpstreamServiceRelation()
+       assert.Nil(t, err)
+       assert.Len(t, uss, 2)

Review Comment:
   The parameter's order 



##########
pkg/apisix/cache/memdb.go:
##########
@@ -152,6 +156,14 @@ func (c *dbCache) GetPluginConfig(name string) 
(*v1.PluginConfig, error) {
        return obj.(*v1.PluginConfig).DeepCopy(), nil
 }
 
+func (c *dbCache) GetUpstreamServiceRelation(serverName string) 
(*v1.UpstreamServiceRelation, error) {

Review Comment:
   We don't have any object named server



##########
pkg/apisix/cache/memdb_test.go:
##########
@@ -462,3 +462,50 @@ func TestMemDBCachePluginConfig(t *testing.T) {
        }
        assert.Error(t, ErrNotFound, c.DeletePluginConfig(pc4))
 }
+
+func TestMemDBCacheUpstreamServiceRelation(t *testing.T) {
+       c, err := NewMemDBCache()
+       assert.Nil(t, err, "NewMemDBCache")
+
+       us1 := &v1.UpstreamServiceRelation{
+               ServiceName: "1",
+       }
+       assert.Nil(t, c.InsertUpstreamServiceRelation(us1), "inserting route 1")
+
+       us, err := c.GetUpstreamServiceRelation("1")
+       assert.Nil(t, err)
+       assert.Equal(t, us1, us)
+
+       us2 := &v1.UpstreamServiceRelation{
+               ServiceName: "2",
+       }
+       assert.Nil(t, c.InsertUpstreamServiceRelation(us2), "inserting route 1")
+
+       us, err = c.GetUpstreamServiceRelation("2")
+       assert.Nil(t, err)
+       assert.Equal(t, us2, us)
+
+       uss, err := c.ListUpstreamServiceRelation()
+       assert.Nil(t, err)
+       assert.Len(t, uss, 2)
+
+       us3 := &v1.UpstreamServiceRelation{
+               ServiceName:  "httpbin",
+               UpstreamName: "upstream",
+       }
+       assert.Nil(t, c.InsertUpstreamServiceRelation(us3), "inserting route 1")

Review Comment:
   Ditto 



-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to