Skip to content

Commit 3601ba1

Browse files
authored
Add ITVersion for helping management the versions in IT (#12895)
1 parent 82967c9 commit 3601ba1

File tree

5 files changed

+106
-1
lines changed
  • oap-server
    • server-library
    • server-storage-plugin/storage-banyandb-plugin

5 files changed

+106
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one or more
4+
~ contributor license agreements. See the NOTICE file distributed with
5+
~ this work for additional information regarding copyright ownership.
6+
~ The ASF licenses this file to You under the Apache License, Version 2.0
7+
~ (the "License"); you may not use this file except in compliance with
8+
~ the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
~
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<parent>
22+
<artifactId>server-library</artifactId>
23+
<groupId>org.apache.skywalking</groupId>
24+
<version>${revision}</version>
25+
</parent>
26+
<modelVersion>4.0.0</modelVersion>
27+
28+
<artifactId>library-integration-test</artifactId>
29+
30+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*
17+
*/
18+
19+
package org.apache.skywalking.oap.server.library.it;
20+
21+
import java.io.IOException;
22+
import java.nio.file.Files;
23+
import java.nio.file.Path;
24+
import java.nio.file.Paths;
25+
import java.util.Map;
26+
import java.util.stream.Collectors;
27+
28+
/**
29+
* ITVersions is a utility class to read the version information from the environment file.
30+
*/
31+
public class ITVersions {
32+
33+
static Map<String, String> ENV = readingEnv("test", "e2e-v2", "script", "env");
34+
35+
// Get the version from the environment file.
36+
public static String get(String key) {
37+
return ENV.get(key);
38+
}
39+
40+
private static Map<String, String> readingEnv(String... envFile) {
41+
// Find the project root directory and get the environment file path.
42+
Path envFilePath = getProjectRootDir();
43+
for (String subPath : envFile) {
44+
envFilePath = envFilePath.resolve(subPath);
45+
}
46+
47+
try {
48+
return Files.readAllLines(envFilePath).stream()
49+
.filter(l -> !l.startsWith("#"))
50+
.map(l -> l.split("=", 2))
51+
.filter(l -> l.length == 2)
52+
.collect(Collectors.toMap(l -> l[0], l -> l[1], (older, newer) -> newer));
53+
} catch (IOException e) {
54+
throw new IllegalStateException("Reading environment file error, path: " + envFile, e);
55+
}
56+
}
57+
58+
// Get the project root directory which should contain the mvnw file.
59+
private static Path getProjectRootDir() {
60+
Path path = Paths.get(System.getProperty("user.dir"));
61+
while (!Files.exists(path.resolve("mvnw"))) {
62+
path = path.getParent();
63+
}
64+
return path;
65+
}
66+
67+
}

oap-server/server-library/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,6 @@
3636
<module>library-datacarrier-queue</module>
3737
<module>library-kubernetes-support</module>
3838
<module>library-async-profiler-jfr-parser</module>
39+
<module>library-integration-test</module>
3940
</modules>
4041
</project>

oap-server/server-storage-plugin/storage-banyandb-plugin/pom.xml

+6
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,11 @@
4848
<groupId>org.apache.skywalking</groupId>
4949
<artifactId>banyandb-java-client</artifactId>
5050
</dependency>
51+
<dependency>
52+
<groupId>org.apache.skywalking</groupId>
53+
<artifactId>library-integration-test</artifactId>
54+
<version>${project.version}</version>
55+
<scope>test</scope>
56+
</dependency>
5157
</dependencies>
5258
</project>

oap-server/server-storage-plugin/storage-banyandb-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBIT.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
import org.apache.skywalking.oap.server.core.storage.type.Convert2Entity;
5151
import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage;
5252
import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder;
53+
import org.apache.skywalking.oap.server.library.it.ITVersions;
5354
import org.apache.skywalking.oap.server.library.module.ModuleManager;
5455
import org.apache.skywalking.oap.server.library.module.ModuleProviderHolder;
5556
import org.apache.skywalking.oap.server.library.module.ModuleServiceHolder;
@@ -77,7 +78,7 @@
7778
public class BanyanDBIT {
7879
private static final String REGISTRY = "ghcr.io";
7980
private static final String IMAGE_NAME = "apache/skywalking-banyandb";
80-
private static final String TAG = "6e99ab7e8fed451d24e4d6041ec4c3db7c44f237";
81+
private static final String TAG = ITVersions.get("SW_BANYANDB_COMMIT");
8182

8283
private static final String IMAGE = REGISTRY + "/" + IMAGE_NAME + ":" + TAG;
8384
private static MockedStatic<DefaultScopeDefine> DEFAULT_SCOPE_DEFINE_MOCKED_STATIC;

0 commit comments

Comments
 (0)