Bug description The EnabledIfEnvironmentVariable annotation seems to be ignored.
Environment Please provide as many details as possible: Spring AI version, Java version, which vector store you use if any, etc I am on commit 6f4ab64f, latest on main as of a few hours ago. Spring AI 1.0.0-SNAPSHOT.
$ mvn -v
Apache Maven 3.9.6 (bc0240f3c744dd6b6ec2920b3cd08dcc295161ae)
Maven home: /home/mark/apache-maven-3.9.6
Java version: 21.0.3, vendor: Oracle Corporation, runtime: /home/mark/jdk-21.0.3
Default locale: en, platform encoding: UTF-8
OS name: "linux", version: "5.10.102.1-microsoft-standard-wsl2", arch: "amd64", family: "unix"
Steps to reproduce Add the annotation to this class: models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java
As shown in this diff:
diff --git a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java
index dcf0f303..25bfe949 100644
--- a/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java
+++ b/models/spring-ai-openai/src/test/java/org/springframework/ai/openai/chat/OpenAiRetryTests.java
@@ -20,6 +20,7 @@ import java.util.Optional;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.condition.EnabledIfEnvironmentVariable;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;
@@ -76,6 +77,7 @@ import static org.mockito.Mockito.when;
*/
@SuppressWarnings("unchecked")
@ExtendWith(MockitoExtension.class)
+@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+")
public class OpenAiRetryTests {
private class TestRetryListener implements RetryListener {
Run the integration tests as per the readme, note that I do not have OPENAI_API_KEY env var set.
$ mvn clean verify -Pintegration-tests
Expected behavior I expect that every test with this acnnotation on the class will be skipped, including the one that we just added the annotation to:
@EnabledIfEnvironmentVariable(named = "OPENAI_API_KEY", matches = ".+")
Minimal Complete Reproducible example The steps listed above will reliably reproduce the issue. For example, the newly annotated test (and many others with this annotation) will still be run.
Comment From: markxnelson
Today I am having trouble reproducing this, it may have been an environmental issue :( Closing for now, will reopen if I manage to reproduce it again.