Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: kpango <i.can.feel.gravity@gmail.com>
  • Loading branch information
kpango committed Jun 25, 2020
1 parent f6c2444 commit 032a1df
Show file tree
Hide file tree
Showing 88 changed files with 46,719 additions and 338 deletions.
4 changes: 3 additions & 1 deletion Makefile.d/kind.mk
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,14 @@ kind/stop:
## start kind (kubernetes in docker) multi node cluster
kind/cluster/start:
kind create cluster --name $(NAME)-cluster --config $(ROOTDIR)/k8s/debug/kind/config.yaml
@make kind/login
kubectl apply -f https://projectcontour.io/quickstart/contour.yaml
kubectl patch daemonsets -n projectcontour envoy -p '{"spec":{"template":{"spec":{"nodeSelector":{"ingress-ready":"true"},"tolerations":[{"key":"node-role.kubernetes.io/master","operator":"Equal","effect":"NoSchedule"}]}}}}'


.PHONY: kind/cluster/stop
## stop kind (kubernetes in docker) multi node cluster
kind/cluster/stop:
kubectl delete -f https://projectcontour.io/quickstart/contour.yaml
kind delete cluster --name $(NAME)-cluster

.PHONY: kind/cluster/login
Expand Down
26 changes: 15 additions & 11 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ replace (
github.com/docker/docker => github.com/moby/moby v17.12.0-ce-rc1.0.20200531234253-77e06fda0c94+incompatible
github.com/envoyproxy/protoc-gen-validate => github.com/envoyproxy/protoc-gen-validate v0.3.0-java
github.com/go-sql-driver/mysql => github.com/go-sql-driver/mysql v1.5.1-0.20200531100419-12508c83901b
github.com/gocql/gocql => github.com/gocql/gocql v0.0.0-20200615160627-420e3b873d91
github.com/gocql/gocql => github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e
github.com/gogo/protobuf => github.com/gogo/protobuf v1.3.1
github.com/gophercloud/gophercloud => github.com/gophercloud/gophercloud v0.11.0
github.com/gorilla/mux => github.com/gorilla/mux v1.7.5-0.20200517040254-948bec34b516
github.com/gorilla/websocket => github.com/gorilla/websocket v1.4.2
github.com/tensorflow/tensorflow => github.com/tensorflow/tensorflow v2.1.0+incompatible
golang.org/x/crypto => golang.org/x/crypto v0.0.0-20200604202706-70a84ac30bf9
golang.org/x/crypto => golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9
k8s.io/api => k8s.io/api v0.18.4
k8s.io/apiextensions-apiserver => k8s.io/apiextensions-apiserver v0.18.4
k8s.io/apimachinery => k8s.io/apimachinery v0.18.4
Expand All @@ -25,12 +25,12 @@ replace (
)

require (
cloud.google.com/go v0.58.0
cloud.google.com/go v0.56.0
code.cloudfoundry.org/bytefmt v0.0.0-20200131002437-cf55d5288a48
contrib.go.opencensus.io/exporter/jaeger v0.2.0
contrib.go.opencensus.io/exporter/prometheus v0.2.0
contrib.go.opencensus.io/exporter/stackdriver v0.13.1
github.com/aws/aws-sdk-go v1.32.4
github.com/aws/aws-sdk-go v1.32.9
github.com/cespare/xxhash/v2 v2.1.1
github.com/cockroachdb/errors v0.0.0-00010101000000-000000000000
github.com/danielvladco/go-proto-gql/pb v0.6.1
Expand All @@ -42,10 +42,11 @@ require (
github.com/gocraft/dbr/v2 v2.7.0
github.com/gogo/protobuf v1.3.1
github.com/google/gofuzz v1.1.0
github.com/google/pprof v0.0.0-20200615235658-03e1cf38a040 // indirect
github.com/gorilla/mux v1.7.1
github.com/hashicorp/go-version v1.2.1
github.com/json-iterator/go v1.1.10
github.com/klauspost/compress v1.10.9
github.com/klauspost/compress v1.10.10
github.com/kpango/fastime v1.0.16
github.com/kpango/fuid v0.0.0-20190507064958-80435564606b
github.com/kpango/gache v1.2.1
Expand All @@ -59,15 +60,18 @@ require (
go.opencensus.io v0.22.4
go.uber.org/automaxprocs v1.3.0
go.uber.org/goleak v1.0.0
golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2
golang.org/x/sys v0.0.0-20200523222454-059865788121
golang.org/x/tools v0.0.0-20200618031402-d15173dcc7e4 // indirect
golang.org/x/mod v0.3.0 // indirect
golang.org/x/net v0.0.0-20200625001655-4c5254603344
golang.org/x/sys v0.0.0-20200622214017-ed371f2e16b4
golang.org/x/text v0.3.3 // indirect
golang.org/x/tools v0.0.0-20200624225443-88f3c62a19ff // indirect
gonum.org/v1/hdf5 v0.0.0-20200504100616-496fefe91614
gonum.org/v1/netlib v0.0.0-20200603212716-16abd5ac5bc7 // indirect
gonum.org/v1/plot v0.7.0
google.golang.org/api v0.27.0
google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790
google.golang.org/grpc v1.29.1
google.golang.org/api v0.28.0
google.golang.org/genproto v0.0.0-20200624020401-64a14ca9d1ad
google.golang.org/grpc v1.30.0
google.golang.org/protobuf v1.25.0 // indirect
gopkg.in/yaml.v2 v2.3.0
k8s.io/api v0.18.4
k8s.io/apimachinery v0.18.4
Expand Down
113 changes: 43 additions & 70 deletions go.sum

Large diffs are not rendered by default.

43 changes: 22 additions & 21 deletions internal/client/agent/grpc/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"context"

agent "github.com/vdaas/vald/apis/grpc/agent/core"
"github.com/vdaas/vald/apis/grpc/gateway/vald"
"github.com/vdaas/vald/internal/client"
"github.com/vdaas/vald/internal/net/grpc"
)
Expand Down Expand Up @@ -60,7 +61,7 @@ func (c *agentClient) Exists(
) (*client.ObjectID, error) {
res, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).Exists(ctx, req, copts...)
return vald.NewValdClient(conn).Exists(ctx, req, copts...)
},
)
if err != nil {
Expand All @@ -75,7 +76,7 @@ func (c *agentClient) Search(
) (*client.SearchResponse, error) {
res, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).Search(ctx, req, copts...)
return vald.NewValdClient(conn).Search(ctx, req, copts...)
},
)
if err != nil {
Expand All @@ -90,7 +91,7 @@ func (c *agentClient) SearchByID(
) (*client.SearchResponse, error) {
res, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).SearchByID(ctx, req, copts...)
return vald.NewValdClient(conn).SearchByID(ctx, req, copts...)
},
)
if err != nil {
Expand All @@ -106,9 +107,9 @@ func (c *agentClient) StreamSearch(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (res interface{}, err error) {
var st agent.Agent_StreamSearchClient
var st vald.Vald_StreamSearchClient

st, err = agent.NewAgentClient(conn).StreamSearch(ctx, copts...)
st, err = vald.NewValdClient(conn).StreamSearch(ctx, copts...)
if err != nil {
return nil, err
}
Expand All @@ -129,9 +130,9 @@ func (c *agentClient) StreamSearchByID(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (res interface{}, err error) {
var st agent.Agent_StreamSearchByIDClient
var st vald.Vald_StreamSearchByIDClient

st, err = agent.NewAgentClient(conn).StreamSearchByID(ctx, copts...)
st, err = vald.NewValdClient(conn).StreamSearchByID(ctx, copts...)
if err != nil {
return nil, err
}
Expand All @@ -152,7 +153,7 @@ func (c *agentClient) Insert(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).Insert(ctx, req, copts...)
return vald.NewValdClient(conn).Insert(ctx, req, copts...)
},
)
return err
Expand All @@ -165,9 +166,9 @@ func (c *agentClient) StreamInsert(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (res interface{}, err error) {
var st agent.Agent_StreamInsertClient
var st vald.Vald_StreamInsertClient

st, err = agent.NewAgentClient(conn).StreamInsert(ctx, copts...)
st, err = vald.NewValdClient(conn).StreamInsert(ctx, copts...)
if err != nil {
return nil, err
}
Expand All @@ -188,7 +189,7 @@ func (c *agentClient) MultiInsert(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).MultiInsert(ctx, req, copts...)
return vald.NewValdClient(conn).MultiInsert(ctx, req, copts...)
},
)
return err
Expand All @@ -200,7 +201,7 @@ func (c *agentClient) Update(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).Update(ctx, req, copts...)
return vald.NewValdClient(conn).Update(ctx, req, copts...)
},
)
return err
Expand All @@ -213,9 +214,9 @@ func (c *agentClient) StreamUpdate(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (res interface{}, err error) {
var st agent.Agent_StreamUpdateClient
var st vald.Vald_StreamUpdateClient

st, err = agent.NewAgentClient(conn).StreamUpdate(ctx, copts...)
st, err = vald.NewValdClient(conn).StreamUpdate(ctx, copts...)
if err != nil {
return nil, err
}
Expand All @@ -236,7 +237,7 @@ func (c *agentClient) MultiUpdate(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).MultiUpdate(ctx, req, copts...)
return vald.NewValdClient(conn).MultiUpdate(ctx, req, copts...)
},
)
return err
Expand All @@ -248,7 +249,7 @@ func (c *agentClient) Remove(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).Remove(ctx, req, copts...)
return vald.NewValdClient(conn).Remove(ctx, req, copts...)
},
)
return err
Expand All @@ -261,7 +262,7 @@ func (c *agentClient) StreamRemove(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
st, err := agent.NewAgentClient(conn).StreamRemove(ctx, copts...)
st, err := vald.NewValdClient(conn).StreamRemove(ctx, copts...)
if err != nil {
return nil, err
}
Expand All @@ -282,7 +283,7 @@ func (c *agentClient) MultiRemove(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).MultiRemove(ctx, req, copts...)
return vald.NewValdClient(conn).MultiRemove(ctx, req, copts...)
},
)
return err
Expand All @@ -294,7 +295,7 @@ func (c *agentClient) GetObject(
) (*client.ObjectVector, error) {
res, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (interface{}, error) {
return agent.NewAgentClient(conn).GetObject(ctx, req, copts...)
return vald.NewValdClient(conn).GetObject(ctx, req, copts...)
},
)
if err != nil {
Expand All @@ -310,9 +311,9 @@ func (c *agentClient) StreamGetObject(
) error {
_, err := c.Client.Do(ctx, c.addr,
func(ctx context.Context, conn *grpc.ClientConn, copts ...grpc.CallOption) (res interface{}, err error) {
var st agent.Agent_StreamGetObjectClient
var st vald.Vald_StreamGetObjectClient

st, err = agent.NewAgentClient(conn).StreamGetObject(ctx, copts...)
st, err = vald.NewValdClient(conn).StreamGetObject(ctx, copts...)
if err != nil {
return nil, err
}
Expand Down
13 changes: 13 additions & 0 deletions k8s/debug/kind/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ apiVersion: kind.x-k8s.io/v1alpha4
# AllBeta: false
nodes:
- role: control-plane
kubeadmConfigPatches:
- |
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
node-labels: "ingress-ready=true"
extraPortMappings:
- containerPort: 80
hostPort: 8080
protocol: TCP
- containerPort: 443
hostPort: 4443
protocol: TCP
- role: worker
- role: worker
- role: worker
Expand Down
101 changes: 101 additions & 0 deletions pkg/gateway/backup/config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
//
// Copyright (C) 2019-2020 Vdaas.org Vald team ( kpango, rinx, kmrmt )
//
// 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
//
// https://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 setting stores all server application settings
package config

import (
"reflect"
"testing"

"github.com/vdaas/vald/internal/errors"
"go.uber.org/goleak"
)

func TestNewConfig(t *testing.T) {
type args struct {
path string
}
type want struct {
wantCfg *Data
err error
}
type test struct {
name string
args args
want want
checkFunc func(want, *Data, error) error
beforeFunc func(args)
afterFunc func(args)
}
defaultCheckFunc := func(w want, gotCfg *Data, err error) error {
if !errors.Is(err, w.err) {
return errors.Errorf("got error = %v, want %v", err, w.err)
}
if !reflect.DeepEqual(gotCfg, w.wantCfg) {
return errors.Errorf("got = %v, want %v", gotCfg, w.wantCfg)
}
return nil
}
tests := []test{
// TODO test cases
/*
{
name: "test_case_1",
args: args {
path: "",
},
want: want{},
checkFunc: defaultCheckFunc,
},
*/

// TODO test cases
/*
func() test {
return test {
name: "test_case_2",
args: args {
path: "",
},
want: want{},
checkFunc: defaultCheckFunc,
}
}(),
*/
}

for _, test := range tests {
t.Run(test.name, func(tt *testing.T) {
defer goleak.VerifyNone(tt)
if test.beforeFunc != nil {
test.beforeFunc(test.args)
}
if test.afterFunc != nil {
defer test.afterFunc(test.args)
}
if test.checkFunc == nil {
test.checkFunc = defaultCheckFunc
}

gotCfg, err := NewConfig(test.args.path)
if err := test.checkFunc(test.want, gotCfg, err); err != nil {
tt.Errorf("error = %v", err)
}

})
}
}
Loading

0 comments on commit 032a1df

Please sign in to comment.