refactor: too long param
diff --git a/go.mod b/go.mod
index addfe9b..0fa2317 100644
--- a/go.mod
+++ b/go.mod
@@ -2,13 +2,12 @@
require (
github.com/Shopify/toxiproxy v2.1.3+incompatible // indirect
- github.com/apache/servicecomb-kie v0.1.0 // indirect
github.com/emicklei/go-restful-swagger12 v0.0.0-20170926063155-7524189396c6 // indirect
github.com/envoyproxy/go-control-plane v0.6.0
github.com/ghodss/yaml v1.0.0
github.com/go-chassis/foundation v0.0.0-20190621030543-c3b63f787f4c
github.com/go-chassis/go-archaius v0.20.0
- github.com/go-chassis/go-chassis v1.7.1-0.20190903133217-e4a22c998fe1
+ github.com/go-chassis/go-chassis v1.7.2-0.20190917011915-d49fa9cdd27d
github.com/go-chassis/go-chassis-config v0.10.0
github.com/go-chassis/gohessian v0.0.0-20180702061429-e5130c25af55
github.com/go-logfmt/logfmt v0.4.0 // indirect
@@ -16,11 +15,14 @@
github.com/gogo/googleapis v1.1.0 // indirect
github.com/gogo/protobuf v1.2.0
github.com/google/gofuzz v0.0.0-20170612174753-24818f796faf // indirect
+ github.com/gopherjs/gopherjs v0.0.0-20181103185306-d547d1d9531e // indirect
github.com/imdario/mergo v0.3.6 // indirect
github.com/lyft/protoc-gen-validate v0.0.11 // indirect
github.com/patrickmn/go-cache v2.1.0+incompatible
github.com/prometheus/client_golang v0.9.1
github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f
+ github.com/prometheus/procfs v0.0.0-20190117184657-bf6a532e95b1 // indirect
+ github.com/smartystreets/assertions v0.0.0-20190116191733-b6c0e53d7304 // indirect
github.com/spf13/pflag v1.0.3 // indirect
github.com/stretchr/testify v1.3.0
github.com/uber-go/atomic v1.3.2 // indirect
diff --git a/proxy/cmd/cmd_test.go b/proxy/cmd/cmd_test.go
index 9e73dc3..2063c71 100644
--- a/proxy/cmd/cmd_test.go
+++ b/proxy/cmd/cmd_test.go
@@ -39,7 +39,6 @@
}
func TestConfigFromCmd_GeneratePortsMap(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
c := &cmd.ConfigFromCmd{
LocalServicePorts: "rest:80,grpc:8000",
@@ -49,7 +48,6 @@
assert.Equal(t, "127.0.0.1:80", c.PortsMap["rest"])
}
func TestConfigFromCmd_GeneratePortsMap2(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
c := &cmd.ConfigFromCmd{
LocalServicePorts: "rest: 80,grpc",
@@ -59,7 +57,6 @@
assert.Error(t, err)
}
func TestConfigFromCmd_GeneratePortsMap3(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
os.Setenv(common.EnvServicePorts, "rest:80,grpc:90")
cmd.Init()
_ = cmd.Configs.GeneratePortsMap()
@@ -67,10 +64,12 @@
assert.Equal(t, "127.0.0.1:80", cmd.Configs.PortsMap["rest"])
}
func TestConfigFromCmd_GeneratePortsMap4(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
os.Setenv(common.EnvSpecificAddr, "127.0.0.1:80")
cmd.Init()
_ = cmd.Configs.GeneratePortsMap()
t.Log(cmd.Configs.PortsMap)
assert.Equal(t, "127.0.0.1:80", cmd.Configs.PortsMap["rest"])
}
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
diff --git a/proxy/config/config_test.go b/proxy/config/config_test.go
index 4ce2039..b17b731 100644
--- a/proxy/config/config_test.go
+++ b/proxy/config/config_test.go
@@ -24,6 +24,7 @@
// "github.com/go-chassis/go-chassis/pkg/util/fileutil"
"github.com/apache/servicecomb-mesher/proxy/cmd"
"github.com/apache/servicecomb-mesher/proxy/config"
+ "github.com/go-chassis/go-chassis/core/lager"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
// "os"
@@ -31,6 +32,9 @@
"testing"
)
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestGetConfigFilePath(t *testing.T) {
var key = "mesher.yaml"
cmd.Init()
@@ -64,33 +68,3 @@
assert.Equal(t, "host", c.Plugin.DestinationResolver["http"])
assert.Equal(t, "8800", c.HealthCheck[0].Port)
}
-
-// Testcase is trying to create files inside /tmp/build folder which is dynamic, so in travis it is not possible to create folder in prior, so can't test this case in travis
-/*func TestInit(t *testing.T) {
- s, _ := fileutil.GetWorkDir()
- os.Setenv(fileutil.ChassisHome, s)
- chassisConf := filepath.Join(os.Getenv(fileutil.ChassisHome), "conf")
- os.MkdirAll(chassisConf, 0600)
- f, err := os.Create(filepath.Join(chassisConf, "chassis.yaml"))
- assert.NoError(t, err)
- t.Log(f.Name())
-
- f, err = os.Create(filepath.Join(chassisConf, "microservice.yaml"))
- t.Log(f.Name())
- assert.NoError(t, err)
- err = cConfig.Init()
- f, err = os.Create(filepath.Join(chassisConf, "mesher.yaml"))
- t.Log(f.Name())
- f.Write(file)
- f.Close()
- lager.Initialize("", "INFO", "", "size", true, 1, 10, 7)
- archaius.Init()
-
- err = config.Init()
- assert.NoError(t, err)
- t.Log(config.GetConfig())
- assert.Equal(t, "host", config.GetConfig().Plugin.DestinationResolver)
- assert.Equal(t, true, config.GetConfig().PProf.Enable)
- assert.Equal(t, "0.0.0.0:6060", config.GetConfig().PProf.Listen)
- assert.Equal(t, "rest", config.GetConfig().HealthCheck[0].Port)
-}*/
diff --git a/proxy/handler/port_rewrite_test.go b/proxy/handler/port_rewrite_test.go
index c117216..04265b3 100644
--- a/proxy/handler/port_rewrite_test.go
+++ b/proxy/handler/port_rewrite_test.go
@@ -48,7 +48,6 @@
assert.NoError(t, r.Err)
return r.Err
})
- c.Reset()
}
func TestPortRewriteHandler_InValidEndpoint(t *testing.T) {
@@ -72,7 +71,6 @@
return r.Err
})
- c.Reset()
}
func TestPortRewriteHandler_Names(t *testing.T) {
diff --git a/proxy/health/health_test.go b/proxy/health/health_test.go
index 21465c2..1273be7 100644
--- a/proxy/health/health_test.go
+++ b/proxy/health/health_test.go
@@ -29,8 +29,10 @@
"time"
)
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestHttpCheck(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
server := &http.Server{
Addr: "127.0.0.1:3000",
}
@@ -113,7 +115,6 @@
}
func TestParseConfig(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
check := &config.HealthCheck{
Port: "8080",
URI: "/health",
@@ -139,7 +140,6 @@
assert.Error(t, err)
}
func TestL4Check(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
err := health.L4Check("127.0.0.1:3000")
assert.Error(t, err)
net.Listen("tcp", "127.0.0.1:3000")
diff --git a/proxy/pkg/egress/egress_test.go b/proxy/pkg/egress/egress_test.go
index a1c9a03..05b70e8 100644
--- a/proxy/pkg/egress/egress_test.go
+++ b/proxy/pkg/egress/egress_test.go
@@ -37,9 +37,10 @@
"gopkg.in/yaml.v2"
)
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func BenchmarkMatch(b *testing.B) {
- lager.Initialize("", "DEBUG", "",
- "size", true, 1, 10, 7)
chassis := []byte(`
cse:
service:
@@ -97,8 +98,6 @@
}
func TestMatch(t *testing.T) {
- lager.Initialize("", "DEBUG", "",
- "size", true, 1, 10, 7)
b := []byte(`
cse:
diff --git a/proxy/pkg/infras/istio/xds_test.go b/proxy/pkg/infras/istio/xds_test.go
index 3ec79fd..2f1c1b2 100644
--- a/proxy/pkg/infras/istio/xds_test.go
+++ b/proxy/pkg/infras/istio/xds_test.go
@@ -18,13 +18,13 @@
package pilotv2
import (
+ "github.com/go-chassis/go-chassis/core/lager"
"os"
"os/user"
"testing"
"time"
apiv2 "github.com/envoyproxy/go-control-plane/envoy/api/v2"
- "github.com/go-chassis/go-chassis/core/lager"
"github.com/go-chassis/go-chassis/pkg/util/iputil"
)
@@ -46,8 +46,10 @@
err error
)
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestXdsClient_CDS(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
// Get kube config path and local ip
if KUBE_CONFIG := os.Getenv("KUBE_CONFIG"); KUBE_CONFIG != "" {
KubeConfig = KUBE_CONFIG
diff --git a/proxy/plugins/registry/istiov2/cache_test.go b/proxy/plugins/registry/istiov2/cache_test.go
index 2b45c25..7f26707 100644
--- a/proxy/plugins/registry/istiov2/cache_test.go
+++ b/proxy/plugins/registry/istiov2/cache_test.go
@@ -44,8 +44,10 @@
err error
)
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestNewCacheManager2(t *testing.T) {
- lager.Initialize("", "DEBUG", "", "size", true, 1, 10, 7)
// Get kube config path and local ip
if KUBE_CONFIG := os.Getenv("KUBE_CONFIG"); KUBE_CONFIG != "" {
KubeConfig = KUBE_CONFIG
diff --git a/proxy/register/register_test.go b/proxy/register/register_test.go
index a9e4daa..5bea983 100644
--- a/proxy/register/register_test.go
+++ b/proxy/register/register_test.go
@@ -29,8 +29,10 @@
"github.com/stretchr/testify/assert"
)
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestAdaptEndpoints(t *testing.T) {
- lager.Initialize("", "INFO", "", "size", true, 1, 10, 7)
protoMap := make(map[string]model.Protocol)
config.GlobalDefinition = &model.GlobalCfg{
Cse: model.CseStruct{
diff --git a/proxy/resolver/authority/destination_test.go b/proxy/resolver/authority/destination_test.go
index ecc0391..baa29e2 100644
--- a/proxy/resolver/authority/destination_test.go
+++ b/proxy/resolver/authority/destination_test.go
@@ -27,9 +27,10 @@
"net/http"
)
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestResolve(t *testing.T) {
- lager.Initialize("", "DEBUG", "",
- "size", true, 1, 10, 7)
d := &authority.GRPCDefaultDestinationResolver{}
header := http.Header{}
header.Add("cookie", "user=jason")
@@ -56,8 +57,6 @@
}
func BenchmarkDefaultDestinationResolver_Resolve(b *testing.B) {
- lager.Initialize("", "DEBUG", "",
- "size", true, 1, 10, 7)
d := &authority.GRPCDefaultDestinationResolver{}
for i := 0; i < b.N; i++ {
d.Resolve("abc", "", "127.0.0.1:80", map[string]string{})
diff --git a/proxy/resolver/destination_test.go b/proxy/resolver/destination_test.go
index ae647d7..6b90ae7 100644
--- a/proxy/resolver/destination_test.go
+++ b/proxy/resolver/destination_test.go
@@ -33,30 +33,10 @@
"github.com/stretchr/testify/assert"
)
-// Testcase is trying to create files inside /tmp/build folder which is dynamic, so in travis it is not possible to create folder in prior, so can't test this case in travis
-/*func TestInit(t *testing.T) {
- s, _ := fileutil.GetWorkDir()
- os.Setenv(fileutil.ChassisHome, s)
- chassisConf := filepath.Join(os.Getenv(fileutil.ChassisHome), "conf")
- os.MkdirAll(chassisConf, 0600)
- f, err := os.Create(filepath.Join(chassisConf, "chassis.yaml"))
- t.Log(f.Name())
- assert.NoError(t, err)
- f, err = os.Create(filepath.Join(chassisConf, "microservice.yaml"))
- t.Log(f.Name())
- assert.NoError(t, err)
- err = cConfig.Init()
- err = cmd.Init()
- lager.Initialize("", "INFO", "", "size", true, 1, 10, 7)
- archaius.Init()
- config.Init()
- err = Init()
- assert.NoError(t, err)
-}*/
-
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestResolve(t *testing.T) {
- lager.Initialize("", "DEBUG", "",
- "size", true, 1, 10, 7)
d := &DefaultDestinationResolver{}
header := http.Header{}
header.Add("cookie", "user=jason")
@@ -94,8 +74,6 @@
}
func BenchmarkDefaultDestinationResolver_Resolve(b *testing.B) {
- lager.Initialize("", "DEBUG", "",
- "size", true, 1, 10, 7)
d := &DefaultDestinationResolver{}
for i := 0; i < b.N; i++ {
d.Resolve("abc", "", "http://127.0.0.1:80/test", map[string]string{})
diff --git a/proxy/resource/v1/health/health_test.go b/proxy/resource/v1/health/health_test.go
index 510d256..fee67bc2 100644
--- a/proxy/resource/v1/health/health_test.go
+++ b/proxy/resource/v1/health/health_test.go
@@ -35,6 +35,9 @@
mockError = errors.New("test mock error")
)
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestGetMesherHealth(t *testing.T) {
testGetServiceStatusSuccess(t)
testGetServiceStatusFailed(t)
@@ -48,7 +51,6 @@
}
func testInit() {
- lager.Initialize("", "INFO", "", "size", true, 1, 10, 7)
p := filepath.Join(os.Getenv("GOPATH"), "src", "github.com", "go-chassis", "mesher", "conf")
os.Setenv("CHASSIS_CONF_DIR", p)
err := config.Init()
diff --git a/proxy/resource/v1/init_test.go b/proxy/resource/v1/init_test.go
index d1ed5f6..b3fec12 100644
--- a/proxy/resource/v1/init_test.go
+++ b/proxy/resource/v1/init_test.go
@@ -24,7 +24,7 @@
"github.com/go-chassis/go-chassis/core/config"
"github.com/go-chassis/go-chassis/core/config/model"
"github.com/go-chassis/go-chassis/core/lager"
- _ "github.com/go-chassis/go-chassis/core/router/cse"
+ _ "github.com/go-chassis/go-chassis/core/router/servicecomb"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"
)
@@ -78,10 +78,12 @@
weight: 100
`
+func init() {
+ lager.Init(&lager.Options{LoggerLevel: "DEBUG"})
+}
func TestInit(t *testing.T) {
t.Log("testing mesher admin protocol when protocol URI is valid")
assert := assert.New(t)
- lager.Initialize("", "INFO", "", "size", true, 1, 10, 7)
mesherConfig := new(mesherconfig.MesherConfig)
yaml.Unmarshal([]byte(mesherConf), mesherConfig)
mesherconfig.SetConfig(mesherConfig)