Skip to content

Commit

Permalink
[#4375] Fix local registry not find cross app name alias (#4377)
Browse files Browse the repository at this point in the history
  • Loading branch information
liubao68 authored Jun 20, 2024
1 parent 86a682e commit cd5e35b
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ private static void registerSchema() {
RegistrationManager.INSTANCE.getSwaggerLoader().registerSwagger("demo-local-registry",
"demo-local-registry-server",
"CodeFirstEndpoint", CodeFirstService.class);
RegistrationManager.INSTANCE.getSwaggerLoader().registerSwagger("demo-local-registry-cross",
"demo-local-registry-server-cross",
"CodeFirstEndpoint", CodeFirstService.class);
RegistrationManager.INSTANCE.getSwaggerLoader().registerSwagger("demo-local-registry",
"demo-local-registry-server-bean",
"CodeFirstEndpoint", CodeFirstService.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ public class LocalRegistryServerTest implements CategorizedTestCase {
@RpcReference(microserviceName = "demo-local-registry-server", schemaId = "CodeFirstEndpoint")
private CodeFirstService codeFirstService;

@RpcReference(microserviceName = "demo-local-registry-cross:demo-local-registry-server-cross",
schemaId = "CodeFirstEndpoint")
private CodeFirstService codeFirstServiceCross;

@RpcReference(microserviceName = "demo-local-registry-server-bean", schemaId = "CodeFirstEndpoint")
private CodeFirstService codeFirstServiceBean;

Expand Down Expand Up @@ -62,6 +66,7 @@ private void testGetAllMicroservice() {

private void testCodeFirstGetName() {
TestMgr.check("2", codeFirstService.getName("2"));
TestMgr.check("2", codeFirstServiceCross.getName("2"));
TestMgr.check("2", codeFirstServiceBean.getName("2"));
TestMgr.check("2", codeFirstServiceBean2.getName("2"));
}
Expand All @@ -71,6 +76,10 @@ private void testServerGetName() {
TestMgr.check("2", template
.getForObject("cse://demo-local-registry-server/register/url/prefix/getName?name=2",
String.class));
TestMgr.check("2", template
.getForObject(
"cse://demo-local-registry-cross:demo-local-registry-server-cross/register/url/prefix/getName?name=2",
String.class));
TestMgr.check("2", template
.getForObject("cse://demo-local-registry-server-bean/register/url/prefix/getName?name=2",
String.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
## ---------------------------------------------------------------------------
## 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.
## ---------------------------------------------------------------------------

swagger: "2.0"
info:
version: "1.0.0"
title: "swagger definition for org.apache.servicecomb.demo.registry.ServerEndpoint"
x-java-interface: "gen.swagger.ServerEndpointIntf"
basePath: "/register/url/prefix"
schemes:
- "http"
consumes:
- "application/json"
produces:
- "application/json"
paths:
/getName:
get:
operationId: "getName"
parameters:
- name: "name"
in: "query"
required: true
type: "string"
responses:
"200":
description: "response of 200"
schema:
type: "string"
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,19 @@
## ---------------------------------------------------------------------------

demo-local-registry-server:
- id: "001"
- id: "service-001"
version: "1.0"
appid: demo-local-registry
schemaIds:
- ServerEndpoint
- CodeFirstEndpoint
instances:
- endpoints:
- rest://localhost:8080
demo-local-registry-server-cross:
- id: "service-002"
version: "1.0"
appid: demo-local-registry-cross
schemaIds:
- ServerEndpoint
- CodeFirstEndpoint
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ public void pullInstances() {

protected MicroserviceInstances findServiceInstances() {
return DiscoveryManager.INSTANCE.findServiceInstances(appId,
microserviceName,
shortName,
DefinitionConst.VERSION_RULE_ALL,
revision);
}
Expand Down

0 comments on commit cd5e35b

Please sign in to comment.