Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions .github/workflows/dubbo-3_2.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ jobs:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
java: [ '8', '17' ]
steps:
- uses: actions/checkout@v1
- name: Cache local Maven repository
Expand All @@ -43,13 +45,18 @@ jobs:
key: ${{ runner.os }}-samples-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-samples-maven-
- name: Set up JDK 8
- name: Set up JDK ${{ matrix.Java }}
uses: actions/setup-java@v1
with:
java-version: 8
- name: Build with Maven
java-version: ${{ matrix.Java }}
- name: Build for compiler 8 with Maven
if: matrix.java == '8'
run: |
./mvnw $BUILD_OPTS -pl "-:dubbo-samples-spring-boot-consumer","-:dubbo-samples-spring-boot-provider","-:dubbo-samples-spring-boot-interface","-:dubbo-samples-spring-boot"
- name: Build for compiler 17 with Maven
if: matrix.java == '17'
run: |
./mvnw $BUILD_OPTS
./mvnw $BUILD_OPTS -pl "+:dubbo-samples-spring-boot-consumer","+:dubbo-samples-spring-boot-provider" -am

build-dubbo:
runs-on: ubuntu-latest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>dubbo-samples-spring-boot-consumer</artifactId>

<properties>
<slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
<spring-boot.version>2.3.1.RELEASE</spring-boot.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.dubbo</groupId>
Expand Down Expand Up @@ -60,11 +55,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ dubbo:
address: zookeeper://127.0.0.1:2181
metadata-report:
address: zookeeper://127.0.0.1:2181
service:
org:
apache:
dubbo:
springboot:
demo:
serialization: fastjson2
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
<relativePath>../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>dubbo-samples-spring-boot-provider</artifactId>

<dependencies>
Expand Down Expand Up @@ -56,11 +55,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-autoconfigure</artifactId>
</dependency>

</dependencies>

<build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import org.slf4j.LoggerFactory;
import org.springframework.context.SmartLifecycle;
import org.springframework.util.ErrorHandler;
import org.springframework.util.SocketUtils;

import java.io.File;
import java.lang.reflect.Method;
Expand Down Expand Up @@ -85,7 +84,7 @@ public class EmbeddedZooKeeper implements SmartLifecycle {
* Construct an EmbeddedZooKeeper with a random port.
*/
public EmbeddedZooKeeper() {
clientPort = SocketUtils.findAvailableTcpPort();
clientPort = TestSocketUtils.findAvailableTcpPort();
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* 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.springboot.demo.provider;

import java.net.InetAddress;
import java.net.ServerSocket;
import java.util.Random;

import javax.net.ServerSocketFactory;

import org.apache.dubbo.common.utils.Assert;

/**
* Simple utility for finding available TCP ports on {@code localhost} for use in
* integration testing scenarios.
*
* <p>{@code TestSocketUtils} can be used in integration tests which start an
* external server on an available random port. However, these utilities make no
* guarantee about the subsequent availability of a given port and are therefore
* unreliable. Instead of using {@code TestSocketUtils} to find an available local
* port for a server, it is recommended that you rely on a server's ability to
* start on a random <em>ephemeral</em> port that it selects or is assigned by the
* operating system. To interact with that server, you should query the server
* for the port it is currently using.
*
* @since 3.2
*/
public class TestSocketUtils {

/**
* The minimum value for port ranges used when finding an available TCP port.
*/
static final int PORT_RANGE_MIN = 1024;

/**
* The maximum value for port ranges used when finding an available TCP port.
*/
static final int PORT_RANGE_MAX = 65535;

private static final int PORT_RANGE_PLUS_ONE = PORT_RANGE_MAX - PORT_RANGE_MIN + 1;

private static final int MAX_ATTEMPTS = 1_000;

private static final Random random = new Random(System.nanoTime());

private static final TestSocketUtils INSTANCE = new TestSocketUtils();

private TestSocketUtils() {
}

/**
* Find an available TCP port randomly selected from the range [1024, 65535].
* @return an available TCP port number
* @throws IllegalStateException if no available port could be found
*/
public static int findAvailableTcpPort() {
return INSTANCE.findAvailableTcpPortInternal();
}


/**
* Internal implementation of {@link #findAvailableTcpPort()}.
* <p>Package-private solely for testing purposes.
*/
int findAvailableTcpPortInternal() {
int candidatePort;
int searchCounter = 0;
do {
Assert.assertTrue(++searchCounter <= MAX_ATTEMPTS, String.format(
"Could not find an available TCP port in the range [%d, %d] after %d attempts",
PORT_RANGE_MIN, PORT_RANGE_MAX, MAX_ATTEMPTS));
candidatePort = PORT_RANGE_MIN + random.nextInt(PORT_RANGE_PLUS_ONE);
}
while (!isPortAvailable(candidatePort));

return candidatePort;
}

/**
* Determine if the specified TCP port is currently available on {@code localhost}.
* <p>Package-private solely for testing purposes.
*/
boolean isPortAvailable(int port) {
try {
ServerSocket serverSocket = ServerSocketFactory.getDefault()
.createServerSocket(port, 1, InetAddress.getByName("localhost"));
serverSocket.close();
return true;
}
catch (Exception ex) {
return false;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,10 @@ dubbo:
address: zookeeper://127.0.0.1:2181
metadata-report:
address: zookeeper://127.0.0.1:2181
service:
org:
apache:
dubbo:
springboot:
demo:
serialization: fastjson2
22 changes: 20 additions & 2 deletions 1-basic/dubbo-samples-spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,28 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>jdk17ge</id>
<activation>
<jdk>[17,)</jdk>
</activation>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<spring_version>6.0.2</spring_version>
<dubbo.version>3.2.0-beta.2</dubbo.version>
<junit.version>4.13.2</junit.version>
<spring-boot.version>3.0.0</spring-boot.version>
<spring-boot-maven-plugin.version>3.0.0</spring-boot-maven-plugin.version>
</properties>
</profile>
</profiles>
</project>
2 changes: 1 addition & 1 deletion test/dubbo-test-runner/src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.

ARG JAVA_VER=8
FROM openjdk:$JAVA_VER
FROM eclipse-temurin:$JAVA_VER

ARG DEBIAN_MIRROR
RUN if [ -n "$DEBIAN_MIRROR" ]; then \
Expand Down