-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#9601] Fix tests aarch64 compatible
- Loading branch information
Showing
54 changed files
with
4,734 additions
and
197 deletions.
There are no files selected for viewing
65 changes: 65 additions & 0 deletions
65
...gin-testweb/src/test/java/com/pinpoint/test/plugin/spring/data/r2dbc/DockerTestUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.