From c92ebc58fed885cf7aeaa3203c16b960e7edd24f Mon Sep 17 00:00:00 2001 From: "liujianjun.ljj" Date: Wed, 26 Jul 2023 21:38:48 +0800 Subject: [PATCH] fix unit test unstable problem --- .../sofa/rpc/registry/mesh/MeshApiClientTest.java | 2 +- .../sofa/rpc/registry/mesh/MeshRegistryTest.java | 2 +- .../sofa/rpc/test/baggage/BaggageAsyncChainTest.java | 6 +++--- .../sofa/rpc/test/baggage/BaggageCallbackTest.java | 6 +++--- .../sofa/rpc/test/baggage/BaggageFutureTest.java | 6 +++--- .../sofa/rpc/test/baggage/BaggageOnewayTest.java | 6 +++--- .../sofa/rpc/test/baggage/BaggageSyncTest.java | 6 +++--- .../test/baggage/BoltProtobufBaggageSyncTest.java | 6 +++--- .../sofa/rpc/triple/TripleHessianInvokeTest.java | 12 ++++++------ 9 files changed, 26 insertions(+), 26 deletions(-) diff --git a/registry/registry-mesh/src/test/java/com/alipay/sofa/rpc/registry/mesh/MeshApiClientTest.java b/registry/registry-mesh/src/test/java/com/alipay/sofa/rpc/registry/mesh/MeshApiClientTest.java index 4f57ab30b..5b97d8b19 100644 --- a/registry/registry-mesh/src/test/java/com/alipay/sofa/rpc/registry/mesh/MeshApiClientTest.java +++ b/registry/registry-mesh/src/test/java/com/alipay/sofa/rpc/registry/mesh/MeshApiClientTest.java @@ -57,7 +57,7 @@ public void testApplicationInfo() { public void before() { httpMockServer = new HttpMockServer(); - meshApiClient = new MeshApiClient("http://localhost:7654"); + meshApiClient = new MeshApiClient("http://127.0.0.1:7654"); httpMockServer.initSever(7654); ApplicationInfoResult applicationInfoResult = new ApplicationInfoResult(); diff --git a/registry/registry-mesh/src/test/java/com/alipay/sofa/rpc/registry/mesh/MeshRegistryTest.java b/registry/registry-mesh/src/test/java/com/alipay/sofa/rpc/registry/mesh/MeshRegistryTest.java index f6a4c595d..ca478aa54 100644 --- a/registry/registry-mesh/src/test/java/com/alipay/sofa/rpc/registry/mesh/MeshRegistryTest.java +++ b/registry/registry-mesh/src/test/java/com/alipay/sofa/rpc/registry/mesh/MeshRegistryTest.java @@ -95,7 +95,7 @@ public void setUp() { .setProtocol("mesh") .setSubscribe(true) .setRegister(true) - .setAddress("http://localhost:7654"); + .setAddress("http://127.0.0.1:7654"); registry = (MeshRegistry) RegistryFactory.getRegistry(registryConfig); registry.init(); diff --git a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageAsyncChainTest.java b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageAsyncChainTest.java index e29ec5c25..f28ff7c9d 100644 --- a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageAsyncChainTest.java +++ b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageAsyncChainTest.java @@ -71,7 +71,7 @@ public void doTest() throws Exception { referenceBeanC.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanC.setInterfaceId(SampleService.class.getName()); referenceBeanC.setUniqueId("C5"); - referenceBeanC.setDirectUrl("localhost:12299"); + referenceBeanC.setDirectUrl("127.0.0.1:12299"); referenceBeanC.setTimeout(1000); MethodConfig methodConfigC = new MethodConfig() .setName("hello") @@ -84,7 +84,7 @@ public void doTest() throws Exception { referenceBeanD.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanD.setInterfaceId(SampleService.class.getName()); referenceBeanD.setUniqueId("D5"); - referenceBeanD.setDirectUrl("localhost:12299?p=1&v=4.0"); + referenceBeanD.setDirectUrl("127.0.0.1:12299?p=1&v=4.0"); referenceBeanD.setTimeout(1000); SampleService sampleServiceD = (SampleService) referenceBeanD.refer(); @@ -107,7 +107,7 @@ public void doTest() throws Exception { referenceBeanA.setApplication(new ApplicationConfig().setAppName("AAA")); referenceBeanA.setUniqueId("B5"); referenceBeanA.setInterfaceId(SampleService.class.getName()); - referenceBeanA.setDirectUrl("localhost:12299"); + referenceBeanA.setDirectUrl("127.0.0.1:12299"); referenceBeanA.setTimeout(3000); MethodConfig methodConfigA = new MethodConfig() .setName("hello") diff --git a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageCallbackTest.java b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageCallbackTest.java index f67e8638f..efd21d684 100644 --- a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageCallbackTest.java +++ b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageCallbackTest.java @@ -72,7 +72,7 @@ public void doTest() throws Exception { referenceBeanC.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanC.setInterfaceId(SampleService.class.getName()); referenceBeanC.setUniqueId("C3"); - referenceBeanC.setDirectUrl("localhost:12299"); + referenceBeanC.setDirectUrl("127.0.0.1:12299"); referenceBeanC.setTimeout(1000); MethodConfig methodConfigC = new MethodConfig() .setName("hello") @@ -85,7 +85,7 @@ public void doTest() throws Exception { referenceBeanD.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanD.setInterfaceId(SampleService.class.getName()); referenceBeanD.setUniqueId("D3"); - referenceBeanD.setDirectUrl("localhost:12299?p=1&v=4.0"); + referenceBeanD.setDirectUrl("127.0.0.1:12299?p=1&v=4.0"); referenceBeanD.setTimeout(1000); MethodConfig methodConfigD = new MethodConfig() .setName("hello") @@ -112,7 +112,7 @@ public void doTest() throws Exception { referenceBeanA.setApplication(new ApplicationConfig().setAppName("AAA")); referenceBeanA.setUniqueId("B3"); referenceBeanA.setInterfaceId(SampleService.class.getName()); - referenceBeanA.setDirectUrl("localhost:12299"); + referenceBeanA.setDirectUrl("127.0.0.1:12299"); referenceBeanA.setTimeout(3000); MethodConfig methodConfigA = new MethodConfig() .setName("hello") diff --git a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageFutureTest.java b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageFutureTest.java index 157fa300b..0137e395e 100644 --- a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageFutureTest.java +++ b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageFutureTest.java @@ -66,7 +66,7 @@ public void doTest() throws Exception { referenceBeanC.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanC.setInterfaceId(SampleService.class.getName()); referenceBeanC.setUniqueId("C2"); - referenceBeanC.setDirectUrl("localhost:12299"); + referenceBeanC.setDirectUrl("127.0.0.1:12299"); referenceBeanC.setTimeout(1000); MethodConfig methodConfigC = new MethodConfig() .setName("hello") @@ -79,7 +79,7 @@ public void doTest() throws Exception { referenceBeanD.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanD.setInterfaceId(SampleService.class.getName()); referenceBeanD.setUniqueId("D2"); - referenceBeanD.setDirectUrl("localhost:12299?p=1&v=4.0"); + referenceBeanD.setDirectUrl("127.0.0.1:12299?p=1&v=4.0"); referenceBeanD.setTimeout(1000); MethodConfig methodConfigD = new MethodConfig() .setName("hello") @@ -103,7 +103,7 @@ public void doTest() throws Exception { referenceBeanA.setApplication(new ApplicationConfig().setAppName("AAA")); referenceBeanA.setUniqueId("B2"); referenceBeanA.setInterfaceId(SampleService.class.getName()); - referenceBeanA.setDirectUrl("localhost:12299"); + referenceBeanA.setDirectUrl("127.0.0.1:12299"); referenceBeanA.setTimeout(3000); MethodConfig methodConfigA = new MethodConfig() .setName("hello") diff --git a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageOnewayTest.java b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageOnewayTest.java index 5deb9685d..ac40fd04f 100644 --- a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageOnewayTest.java +++ b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageOnewayTest.java @@ -65,7 +65,7 @@ void doTest() { referenceBeanC.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanC.setInterfaceId(SampleService.class.getName()); referenceBeanC.setUniqueId("C4"); - referenceBeanC.setDirectUrl("localhost:12299"); + referenceBeanC.setDirectUrl("127.0.0.1:12299"); referenceBeanC.setTimeout(1000); SampleService sampleServiceC = (SampleService) referenceBeanC.refer(); @@ -74,7 +74,7 @@ void doTest() { referenceBeanD.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanD.setInterfaceId(SampleService.class.getName()); referenceBeanD.setUniqueId("D4"); - referenceBeanD.setDirectUrl("localhost:12299?p=1&v=4.0"); + referenceBeanD.setDirectUrl("127.0.0.1:12299?p=1&v=4.0"); referenceBeanD.setTimeout(1000); SampleService sampleServiceD = (SampleService) referenceBeanD.refer(); @@ -94,7 +94,7 @@ void doTest() { referenceBeanA.setApplication(new ApplicationConfig().setAppName("AAA")); referenceBeanA.setUniqueId("B4"); referenceBeanA.setInterfaceId(SampleService.class.getName()); - referenceBeanA.setDirectUrl("localhost:12299"); + referenceBeanA.setDirectUrl("127.0.0.1:12299"); referenceBeanA.setTimeout(3000); MethodConfig methodConfigA = new MethodConfig() .setName("hello") diff --git a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageSyncTest.java b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageSyncTest.java index ba649a379..d476b8b29 100644 --- a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageSyncTest.java +++ b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BaggageSyncTest.java @@ -62,7 +62,7 @@ void doTest() { referenceBeanC.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanC.setInterfaceId(SampleService.class.getName()); referenceBeanC.setUniqueId("C1"); - referenceBeanC.setDirectUrl("localhost:12299"); + referenceBeanC.setDirectUrl("127.0.0.1:12299"); referenceBeanC.setTimeout(1000); SampleService sampleServiceC = (SampleService) referenceBeanC.refer(); @@ -71,7 +71,7 @@ void doTest() { referenceBeanD.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanD.setInterfaceId(SampleService.class.getName()); referenceBeanD.setUniqueId("D1"); - referenceBeanD.setDirectUrl("localhost:12299?p=1&v=4.0"); + referenceBeanD.setDirectUrl("127.0.0.1:12299?p=1&v=4.0"); referenceBeanD.setTimeout(1000); SampleService sampleServiceD = (SampleService) referenceBeanD.refer(); @@ -91,7 +91,7 @@ void doTest() { referenceBeanA.setApplication(new ApplicationConfig().setAppName("AAA")); referenceBeanA.setUniqueId("B1"); referenceBeanA.setInterfaceId(SampleService.class.getName()); - referenceBeanA.setDirectUrl("localhost:12299"); + referenceBeanA.setDirectUrl("127.0.0.1:12299"); referenceBeanA.setTimeout(3000); SampleService service = (SampleService) referenceBeanA.refer(); diff --git a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BoltProtobufBaggageSyncTest.java b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BoltProtobufBaggageSyncTest.java index 4d8f24585..cdfe22811 100644 --- a/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BoltProtobufBaggageSyncTest.java +++ b/test/test-integration/src/test/java/com/alipay/sofa/rpc/test/baggage/BoltProtobufBaggageSyncTest.java @@ -65,7 +65,7 @@ void doTest() { referenceBeanC.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanC.setInterfaceId(SampleService.class.getName()); referenceBeanC.setUniqueId("C1"); - referenceBeanC.setDirectUrl("localhost:12299"); + referenceBeanC.setDirectUrl("127.0.0.1:12299"); referenceBeanC.setSerialization("protobuf"); referenceBeanC.setTimeout(1000); SampleService sampleServiceC = (SampleService) referenceBeanC.refer(); @@ -75,7 +75,7 @@ void doTest() { referenceBeanD.setApplication(new ApplicationConfig().setAppName("BBB")); referenceBeanD.setInterfaceId(SampleService.class.getName()); referenceBeanD.setUniqueId("D1"); - referenceBeanD.setDirectUrl("localhost:12299?p=1&v=4.0"); + referenceBeanD.setDirectUrl("127.0.0.1:12299?p=1&v=4.0"); referenceBeanD.setSerialization("protobuf"); referenceBeanD.setTimeout(1000); SampleService sampleServiceD = (SampleService) referenceBeanD.refer(); @@ -96,7 +96,7 @@ void doTest() { referenceBeanA.setApplication(new ApplicationConfig().setAppName("AAA")); referenceBeanA.setUniqueId("B1"); referenceBeanA.setInterfaceId(SampleService.class.getName()); - referenceBeanA.setDirectUrl("localhost:12299"); + referenceBeanA.setDirectUrl("127.0.0.1:12299"); referenceBeanA.setSerialization("protobuf"); referenceBeanA.setTimeout(3000); diff --git a/test/test-integration/src/test/java/com/alipay/sofa/rpc/triple/TripleHessianInvokeTest.java b/test/test-integration/src/test/java/com/alipay/sofa/rpc/triple/TripleHessianInvokeTest.java index ad88a35e3..535d66e05 100644 --- a/test/test-integration/src/test/java/com/alipay/sofa/rpc/triple/TripleHessianInvokeTest.java +++ b/test/test-integration/src/test/java/com/alipay/sofa/rpc/triple/TripleHessianInvokeTest.java @@ -81,7 +81,7 @@ public void testInvoke() throws InterruptedException { ConsumerConfig consumerConfig = new ConsumerConfig(); consumerConfig.setInterfaceId(TripleHessianInterface.class.getName()) .setProtocol(RpcConstants.PROTOCOL_TYPE_TRIPLE) - .setDirectUrl("localhost:" + port) + .setDirectUrl("127.0.0.1:" + port) .setRegister(false) .setApplication(clientApp); @@ -152,7 +152,7 @@ public void testInvokeWithUniqueId() throws InterruptedException { ConsumerConfig consumerConfig = new ConsumerConfig(); consumerConfig.setInterfaceId(TripleHessianInterface.class.getName()) .setProtocol(RpcConstants.PROTOCOL_TYPE_TRIPLE) - .setDirectUrl("localhost:" + port) + .setDirectUrl("127.0.0.1:" + port) .setUniqueId(uniqueId) .setRegister(false) .setApplication(clientApp); @@ -183,7 +183,7 @@ public void testInvokeWithUniqueId() throws InterruptedException { consumerConfig = new ConsumerConfig(); consumerConfig.setInterfaceId(TripleHessianInterface.class.getName()) .setProtocol(RpcConstants.PROTOCOL_TYPE_TRIPLE) - .setDirectUrl("localhost:" + port) + .setDirectUrl("127.0.0.1:" + port) .setRegister(false) .setApplication(clientApp); @@ -313,7 +313,7 @@ public void testExposeTwoUniqueId() { ConsumerConfig consumerConfig = new ConsumerConfig<>(); consumerConfig.setInterfaceId(TripleHessianInterface.class.getName()) .setProtocol(RpcConstants.PROTOCOL_TYPE_TRIPLE) - .setDirectUrl("localhost:" + port) + .setDirectUrl("127.0.0.1:" + port) .setUniqueId(uniqueId) .setRegister(false) .setApplication(clientApp); @@ -324,7 +324,7 @@ public void testExposeTwoUniqueId() { ConsumerConfig consumerConfig2 = new ConsumerConfig<>(); consumerConfig2.setInterfaceId(TripleHessianInterface.class.getName()) .setProtocol(RpcConstants.PROTOCOL_TYPE_TRIPLE) - .setDirectUrl("localhost:" + port) + .setDirectUrl("127.0.0.1:" + port) .setUniqueId(uniqueId2) .setRegister(false) .setApplication(clientApp); @@ -362,7 +362,7 @@ public void testTripleRpcInvokeContext() { ConsumerConfig consumerConfig = new ConsumerConfig(); consumerConfig.setInterfaceId(TripleHessianInterface.class.getName()) .setProtocol(RpcConstants.PROTOCOL_TYPE_TRIPLE) - .setDirectUrl("localhost:" + port) + .setDirectUrl("127.0.0.1:" + port) .setTimeout(300000) .setRegister(false) .setApplication(clientApp);