diff --git a/.github/workflows/dubbo-3_2.yml b/.github/workflows/dubbo-3_2.yml index 8bbb59f3d0..6c91df24f7 100644 --- a/.github/workflows/dubbo-3_2.yml +++ b/.github/workflows/dubbo-3_2.yml @@ -51,6 +51,9 @@ jobs: - name: Build with Maven run: | ./mvnw $BUILD_OPTS + - name: Clean with Maven + run: | + ./mvnw --batch-mode --no-snapshot-updates --no-transfer-progress --settings ${{github.workspace}}/.mvn/settings.xml clean build-dubbo: runs-on: ubuntu-latest diff --git a/.github/workflows/dubbo-3_3.yml b/.github/workflows/dubbo-3_3.yml index c6daccd2d7..177b618145 100644 --- a/.github/workflows/dubbo-3_3.yml +++ b/.github/workflows/dubbo-3_3.yml @@ -51,6 +51,9 @@ jobs: - name: Build with Maven run: | ./mvnw $BUILD_OPTS + - name: Clean with Maven + run: | + ./mvnw --batch-mode --no-snapshot-updates --no-transfer-progress --settings ${{github.workspace}}/.mvn/settings.xml clean build-dubbo: runs-on: ubuntu-latest diff --git a/99-integration/dubbo-samples-test-13078/case-configuration.yml b/99-integration/dubbo-samples-test-13078/case-configuration.yml new file mode 100644 index 0000000000..a739955d2d --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/case-configuration.yml @@ -0,0 +1,23 @@ +# 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. + +from: app-external-zookeeper.yml + +props: + project_name: dubbo-samples-test-13078 + main_class: org.apache.dubbo.samples.provider.Application + dubbo_port: 50051 + check_log: "DubboBootstrap awaiting ..." diff --git a/99-integration/dubbo-samples-test-13078/case-versions.conf b/99-integration/dubbo-samples-test-13078/case-versions.conf new file mode 100644 index 0000000000..5610cf334a --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/case-versions.conf @@ -0,0 +1,24 @@ +# +# +# 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. +# + + +# Supported component versions of the test case + +# Spring app +dubbo.version=3.* +java.version= [ >= 8 ] \ No newline at end of file diff --git a/99-integration/dubbo-samples-test-13078/pom.xml b/99-integration/dubbo-samples-test-13078/pom.xml new file mode 100644 index 0000000000..5018112055 --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/pom.xml @@ -0,0 +1,108 @@ + + + + + + org.apache + apache + 23 + + + + org.apache.dubbo + 1.0-SNAPSHOT + + 4.0.0 + + dubbo-samples-test-13078 + Dubbo Samples Test for 13078 + Dubbo Samples Test for 13078 + + + 3.2.8-SNAPSHOT + 5.9.2 + 1.8 + 1.8 + 1.7.33 + 4.2.0 + + + + + org.apache.dubbo + dubbo + ${dubbo.version} + + + + org.apache.dubbo + dubbo-dependencies-zookeeper-curator5 + ${dubbo.version} + pom + + + logback-classic + ch.qos.logback + + + logback-core + ch.qos.logback + + + + + + org.slf4j + slf4j-log4j12 + ${slf4j-log4j12.version} + + + + com.google.protobuf + protobuf-java + 3.22.2 + + + + org.awaitility + awaitility + ${awaitility.version} + + + + org.junit.jupiter + junit-jupiter-engine + ${junit5.version} + test + + + org.junit.jupiter + junit-jupiter-api + ${junit5.version} + test + + + org.junit.jupiter + junit-jupiter-params + ${junit5.version} + test + + + diff --git a/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java b/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java new file mode 100644 index 0000000000..06b2356700 --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/api/GreetingsService.java @@ -0,0 +1,22 @@ +/* + * 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 org.apache.dubbo.samples.api; + +public interface GreetingsService { + String sayHi(String name); +} diff --git a/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/provider/Application.java b/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/provider/Application.java new file mode 100644 index 0000000000..4d67dce39a --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/provider/Application.java @@ -0,0 +1,44 @@ +/* + * 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 org.apache.dubbo.samples.provider; + +import org.apache.dubbo.config.ProtocolConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.config.ServiceConfig; +import org.apache.dubbo.config.bootstrap.DubboBootstrap; +import org.apache.dubbo.samples.api.GreetingsService; + +public class Application { + private static final String ZOOKEEPER_HOST = System.getProperty("zookeeper.address", "127.0.0.1"); + private static final String ZOOKEEPER_PORT = System.getProperty("zookeeper.port", "2181"); + private static final String ZOOKEEPER_ADDRESS = "zookeeper://" + ZOOKEEPER_HOST + ":" + ZOOKEEPER_PORT; + + public static void main(String[] args) { + ServiceConfig service = new ServiceConfig<>(); + service.setInterface(GreetingsService.class); + service.setRef(new GreetingsServiceImpl()); + + DubboBootstrap.getInstance() + .application("first-dubbo-provider") + .registry(new RegistryConfig(ZOOKEEPER_ADDRESS)) + .protocol(new ProtocolConfig("tri", -1)) + .service(service) + .start() + .await(); + } +} diff --git a/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java b/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java new file mode 100644 index 0000000000..d0d444843a --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/src/main/java/org/apache/dubbo/samples/provider/GreetingsServiceImpl.java @@ -0,0 +1,27 @@ +/* + * 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 org.apache.dubbo.samples.provider; + +import org.apache.dubbo.samples.api.GreetingsService; + +public class GreetingsServiceImpl implements GreetingsService { + @Override + public String sayHi(String name) { + return "hi, " + name; + } +} diff --git a/99-integration/dubbo-samples-test-13078/src/main/resources/log4j.properties b/99-integration/dubbo-samples-test-13078/src/main/resources/log4j.properties new file mode 100644 index 0000000000..e976f5c2b4 --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/src/main/resources/log4j.properties @@ -0,0 +1,25 @@ +# +# +# 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. +# +# +###set log levels### +log4j.rootLogger=info, stdout +###output to the console### +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.Target=System.out +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n \ No newline at end of file diff --git a/99-integration/dubbo-samples-test-13078/src/main/resources/logback.xml b/99-integration/dubbo-samples-test-13078/src/main/resources/logback.xml new file mode 100644 index 0000000000..39fae26ebb --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/src/main/resources/logback.xml @@ -0,0 +1,30 @@ + + + +     +       +          %-4relative [%thread] %-5level %logger{35} - %msg %n +       +     + +     +        +     + diff --git a/99-integration/dubbo-samples-test-13078/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java b/99-integration/dubbo-samples-test-13078/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java new file mode 100644 index 0000000000..8ac4b517ab --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/src/test/java/org/apache/dubbo/samples/client/GreetingServiceIT.java @@ -0,0 +1,74 @@ +/* + * 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 org.apache.dubbo.samples.client; + +import org.apache.dubbo.config.ApplicationConfig; +import org.apache.dubbo.config.ReferenceConfig; +import org.apache.dubbo.config.RegistryConfig; +import org.apache.dubbo.rpc.RpcException; +import org.apache.dubbo.samples.api.GreetingsService; + +import io.netty.handler.codec.http2.Http2Connection; +import io.netty.handler.codec.http2.Http2LocalFlowController; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Test; + +import java.util.List; +import java.util.concurrent.TimeUnit; + +import static org.awaitility.Awaitility.await; + +public class GreetingServiceIT { + private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1"); + + @Test + public void test() { + ReferenceConfig reference = new ReferenceConfig<>(); + reference.setApplication(new ApplicationConfig("first-dubbo-consumer")); + reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181")); + reference.setInterface(GreetingsService.class); + GreetingsService service = reference.get(); + + for (int i = 0; i < 100; i++) { + String message = service.sayHi("dubbo"); + Assertions.assertEquals("hi, dubbo", message); + } + + List> endpoints = WireProtocolWrapper.getEndpoints(); + Assertions.assertEquals(1, endpoints.size()); + Http2Connection.Endpoint endpoint = endpoints.get(0); + while (endpoint.incrementAndGetNextStreamId() > 0) { + endpoint.incrementAndGetNextStreamId(); + } + + try { + service.sayHi("dubbo"); + Assertions.fail(); + } catch (RpcException e) { + Assertions.assertEquals("java.util.concurrent.ExecutionException: org.apache.dubbo.rpc.StatusRpcException: INTERNAL : Http2 exception", e.getMessage()); + } + + await().atMost(60, TimeUnit.SECONDS).untilAsserted( + () -> Assertions.assertEquals(2, endpoints.size())); + + for (int i = 0; i < 100; i++) { + String message = service.sayHi("dubbo"); + Assertions.assertEquals("hi, dubbo", message); + } + } +} diff --git a/99-integration/dubbo-samples-test-13078/src/test/java/org/apache/dubbo/samples/client/WireProtocolWrapper.java b/99-integration/dubbo-samples-test-13078/src/test/java/org/apache/dubbo/samples/client/WireProtocolWrapper.java new file mode 100644 index 0000000000..afda5e4510 --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/src/test/java/org/apache/dubbo/samples/client/WireProtocolWrapper.java @@ -0,0 +1,79 @@ +/* + * 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 org.apache.dubbo.samples.client; + +import org.apache.dubbo.common.URL; +import org.apache.dubbo.remoting.api.ProtocolDetector; +import org.apache.dubbo.remoting.api.WireProtocol; +import org.apache.dubbo.remoting.api.pu.ChannelOperator; +import org.apache.dubbo.remoting.api.ssl.ContextOperator; + +import io.netty.channel.Channel; +import io.netty.handler.codec.http2.Http2Connection; +import io.netty.handler.codec.http2.Http2FrameCodec; +import io.netty.handler.codec.http2.Http2LocalFlowController; + +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +public class WireProtocolWrapper implements WireProtocol { + private final WireProtocol wireProtocol; + private final static List> endpoints = new CopyOnWriteArrayList<>(); + + public WireProtocolWrapper(WireProtocol wireProtocol) { + this.wireProtocol = wireProtocol; + } + + @Override + public ProtocolDetector detector() { + return wireProtocol.detector(); + } + + @Override + public void configServerProtocolHandler(URL url, ChannelOperator operator) { + wireProtocol.configServerProtocolHandler(url, operator); + } + + @Override + public void configClientPipeline(URL url, ChannelOperator operator, ContextOperator contextOperator) { + wireProtocol.configClientPipeline(url, operator, contextOperator); + try { + Field channelField = operator.getClass().getDeclaredField("channel"); + channelField.setAccessible(true); + Object dubboChannel = channelField.get(operator); + Method getNioChannelMethod = dubboChannel.getClass().getDeclaredMethod("getNioChannel"); + getNioChannelMethod.setAccessible(true); + Channel channel = (Channel)getNioChannelMethod.invoke(dubboChannel); + Http2FrameCodec http2FrameCodec = channel.pipeline().get(Http2FrameCodec.class); + Http2Connection.Endpoint endpoint = http2FrameCodec.connection().local(); + endpoints.add(endpoint); + } catch (Throwable t) { + t.printStackTrace(); + } + } + + @Override + public void close() { + wireProtocol.close(); + } + + public static List> getEndpoints() { + return endpoints; + } +} diff --git a/99-integration/dubbo-samples-test-13078/src/test/resources/META-INF/dubbo/org.apache.dubbo.remoting.api.WireProtocol b/99-integration/dubbo-samples-test-13078/src/test/resources/META-INF/dubbo/org.apache.dubbo.remoting.api.WireProtocol new file mode 100644 index 0000000000..e53dab7950 --- /dev/null +++ b/99-integration/dubbo-samples-test-13078/src/test/resources/META-INF/dubbo/org.apache.dubbo.remoting.api.WireProtocol @@ -0,0 +1 @@ +wire-wrap=org.apache.dubbo.samples.client.WireProtocolWrapper diff --git a/99-integration/pom.xml b/99-integration/pom.xml index 3251b724dc..c4391a15a1 100644 --- a/99-integration/pom.xml +++ b/99-integration/pom.xml @@ -67,6 +67,7 @@ dubbo-samples-test-12376 dubbo-samples-test-12631 dubbo-samples-test-12697 + dubbo-samples-test-13078 dubbo-samples-test-13133 dubbo-samples-test-abc-async dubbo-samples-test-register