Skip to content

Commit

Permalink
Merge branch 'refs/heads/3.3' into feat/refactor_dir
Browse files Browse the repository at this point in the history
# Conflicts:
#	dubbo-demo/README.md
#	dubbo-demo/dubbo-demo-generic-call/pom.xml
#	dubbo-demo/dubbo-demo-interface/pom.xml
#	dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-consumer/pom.xml
#	dubbo-demo/dubbo-demo-spring-boot-idl/dubbo-demo-spring-boot-idl-provider/pom.xml
#	dubbo-demo/dubbo-demo-xml/pom.xml
#	dubbo-demo/pom.xml
  • Loading branch information
CrazyHZM committed Nov 21, 2024
2 parents 79fb004 + a0e39ca commit d6382ac
Show file tree
Hide file tree
Showing 114 changed files with 391 additions and 4,273 deletions.
33 changes: 20 additions & 13 deletions .github/workflows/build-and-test-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ jobs:
github-token: ${{ secrets.GITHUB_TOKEN }}
path: dubbo/
- name: "Upload coverage to Codecov"
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
version: v0.6.0
Expand Down Expand Up @@ -584,15 +584,15 @@ jobs:
- uses: actions/checkout@v4
with:
path: "./dubbo"
- name: "Setup GraalVM environment"
- name: "Set up GraalVM environment"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'
- name: "Setup Zookeeper environment"
- name: "Set up Zookeeper environment"
run: |
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz
tar -zxvf apache-zookeeper-3.8.4-bin.tar.gz
Expand All @@ -604,7 +604,7 @@ jobs:
native-image --version
- name: "Set current date as env variable"
run: echo "TODAY=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: "Restore local maven repository cache"
- name: "Restore local Maven repository cache"
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
Expand All @@ -616,14 +616,21 @@ jobs:
run: |
cd ${{ github.workspace }}/dubbo
./mvnw ${{ env.MAVEN_ARGS }} -T 2C clean install -P '!demo',skip-spotless -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true
- name: "Compile and run Dubbo demo for native (Linux)"
- name: "Checkout dubbo-samples repository"
uses: actions/checkout@v4
with:
repository: 'apache/dubbo-samples'
ref: master
path: "./dubbo-samples"
- name: "Compile and run Dubbo native image demo"
run: |
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface
MVNW="${{ github.workspace }}/dubbo/mvnw ${{ env.MAVEN_ARGS }} -T 2C -Dmaven.test.skip=true"
$MVNW clean install
cd ../dubbo-demo-native-provider
$MVNW clean package -P native native:compile
nohup ./target/dubbo-demo-native-provider &
cd ../dubbo-demo-native-consumer
MVNW="${{ github.workspace }}/dubbo-samples/mvnw ${{ env.MAVEN_ARGS }} -Dmaven.test.skip=true"
cd ${{ github.workspace }}/dubbo-samples/2-advanced/dubbo-samples-native-image/dubbo-samples-native-image-provider
$MVNW clean package -P native native:compile
./target/dubbo-demo-native-consumer
nohup ./target/dubbo-samples-native-image-provider &
sleep 10
curl \
--header "Content-Type: application/json" \
--data '{"name":"Dubbo"}' \
http://localhost:50052/org.apache.dubbo.nativeimage.DemoService/sayHello/
44 changes: 27 additions & 17 deletions .github/workflows/build-and-test-scheduled-3.3.yml
Original file line number Diff line number Diff line change
Expand Up @@ -463,43 +463,53 @@ jobs:
steps:
- uses: actions/checkout@v4
with:
ref: "3.3"
path: "./dubbo"

- name: "Setup GraalVM environment"
- name: "Set up GraalVM environment"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: "Setup Zookeeper environment"
- name: "Set up Zookeeper environment"
run: |
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz
tar -zxvf apache-zookeeper-3.8.4-bin.tar.gz
mv apache-zookeeper-3.8.4-bin/conf/zoo_sample.cfg apache-zookeeper-3.8.4-bin/conf/zoo.cfg
apache-zookeeper-3.8.4-bin/bin/zkServer.sh start
- name: "Check environment"
run: |
java --version
native-image --version
- name: "Set current date as env variable"
run: echo "TODAY=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: "Restore local Maven repository cache"
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.TODAY }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
${{ runner.os }}-maven-
- name: "Compile Dubbo (Linux)"
run: |
cd ${{ github.workspace }}/dubbo
./mvnw ${{ env.MAVEN_ARGS }} -T 2C clean install -P '!demo',skip-spotless -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true
- name: "Compile and run Dubbo demo for native (Linux)"
- name: "Checkout dubbo-samples repository"
uses: actions/checkout@v4
with:
repository: 'apache/dubbo-samples'
ref: master
path: "./dubbo-samples"
- name: "Compile and run Dubbo native image demo"
run: |
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface
MVNW="${{ github.workspace }}/dubbo/mvnw ${{ env.MAVEN_ARGS }} -T 2C -Dmaven.test.skip=true"
$MVNW clean install
cd ../dubbo-demo-native-provider
$MVNW clean package -P native native:compile
nohup ./target/dubbo-demo-native-provider &
cd ../dubbo-demo-native-consumer
MVNW="${{ github.workspace }}/dubbo-samples/mvnw ${{ env.MAVEN_ARGS }} -Dmaven.test.skip=true"
cd ${{ github.workspace }}/dubbo-samples/2-advanced/dubbo-samples-native-image/dubbo-samples-native-image-provider
$MVNW clean package -P native native:compile
./target/dubbo-demo-native-consumer
nohup ./target/dubbo-samples-native-image-provider &
sleep 10
curl \
--header "Content-Type: application/json" \
--data '{"name":"Dubbo"}' \
http://localhost:50052/org.apache.dubbo.nativeimage.DemoService/sayHello/
43 changes: 27 additions & 16 deletions .github/workflows/release-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -460,41 +460,52 @@ jobs:
- uses: actions/checkout@v4
with:
path: "./dubbo"

