asifdxtreme closed pull request #252: SCB-259 Can not discovery default APP
services in Shared service mode
URL: https://github.com/apache/incubator-servicecomb-service-center/pull/252
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/server/core/common.go b/server/core/common.go
index 6efbae3e..7b35285b 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 27f2e2e4..45ecd485 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 e4aa9f02..f5819c9e 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 4494295a..a759dff1 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 8cc05bdb..05de94dd 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()
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services