Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// 直接实现 dotenv 功能,避免插件依赖
fun loadDotenv() {
val envFile = rootProject.file(".env")
if (envFile.exists()) {
envFile.readLines().forEach { line ->
val trimmedLine = line.trim()
if (trimmedLine.isNotEmpty() && !trimmedLine.startsWith("#")) {
val parts = trimmedLine.split("=", limit = 2)
if (parts.size == 2) {
val key = parts[0].trim()
val value = parts[1].trim().removeSurrounding("\"").removeSurrounding("'")
if (key.isNotEmpty() && value.isNotEmpty()) {
// 设置到所有任务的环境变量中
tasks.withType<Test> { environment(key, value) }
tasks.withType<JavaExec> { environment(key, value) }
logger.debug("Loaded environment variable: $key")
}
}
}
}
logger.info("Loaded .env file from: ${envFile.absolutePath}")
} else {
logger.warn(".env file not found at: ${envFile.absolutePath}")
}
}

// 加载 dotenv 配置
loadDotenv()
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ org-springframework-modulith = "2.0.0-M1"
org-springframework-security = "6.5.5"
org-testcontainers = "1.21.3"
org-testng = "7.11.0"
project = "0.0.36"
project = "0.0.37"

[libraries]
ch-qos-logback-logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "ch-qos-logback" }
Expand Down
15 changes: 15 additions & 0 deletions integrate-test/oss/volcengine-tos/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
plugins {
id("buildlogic.kotlinspring-test-conventions")
id("buildlogic.spotless-conventions")
id("buildlogic.loadenv-conventions")
}

dependencies {
implementation(projects.oss.ossVolcengineTos)

testImplementation(libs.com.volcengine.ve.tos.java.sdk)

testImplementation(projects.testtoolkit.testtoolkitSpringmvc)
testImplementation(projects.testtoolkit.testtoolkitTestcontainers)
testImplementation(libs.org.springframework.boot.spring.boot.starter.web)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package itest.integrate.oss.volcenginetos

import io.github.truenine.composeserver.logger
import io.github.truenine.composeserver.oss.volcengine.properties.VolcengineTosProperties

val log = logger<Any>()

private val accessKey = System.getenv("VOLCENGINE_TOS_ACCESS_KEY")?.takeIf { it.isNotBlank() }
private val secretKey = System.getenv("VOLCENGINE_TOS_SECRET_KEY")?.takeIf { it.isNotBlank() }
private val hasCredentials = !accessKey.isNullOrBlank() && !secretKey.isNullOrBlank()

data class OssAkSk(val ak: String, val sk: String, val endpoint: String = VolcengineTosProperties.DEFAULT_ENDPOINT)

fun hasTosRequiredEnvironmentVariables(): Boolean {
if (!hasCredentials) {
log.warn("Skipping Volcengine TOS integration tests: missing required environment variables VOLCENGINE_TOS_ACCESS_KEY or VOLCENGINE_TOS_SECRET_KEY")
} else {
log.info("Detected Volcengine TOS credentials, will execute integration tests")
}
return hasCredentials
}

fun getTosAkSk(): OssAkSk? {
return if (hasTosRequiredEnvironmentVariables()) {
OssAkSk(accessKey!!, secretKey!!)
} else {
null
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package itest.integrate.oss.volcenginetos

import org.springframework.boot.autoconfigure.SpringBootApplication

@SpringBootApplication internal class TestEntrance
Loading
Loading