- name: "Setup GraalVM environment"
- name: "Set up GraalVM environment"
uses: graalvm/setup-graalvm@v1
with:
version: '22.3.0'
java-version: '17'
components: 'native-image'
github-token: ${{ secrets.GITHUB_TOKEN }}
native-image-job-reports: 'true'

- name: "Setup Zookeeper environment"
- name: "Set up Zookeeper environment"
run: |
wget https://dlcdn.apache.org/zookeeper/zookeeper-3.8.4/apache-zookeeper-3.8.4-bin.tar.gz
tar -zxvf apache-zookeeper-3.8.4-bin.tar.gz
mv apache-zookeeper-3.8.4-bin/conf/zoo_sample.cfg apache-zookeeper-3.8.4-bin/conf/zoo.cfg
apache-zookeeper-3.8.4-bin/bin/zkServer.sh start
- name: "Check environment"
run: |
java --version
native-image --version
- name: "Set current date as env variable"
run: echo "TODAY=$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: "Restore local Maven repository cache"
uses: actions/cache/restore@v4
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}-${{ env.TODAY }}
restore-keys: |
${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
${{ runner.os }}-maven-
- name: "Compile Dubbo (Linux)"
run: |
cd ${{ github.workspace }}/dubbo
./mvnw ${{ env.MAVEN_ARGS }} -T 2C clean install -P '!demo',skip-spotless -Dmaven.test.skip=true -Dcheckstyle.skip=true -Dcheckstyle_unix.skip=true -Drat.skip=true
- name: "Compile and run Dubbo demo for native (Linux)"
- name: "Checkout dubbo-samples repository"
uses: actions/checkout@v4
with:
repository: 'apache/dubbo-samples'
ref: master
path: "./dubbo-samples"
- name: "Compile and run Dubbo native image demo"
run: |
cd ${{ github.workspace }}/dubbo/dubbo-demo/dubbo-demo-native/dubbo-demo-native-interface
MVNW="${{ github.workspace }}/dubbo/mvnw ${{ env.MAVEN_ARGS }} -T 2C -Dmaven.test.skip=true"
$MVNW clean install
cd ../dubbo-demo-native-provider
$MVNW clean package -P native native:compile
nohup ./target/dubbo-demo-native-provider &
cd ../dubbo-demo-native-consumer
MVNW="${{ github.workspace }}/dubbo-samples/mvnw ${{ env.MAVEN_ARGS }} -Dmaven.test.skip=true"
cd ${{ github.workspace }}/dubbo-samples/2-advanced/dubbo-samples-native-image/dubbo-samples-native-image-provider
$MVNW clean package -P native native:compile
./target/dubbo-demo-native-consumer
nohup ./target/dubbo-samples-native-image-provider &
sleep 10
curl \
--header "Content-Type: application/json" \
--data '{"name":"Dubbo"}' \
http://localhost:50052/org.apache.dubbo.nativeimage.DemoService/sayHello/
Original file line number Diff line number Diff line change
Expand Up @@ -224,37 +224,36 @@ private String generateUrlNullCheck(int index) {
*/
private String generateMethodContent(Method method) {
Adaptive adaptiveAnnotation = method.getAnnotation(Adaptive.class);
StringBuilder code = new StringBuilder(512);
if (adaptiveAnnotation == null) {
return generateUnsupported(method);
} else {
int urlTypeIndex = getUrlTypeIndex(method);
}
StringBuilder code = new StringBuilder(512);
int urlTypeIndex = getUrlTypeIndex(method);

// found parameter in URL type
if (urlTypeIndex != -1) {
// Null Point check
code.append(generateUrlNullCheck(urlTypeIndex));
} else {
// did not find parameter in URL type
code.append(generateUrlAssignmentIndirectly(method));
}
// found parameter in URL type
if (urlTypeIndex != -1) {
// Null Point check
code.append(generateUrlNullCheck(urlTypeIndex));
} else {
// did not find parameter in URL type
code.append(generateUrlAssignmentIndirectly(method));
}

String[] value = getMethodAdaptiveValue(adaptiveAnnotation);
String[] value = getMethodAdaptiveValue(adaptiveAnnotation);

boolean hasInvocation = hasInvocationArgument(method);
boolean hasInvocation = hasInvocationArgument(method);

code.append(generateInvocationArgumentNullCheck(method));
code.append(generateInvocationArgumentNullCheck(method));

code.append(generateExtNameAssignment(value, hasInvocation));
// check extName == null?
code.append(generateExtNameNullCheck(value));
code.append(generateExtNameAssignment(value, hasInvocation));
// check extName == null?
code.append(generateExtNameNullCheck(value));

code.append(generateScopeModelAssignment());
code.append(generateExtensionAssignment());
code.append(generateScopeModelAssignment());
code.append(generateExtensionAssignment());

// return statement
code.append(generateReturnAndInvocation(method));
}
// return statement
code.append(generateReturnAndInvocation(method));

return code.toString();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.concurrent.TimeUnit;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.mockito.Mockito;

Expand All @@ -29,6 +30,16 @@

class TaskQueueTest {

private TaskQueue<Runnable> queue;
private EagerThreadPoolExecutor executor;

@BeforeEach
void setup() {
queue = new TaskQueue<Runnable>(1);
executor = mock(EagerThreadPoolExecutor.class);
queue.setExecutor(executor);
}

@Test
void testOffer1() throws Exception {
Assertions.assertThrows(RejectedExecutionException.class, () -> {
Expand All @@ -39,53 +50,38 @@ void testOffer1() throws Exception {

@Test
void testOffer2() throws Exception {
TaskQueue<Runnable> queue = new TaskQueue<Runnable>(1);
EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class);
Mockito.when(executor.getPoolSize()).thenReturn(2);
Mockito.when(executor.getActiveCount()).thenReturn(1);
queue.setExecutor(executor);
assertThat(queue.offer(mock(Runnable.class)), is(true));
}

@Test
void testOffer3() throws Exception {
TaskQueue<Runnable> queue = new TaskQueue<Runnable>(1);
EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class);
Mockito.when(executor.getPoolSize()).thenReturn(2);
Mockito.when(executor.getActiveCount()).thenReturn(2);
Mockito.when(executor.getMaximumPoolSize()).thenReturn(4);
queue.setExecutor(executor);
assertThat(queue.offer(mock(Runnable.class)), is(false));
}

@Test
void testOffer4() throws Exception {
TaskQueue<Runnable> queue = new TaskQueue<Runnable>(1);
EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class);
Mockito.when(executor.getPoolSize()).thenReturn(4);
Mockito.when(executor.getActiveCount()).thenReturn(4);
Mockito.when(executor.getMaximumPoolSize()).thenReturn(4);
queue.setExecutor(executor);
assertThat(queue.offer(mock(Runnable.class)), is(true));
}

@Test
void testRetryOffer1() throws Exception {
Assertions.assertThrows(RejectedExecutionException.class, () -> {
TaskQueue<Runnable> queue = new TaskQueue<Runnable>(1);
EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class);
Mockito.when(executor.isShutdown()).thenReturn(true);
queue.setExecutor(executor);
queue.retryOffer(mock(Runnable.class), 1000, TimeUnit.MILLISECONDS);
});
}

@Test
void testRetryOffer2() throws Exception {
TaskQueue<Runnable> queue = new TaskQueue<Runnable>(1);
EagerThreadPoolExecutor executor = mock(EagerThreadPoolExecutor.class);
Mockito.when(executor.isShutdown()).thenReturn(false);
queue.setExecutor(executor);
assertThat(queue.retryOffer(mock(Runnable.class), 1000, TimeUnit.MILLISECONDS), is(true));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.junit.jupiter.api.Assumptions.assumeFalse;
import static org.junit.jupiter.api.Assumptions.assumeTrue;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand All @@ -42,6 +40,9 @@ public void setUp() throws Exception {
when(event.getLevel()).thenReturn(Level.INFO);
when(event.getThreadName()).thenReturn("thread-name");
when(event.getMessage()).thenReturn(new SimpleMessage("message"));

DubboAppender.clear();
DubboAppender.doStop();
}

@AfterEach
Expand All @@ -52,7 +53,7 @@ public void tearDown() throws Exception {

@Test
void testAvailable() {
assumeFalse(DubboAppender.available);
assertThat(DubboAppender.available, is(false));
DubboAppender.doStart();
assertThat(DubboAppender.available, is(true));
DubboAppender.doStop();
Expand All @@ -62,8 +63,9 @@ void testAvailable() {
@Test
void testAppend() {
DubboAppender appender = new DubboAppender();
assertThat(DubboAppender.logList, hasSize(0));
appender.append(event);
assumeTrue(DubboAppender.logList.isEmpty());
assertThat(DubboAppender.logList, hasSize(0));
DubboAppender.doStart();
appender.append(event);
assertThat(DubboAppender.logList, hasSize(1));
Expand All @@ -75,7 +77,7 @@ void testClear() {
DubboAppender.doStart();
DubboAppender appender = new DubboAppender();
appender.append(event);
assumeTrue(1 == DubboAppender.logList.size());
assertThat(DubboAppender.logList, hasSize(1));
DubboAppender.clear();
assertThat(DubboAppender.logList, hasSize(0));
}
Expand Down
Loading

0 comments on commit d6382ac

Please sign in to comment.