diff --git a/oap-server/server-library/library-integration-test/pom.xml b/oap-server/server-library/library-integration-test/pom.xml new file mode 100644 index 000000000000..7d80e79210ee --- /dev/null +++ b/oap-server/server-library/library-integration-test/pom.xml @@ -0,0 +1,30 @@ + + + + + + server-library + org.apache.skywalking + ${revision} + + 4.0.0 + + library-integration-test + + \ No newline at end of file diff --git a/oap-server/server-library/library-integration-test/src/main/java/org/apache/skywalking/oap/server/library/it/ITVersions.java b/oap-server/server-library/library-integration-test/src/main/java/org/apache/skywalking/oap/server/library/it/ITVersions.java new file mode 100644 index 000000000000..9a0428f8f5e7 --- /dev/null +++ b/oap-server/server-library/library-integration-test/src/main/java/org/apache/skywalking/oap/server/library/it/ITVersions.java @@ -0,0 +1,67 @@ +/* + * 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.skywalking.oap.server.library.it; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Map; +import java.util.stream.Collectors; + +/** + * ITVersions is a utility class to read the version information from the environment file. + */ +public class ITVersions { + + static Map ENV = readingEnv("test", "e2e-v2", "script", "env"); + + // Get the version from the environment file. + public static String get(String key) { + return ENV.get(key); + } + + private static Map readingEnv(String... envFile) { + // Find the project root directory and get the environment file path. + Path envFilePath = getProjectRootDir(); + for (String subPath : envFile) { + envFilePath = envFilePath.resolve(subPath); + } + + try { + return Files.readAllLines(envFilePath).stream() + .filter(l -> !l.startsWith("#")) + .map(l -> l.split("=", 2)) + .filter(l -> l.length == 2) + .collect(Collectors.toMap(l -> l[0], l -> l[1], (older, newer) -> newer)); + } catch (IOException e) { + throw new IllegalStateException("Reading environment file error, path: " + envFile, e); + } + } + + // Get the project root directory which should contain the mvnw file. + private static Path getProjectRootDir() { + Path path = Paths.get(System.getProperty("user.dir")); + while (!Files.exists(path.resolve("mvnw"))) { + path = path.getParent(); + } + return path; + } + +} diff --git a/oap-server/server-library/pom.xml b/oap-server/server-library/pom.xml index 59a56145bcc2..3e92ba599bae 100644 --- a/oap-server/server-library/pom.xml +++ b/oap-server/server-library/pom.xml @@ -36,5 +36,6 @@ library-datacarrier-queue library-kubernetes-support library-async-profiler-jfr-parser + library-integration-test diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/pom.xml b/oap-server/server-storage-plugin/storage-banyandb-plugin/pom.xml index 45908da0a899..8bc6a65134d9 100644 --- a/oap-server/server-storage-plugin/storage-banyandb-plugin/pom.xml +++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/pom.xml @@ -48,5 +48,11 @@ org.apache.skywalking banyandb-java-client + + org.apache.skywalking + library-integration-test + ${project.version} + test + diff --git a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBIT.java b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBIT.java index 725beb1a0209..038f06d24597 100644 --- a/oap-server/server-storage-plugin/storage-banyandb-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBIT.java +++ b/oap-server/server-storage-plugin/storage-banyandb-plugin/src/test/java/org/apache/skywalking/oap/server/storage/plugin/banyandb/BanyanDBIT.java @@ -50,6 +50,7 @@ import org.apache.skywalking.oap.server.core.storage.type.Convert2Entity; import org.apache.skywalking.oap.server.core.storage.type.Convert2Storage; import org.apache.skywalking.oap.server.core.storage.type.StorageBuilder; +import org.apache.skywalking.oap.server.library.it.ITVersions; import org.apache.skywalking.oap.server.library.module.ModuleManager; import org.apache.skywalking.oap.server.library.module.ModuleProviderHolder; import org.apache.skywalking.oap.server.library.module.ModuleServiceHolder; @@ -77,7 +78,7 @@ public class BanyanDBIT { private static final String REGISTRY = "ghcr.io"; private static final String IMAGE_NAME = "apache/skywalking-banyandb"; - private static final String TAG = "6e99ab7e8fed451d24e4d6041ec4c3db7c44f237"; + private static final String TAG = ITVersions.get("SW_BANYANDB_COMMIT"); private static final String IMAGE = REGISTRY + "/" + IMAGE_NAME + ":" + TAG; private static MockedStatic DEFAULT_SCOPE_DEFINE_MOCKED_STATIC;