Skip to content

Commit

Permalink
[#9601] Fix tests aarch64 compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
smilu97 committed Jan 5, 2023
1 parent 0f27aa2 commit c6f8e5b
Show file tree
Hide file tree
Showing 51 changed files with 4,730 additions and 194 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright 2023 NAVER Corp.
*
* Licensed 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 com.pinpoint.test.plugin.spring.data.r2dbc;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;

/**
* @author youngjin.kim2
*/
public class DockerTestUtils {
public static boolean isArmDockerServer() {
return getDockerArchitecture().contains("arm");
}

private static String getDockerArchitecture() {
final String dockerInfo = execute("docker version", 3000);
final String dockerServerInfo = dockerInfo.substring(dockerInfo.indexOf("Server: "));
final String archLine = Arrays.stream(dockerServerInfo.split("\n"))
.filter(line -> line.contains("OS/Arch:"))
.findFirst()
.orElseThrow(() -> new RuntimeException("Invalid docker version result"));
return archLine.split(":")[1].trim();
}

private static String execute(String command, long waitMillis) {
try {
return execute0(command, waitMillis);
} catch (Throwable th) {
throw new RuntimeException("Failed to run '" + command + "'");
}
}

private static String execute0(String command, long waitMillis) throws InterruptedException, IOException {
final Process proc = Runtime.getRuntime().exec(command);
if (!proc.waitFor(waitMillis, TimeUnit.MILLISECONDS)) {
throw new RuntimeException();
}
return readAll(proc.getInputStream());
}

private static String readAll(InputStream is) {
return new BufferedReader(new InputStreamReader(is))
.lines()
.collect(Collectors.joining("\n"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@ public class R2dbcMariadbTest {
@BeforeClass
public static void beforeClass() {
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable());
Assume.assumeFalse(DockerTestUtils.isArmDockerServer());

container = new MariaDBContainer();
container = new MariaDBContainer("mariadb:10.3.6");
container.withDatabaseName(DATABASE_NAME);
container.withUsername(USERNAME);
container.withPassword(PASSWORD);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class R2dbcOracleTest {
@BeforeClass
public static void beforeClass() {
Assume.assumeTrue("Docker not enabled", DockerClientFactory.instance().isDockerAvailable());
Assume.assumeFalse(DockerTestUtils.isArmDockerServer());

container = new OracleContainer(ORACLE_21_X_IMAGE);
container.setWaitStrategy(Wait.forLogMessage(".*Completed.*", 1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ public class AgentDirBaseClassPathResolverTest {
@BeforeAll
public static void beforeClass() throws Exception {

TEMP_DIR = TEMP_DIR.toRealPath().normalize();
logger.debug("buildDir:{}", TEMP_DIR);

String testDir = TEST_AGENT_DIR + '_' + AGENT_ID_ALLOCATOR.incrementAndGet();
Expand Down
47 changes: 28 additions & 19 deletions plugins-it/google-grpc-it/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,34 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>

<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>test-compile</goal>
<goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>renew-grpc</id>
<build>
<plugins>
<plugin>
<groupId>org.xolstice.maven.plugins</groupId>
<artifactId>protobuf-maven-plugin</artifactId>
<version>0.5.1</version>
<configuration>
<protocArtifact>com.google.protobuf:protoc:${protoc.version}:exe:${os.detected.classifier}</protocArtifact>
<pluginId>grpc-java</pluginId>
<pluginArtifact>io.grpc:protoc-gen-grpc-java:${grpc.version}:exe:${os.detected.classifier}</pluginArtifact>
</configuration>
<executions>
<execution>
<goals>
<goal>test-compile</goal>
<goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading

0 comments on commit c6f8e5b

Please # to comment.