You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by as...@apache.org on 2018/01/20 06:11:35 UTC

[incubator-servicecomb-service-center] branch master updated: SCB-259 Can not discovery default APP services in Shared service mode (#252)

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

asifdxtreme pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-servicecomb-service-center.git


The following commit(s) were added to refs/heads/master by this push:
     new 8478441  SCB-259 Can not discovery default APP services in Shared service mode (#252)
8478441 is described below

commit 8478441c82ec4bd398a7eb1f7837b56ab11f04ba
Author: little-cui <su...@qq.com>
AuthorDate: Sat Jan 20 14:11:32 2018 +0800

    SCB-259 Can not discovery default APP services in Shared service mode (#252)
    
    * SCB-259 Can not discovery default APP services in Shared service mode
---
 server/core/common.go                    | 10 ++++------
 server/core/proto/services.go            | 10 +++-------
 server/service/microservices_test.go     | 22 ++++++++++++----------
 server/service/util/microservice_util.go |  9 ---------
 server/service/util/util_suite_test.go   |  4 ----
 5 files changed, 19 insertions(+), 36 deletions(-)

diff --git a/server/core/common.go b/server/core/common.go
index 6efbae3..7b35285 100644
--- a/server/core/common.go
+++ b/server/core/common.go
@@ -70,9 +70,7 @@ func init() {
 	statusRegex, _ := regexp.Compile("^(" + pb.MS_UP + "|" + pb.MS_DOWN + ")*$")
 	serviceIdRegex, _ := regexp.Compile(`^.*$`)
 	aliasRegex, _ := regexp.Compile(`^[a-zA-Z0-9_\-.:]*$`)
-	frameversionRegex, _ := regexp.Compile(`^[a-zA-Z0-9_\-.]*$`)
-	registerByRegex, _ := regexp.Compile("^(" + util.StringJoin([]string{
-		pb.REGISTERBY_SDK, pb.REGISTERBY_PLATFORM, pb.REGISTERBY_SIDECAR, pb.REGISTERBY_UNKNOWM}, "|") + ")*$")
+	registerByRegex, _ := regexp.Compile("^(" + util.StringJoin([]string{pb.REGISTERBY_SDK, pb.REGISTERBY_SIDECAR}, "|") + ")*$")
 	envRegex, _ := regexp.Compile("^(" + util.StringJoin([]string{
 		pb.ENV_DEV, pb.ENV_TEST, pb.ENV_ACCEPT, pb.ENV_PROD}, "|") + ")*$")
 	// map/slice元素的validator
@@ -107,8 +105,8 @@ func init() {
 
 	ServicePathValidator.AddRule("Path", &validate.ValidateRule{Regexp: pathRegex})
 
-	FrameWKValidator.AddRule("Name", &validate.ValidateRule{Min: 1, Max: 64, Regexp: nameRegex})
-	FrameWKValidator.AddRule("Version", &validate.ValidateRule{Length: 64, Regexp: frameversionRegex})
+	FrameWKValidator.AddRule("Name", &validate.ValidateRule{Max: 64, Regexp: nameRegex})
+	FrameWKValidator.AddRule("Version", &validate.ValidateRule{Length: 64})
 
 	MicroServiceValidator.AddRules(MicroServiceKeyValidator.GetRules())
 	MicroServiceValidator.AddRule("Description", &validate.ValidateRule{Length: 256})
@@ -117,7 +115,7 @@ func init() {
 	MicroServiceValidator.AddRule("Schemas", SchemaIdRule)
 	MicroServiceValidator.AddSub("Paths", &ServicePathValidator)
 	MicroServiceValidator.AddRule("Alias", &validate.ValidateRule{Length: 128, Regexp: aliasRegex})
-	MicroServiceValidator.AddRule("RegisterBy", &validate.ValidateRule{Min: 1, Length: 64, Regexp: registerByRegex})
+	MicroServiceValidator.AddRule("RegisterBy", &validate.ValidateRule{Length: 64, Regexp: registerByRegex})
 	MicroServiceValidator.AddSub("Framework", &FrameWKValidator)
 
 	GetMSExistsReqValidator.AddRules(MicroServiceKeyValidator.GetRules())
diff --git a/server/core/proto/services.go b/server/core/proto/services.go
index 27f2e2e..45ecd48 100644
--- a/server/core/proto/services.go
+++ b/server/core/proto/services.go
@@ -19,11 +19,11 @@ package proto
 import (
 	"fmt"
 	"github.com/apache/incubator-servicecomb-service-center/pkg/util"
+	scerr "github.com/apache/incubator-servicecomb-service-center/server/error"
 	"github.com/coreos/etcd/mvcc/mvccpb"
 	"github.com/gorilla/websocket"
 	"golang.org/x/net/context"
 	"strings"
-	scerr "github.com/apache/incubator-servicecomb-service-center/server/error"
 )
 
 type EventType string
@@ -58,12 +58,8 @@ const (
 	ENV_ACCEPT string = "acceptance"
 	ENV_PROD   string = "production"
 
-	REGISTERBY_SDK      string = "SDK"
-	REGISTERBY_PLATFORM string = "PLATFORM"
-	REGISTERBY_SIDECAR  string = "SIDECAR"
-	REGISTERBY_UNKNOWM  string = "UNKNOWN"
-
-	FRAMEWORK_UNKNOWN string = "UNKNOWN"
+	REGISTERBY_SDK     string = "SDK"
+	REGISTERBY_SIDECAR string = "SIDECAR"
 )
 
 type SerivceInstanceCtrlServerEx interface {
diff --git a/server/service/microservices_test.go b/server/service/microservices_test.go
index e4aa9f0..f5819c9 100644
--- a/server/service/microservices_test.go
+++ b/server/service/microservices_test.go
@@ -25,8 +25,9 @@ import (
 )
 
 var (
-	TOO_LONG_SERVICEID   = strings.Repeat("x", 65)
-	TOO_LONG_SERVICENAME = strings.Repeat("x", 129)
+	TOO_LONG_SERVICEID     = strings.Repeat("x", 65)
+	TOO_LONG_SERVICENAME   = strings.Repeat("x", 129)
+	TOO_LONG_FRAMEWORK_VER = strings.Repeat("x", 65)
 )
 
 var _ = Describe("'Micro-service' service", func() {
@@ -384,8 +385,7 @@ var _ = Describe("'Micro-service' service", func() {
 						Version:     "1.0.4",
 						Level:       "BACK",
 						Framework: &pb.FrameWorkProperty{
-							Name:    "framework",
-							Version: "1.0.0-:",
+							Version: TOO_LONG_FRAMEWORK_VER,
 						},
 						Properties: make(map[string]string),
 						Status:     "UP",
@@ -403,8 +403,7 @@ var _ = Describe("'Micro-service' service", func() {
 						Version:     "1.0.5",
 						Level:       "BACK",
 						Framework: &pb.FrameWorkProperty{
-							Name:    "test@$",
-							Version: "1.0.0-",
+							Name: "test@$",
 						},
 						Properties: make(map[string]string),
 						Status:     "UP",
@@ -451,15 +450,18 @@ var _ = Describe("'Micro-service' service", func() {
 				Expect(err).To(BeNil())
 				Expect(resp.Response.Code).To(Equal(pb.Response_SUCCESS))
 
-				By("registerBy is nil")
+				By("framework version is nil")
 				r = &pb.CreateServiceRequest{
 					Service: &pb.MicroService{
 						ServiceName: "framework-test",
 						AppId:       "default",
 						Version:     "1.0.2",
 						Level:       "BACK",
-						Properties:  make(map[string]string),
-						Status:      "UP",
+						Framework: &pb.FrameWorkProperty{
+							Name: "framework",
+						},
+						Properties: make(map[string]string),
+						Status:     "UP",
 					},
 				}
 				resp, err = serviceResource.Create(getContext(), r)
@@ -469,7 +471,7 @@ var _ = Describe("'Micro-service' service", func() {
 				By("status is nil")
 				r = &pb.CreateServiceRequest{
 					Service: &pb.MicroService{
-						ServiceName: "framework-test",
+						ServiceName: "status-test",
 						AppId:       "default",
 						Version:     "1.0.3",
 						Level:       "BACK",
diff --git a/server/service/util/microservice_util.go b/server/service/util/microservice_util.go
index 4494295..a759dff 100644
--- a/server/service/util/microservice_util.go
+++ b/server/service/util/microservice_util.go
@@ -284,15 +284,6 @@ func SetServiceDefaultValue(service *pb.MicroService) {
 	if len(service.Level) == 0 {
 		service.Level = "BACK"
 	}
-	if len(service.RegisterBy) == 0 {
-		service.RegisterBy = pb.REGISTERBY_UNKNOWM
-	}
-	if service.Framework == nil {
-		service.Framework = &pb.FrameWorkProperty{}
-	}
-	if len(service.Framework.Name) == 0 {
-		service.Framework.Name = pb.FRAMEWORK_UNKNOWN
-	}
 	if len(service.Status) == 0 {
 		service.Status = pb.MS_UP
 	}
diff --git a/server/service/util/util_suite_test.go b/server/service/util/util_suite_test.go
index 8cc05bd..05de94d 100644
--- a/server/service/util/util_suite_test.go
+++ b/server/service/util/util_suite_test.go
@@ -179,10 +179,6 @@ func TestSetDefault(t *testing.T) {
 	service := &proto.MicroService{}
 	serviceUtil.SetServiceDefaultValue(service)
 	if len(service.Level) == 0 ||
-		//len(service.Environment) == 0 ||
-		len(service.RegisterBy) == 0 ||
-		service.Framework == nil ||
-		len(service.Framework.Name) == 0 ||
 		len(service.Status) == 0 {
 		fmt.Printf(`TestSetDefault failed`)
 		t.FailNow()

-- 
To stop receiving notification emails like this one, please contact
['"commits@servicecomb.apache.org" <co...@servicecomb.apache.org>'].