You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by li...@apache.org on 2022/01/18 14:51:00 UTC
[servicecomb-service-center] branch master updated: Bug: start up failed when upgrade sc version (#1231)
This is an automated email from the ASF dual-hosted git repository.
littlecui pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/servicecomb-service-center.git
The following commit(s) were added to refs/heads/master by this push:
new 365765e Bug: start up failed when upgrade sc version (#1231)
365765e is described below
commit 365765e316713b06fb66214598891dfeeab76a50
Author: little-cui <su...@qq.com>
AuthorDate: Tue Jan 18 22:50:54 2022 +0800
Bug: start up failed when upgrade sc version (#1231)
---
server/service/registry/registry.go | 3 +-
server/service/registry/registry_test.go | 47 ++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+), 1 deletion(-)
diff --git a/server/service/registry/registry.go b/server/service/registry/registry.go
index 57e5771..47b9597 100644
--- a/server/service/registry/registry.go
+++ b/server/service/registry/registry.go
@@ -54,7 +54,8 @@ func registerService(ctx context.Context) error {
serviceID, err := discosvc.ExistService(ctx, core.GetExistenceRequest())
if err != nil {
log.Error("query service center existence failed", err)
- if !errsvc.IsErrEqualCode(err, pb.ErrServiceNotExists) {
+ if !errsvc.IsErrEqualCode(err, pb.ErrServiceNotExists) &&
+ !errsvc.IsErrEqualCode(err, pb.ErrServiceVersionNotExists) {
return err
}
return registerNewService(ctx)
diff --git a/server/service/registry/registry_test.go b/server/service/registry/registry_test.go
new file mode 100644
index 0000000..0d491e7
--- /dev/null
+++ b/server/service/registry/registry_test.go
@@ -0,0 +1,47 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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
+ *
+ * http://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 registry_test
+
+import (
+ "context"
+ "math/rand"
+ "strconv"
+ "testing"
+
+ _ "github.com/apache/servicecomb-service-center/test"
+
+ "github.com/apache/servicecomb-service-center/server/core"
+ "github.com/apache/servicecomb-service-center/server/service/registry"
+ "github.com/stretchr/testify/assert"
+)
+
+func TestSelfRegister(t *testing.T) {
+ t.Run("self register after upgrade sc version, should be ok", func(t *testing.T) {
+ oldServiceID := core.Service.ServiceId
+ oldVersion := core.Service.Version
+ defer func() {
+ core.Service.ServiceId = oldServiceID
+ core.Service.Version = oldVersion
+ }()
+
+ core.Service.ServiceId = ""
+ core.Service.Version = "0.0." + strconv.Itoa(rand.Intn(100))
+ err := registry.SelfRegister(context.Background())
+ assert.NoError(t, err)
+ })
+}