Skip to content

Commit

Permalink
Merge pull request #1043 from FoghostCn/native
Browse files Browse the repository at this point in the history
Add native image integration test support
  • Loading branch information
CrazyHZM authored Feb 26, 2024
2 parents 5fd4da0 + cbfa6c8 commit 44b9b14
Show file tree
Hide file tree
Showing 19 changed files with 1,167 additions and 25 deletions.
24 changes: 24 additions & 0 deletions 2-advanced/dubbo-samples-native-image-registry/case-versions.conf
Original file line number Diff line number Diff line change
@@ -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.3.*
spring.version=6.*
java.version= [ >= 17]
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<dubbo.version>3.3.0-beta.1</dubbo.version>
<spring-boot.version>3.0.5</spring-boot.version>
<spring-boot.version>3.2.2</spring-boot.version>
<protobuf-java.version>3.19.6</protobuf-java.version>

<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<native-maven-plugin.version>0.9.28</native-maven-plugin.version>
<native-maven-plugin.version>0.10.1</native-maven-plugin.version>
<junit5.version>5.10.1</junit5.version>
<junit.platform>1.9.3</junit.platform>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -170,6 +172,23 @@
<artifactId>protobuf-java-util</artifactId>
<version>${protobuf-java.version}</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>${junit5.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
<version>${junit.platform}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
Expand Down Expand Up @@ -258,6 +277,88 @@
</plugins>
</build>
</profile>
<profile>
<id>nativeTest</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.1.2</version>
<configuration>
<includes>
<include>${env.TEST_PATTERNS}</include>
</includes>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<executions>
<execution>
<id>process-test-aot</id>
<goals>
<goal>process-test-aot</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.dubbo</groupId>
<artifactId>dubbo-maven-plugin</artifactId>
<version>${dubbo.version}</version>
<executions>
<execution>
<id>dubbo-process-test-aot</id>
<phase>process-test-sources</phase>
<goals>
<goal>dubbo-process-aot</goal>
</goals>
</execution>
<execution>
<id>dubbo-process-test-aot-classes</id>
<phase>process-test-classes</phase>
<goals>
<goal>dubbo-process-aot</goal>
</goals>
</execution>
</executions>
<configuration>
<mainClass>org.apache.dubbo.registry.consumer.NativeDemoConsumerRegistryApplication</mainClass> <!-- https://github.com/apache/dubbo/pull/13426 -->
</configuration>
</plugin>
<plugin>
<groupId>org.graalvm.buildtools</groupId>
<artifactId>native-maven-plugin</artifactId>
<version>${native-maven-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<classesDirectory>${project.build.outputDirectory}</classesDirectory>
<metadataRepository>
<enabled>true</enabled>
</metadataRepository>
<requiredVersion>22.3</requiredVersion>
<buildArgs>
-H:+ReportExceptionStackTraces
</buildArgs>
<systemProperties>
<zookeeper.address>${zookeeper.address}</zookeeper.address>
</systemProperties>
</configuration>
<executions>
<execution>
<id>native-test</id>
<goals>
<goal>test</goal>
</goals>
<phase>test</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>

<repositories>
Expand All @@ -275,4 +376,4 @@
</snapshots>
</repository>
</repositories>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public static void main(String[] args) throws InterruptedException {
System.out.println("The time taken for the first call is "
+ (System.currentTimeMillis() - startCallTime) +" ms");
System.out.println("result: " + result);
System.exit(0);
}

public String doSayHello(String name) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ dubbo:
logger: slf4j
qos-port: 22223
registry:
address: zookeeper://127.0.0.1:2181
address: zookeeper://${zookeeper.address:127.0.0.1}:2181

logging:
pattern:
level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'

server:
port: 9091
port: 9091
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* 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.registry;

import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.registry.consumer.NativeDemoConsumerRegistryApplication;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit.jupiter.SpringExtension;

/**
* if not use SpringBootTest annotation you have to config proxy-config.json and serialization-config.json Manually
*/
@SpringBootTest(classes = {NativeDemoConsumerRegistryApplication.class})
@ExtendWith(SpringExtension.class)
class DemoServiceTestIT {
private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1");
@Test
public void sayHello() {
ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
reference.setApplication(new ApplicationConfig("first-dubbo-consumer"));
reference.setRegistry(new RegistryConfig("zookeeper://" + zookeeperHost + ":2181"));
reference.setInterface(DemoService.class);
DemoService service = reference.get();
HelloResponse message = service.sayHello(new HelloRequest("dubbo"));
Assertions.assertEquals("dubbo", message.getResponse());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

<dubbo.version>3.3.0-beta.1</dubbo.version>
<spring-boot.version>3.0.5</spring-boot.version>
<spring-boot.version>3.2.2</spring-boot.version>
<protobuf-java.version>3.19.6</protobuf-java.version>

<maven-compiler-plugin.version>3.10.1</maven-compiler-plugin.version>
<native-maven-plugin.version>0.9.28</native-maven-plugin.version>
<native-maven-plugin.version>0.10.1</native-maven-plugin.version>
</properties>

<dependencyManagement>
Expand Down Expand Up @@ -275,4 +275,4 @@
</snapshots>
</repository>
</repositories>
</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ dubbo:
provider:
serialization: fastjson2
registry:
address: "zookeeper://127.0.0.1:2181"
address: zookeeper://${zookeeper.address:127.0.0.1}:2181

logging:
pattern:
level: '%5p [${spring.application.name:},%X{traceId:-},%X{spanId:-}]'

server:
port: 9090
port: 9090
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# 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.

timeout: 600

services:
zookeeper:
image: zookeeper:latest

dubbo-samples-native-image-registry-provider:
type: nativeApp
basedir: dubbo-samples-native-image-registry-provider
checkLog: "dubbo provider application started"
checkPorts:
- 50052
waitPortsBeforeRun:
- zookeeper:2181
depends_on:
- zookeeper
systemProps:
- zookeeper.address=zookeeper

dubbo-samples-native-image-registry-consumer:
type: nativeApp
basedir: dubbo-samples-native-image-registry-consumer
checkLog: "dubbo consumer application started"
waitPortsBeforeRun:
- zookeeper:2181
- dubbo-samples-native-image-registry-provider:50052
depends_on:
- zookeeper
systemProps:
- zookeeper.address=zookeeper

dubbo-samples-native-image-registry-test:
type: nativeTest
basedir: dubbo-samples-native-image-registry-consumer
tests:
- "**/*IT.class"
depends_on:
- zookeeper
systemProps:
- zookeeper.address=zookeeper
waitPortsBeforeRun:
- zookeeper:2181
- dubbo-samples-native-image-registry-provider:50052
10 changes: 10 additions & 0 deletions test/build-native-test-image.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

# Use mirror:
# DEBIAN_MIRROR=http://mirrors.aliyun.com ./build-test-image.sh

DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"

$DIR/dubbo-test-runner/build-native.sh

$DIR/build-nacos-image.sh
Loading

0 comments on commit 44b9b14

Please sign in to comment.