-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: In-memory provider for e2e testing and minimal usage #546
Changes from all commits
c69b5a9
29c99eb
9af7d1d
4f90f66
47d8127
542395e
4cf9ba4
f85cbb5
1e508ca
071fa03
41987b8
9c67eeb
3cb8ee1
4d9ceed
7f86107
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,8 +11,6 @@ | |
<maven.compiler.source>1.8</maven.compiler.source> | ||
<maven.compiler.target>${maven.compiler.source}</maven.compiler.target> | ||
<junit.jupiter.version>5.10.0</junit.jupiter.version> | ||
<!-- exclusion expression for e2e tests --> | ||
<testExclusions>**/e2e/*.java</testExclusions> | ||
<module-name>${groupId}.${artifactId}</module-name> | ||
</properties> | ||
|
||
|
@@ -21,10 +19,10 @@ | |
<url>https://openfeature.dev</url> | ||
<developers> | ||
<developer> | ||
<id>abrahms</id> | ||
<name>Justin Abrahms</name> | ||
<organization>eBay</organization> | ||
<url>https://justin.abrah.ms/</url> | ||
<id>abrahms</id> | ||
<name>Justin Abrahms</name> | ||
<organization>eBay</organization> | ||
<url>https://justin.abrah.ms/</url> | ||
</developer> | ||
</developers> | ||
<licenses> | ||
|
@@ -120,9 +118,9 @@ | |
</dependency> | ||
|
||
<dependency> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-junit-platform-engine</artifactId> | ||
<scope>test</scope> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-junit-platform-engine</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
|
@@ -139,39 +137,33 @@ | |
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>dev.openfeature.contrib.providers</groupId> | ||
<artifactId>flagd</artifactId> | ||
<version>0.5.10</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<version>4.2.0</version> | ||
<scope>test</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
|
||
<dependency> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-bom</artifactId> | ||
<version>7.13.0</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit</groupId> | ||
<artifactId>junit-bom</artifactId> | ||
<version>5.10.0</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.cucumber</groupId> | ||
<artifactId>cucumber-bom</artifactId> | ||
<version>7.13.0</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.junit</groupId> | ||
<artifactId>junit-bom</artifactId> | ||
<version>5.10.0</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
|
||
</dependencies> | ||
</dependencyManagement> | ||
|
@@ -203,7 +195,7 @@ | |
</execution> | ||
</executions> | ||
</plugin> | ||
|
||
<plugin> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>3.6.0</version> | ||
|
@@ -249,7 +241,7 @@ | |
<excludes> | ||
<!-- tests to exclude --> | ||
<exclude>${testExclusions}</exclude> | ||
</excludes> | ||
</excludes> | ||
</configuration> | ||
</plugin> | ||
|
||
|
@@ -271,7 +263,7 @@ | |
|
||
<executions> | ||
<execution> | ||
<id>prepare-agent</id> | ||
<id>prepare-agent</id> | ||
<goals> | ||
<goal>prepare-agent</goal> | ||
</goals> | ||
|
@@ -319,7 +311,7 @@ | |
</rule> | ||
</rules> | ||
</configuration> | ||
</execution> | ||
</execution> | ||
|
||
</executions> | ||
</plugin> | ||
|
@@ -496,14 +488,11 @@ | |
</profile> | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We do not need to remove this profile. It is still needed and works normally Changes you made at StepDefinisions.java [1] is sufficient to fulfill the comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Without this section, we do not initialize the test-harness submodule. See the build result - https://github.com/open-feature/java-sdk/actions/runs/5824793560/job/15795407914?pr=546 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. By this comment it can be removed, if you still think it should remain update here and I can return it.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, we still need them. Tests are now independent from flagd but we need this profile to intialize git submodule and run gherkin tetsts See the GitHub action - https://github.com/open-feature/java-sdk/blob/main/.github/workflows/pullrequest.yml#L42-L43 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was thinking we could just always pull the submodule and copy the gherkin tests, since now they don't require the external flagd process. I dont really mind if we keep these integration tests on a separate profile or not. I think if we keep the profile though, we should add back the little bit of documentation in the contributing guide about it. |
||
<profile> | ||
<!-- this profile handles running the flagd e2e tests --> | ||
<!-- TODO: this profile can likely be removed with TODO: this section should be updated with https://github.com/open-feature/java-sdk/issues/523 --> | ||
<!-- TODO: we should pull the submodule and run these tests unconditionall once flagd isn't required --> | ||
<id>e2e-test</id> | ||
<properties> | ||
<!-- run the e2e tests by clearing the exclusions --> | ||
<testExclusions/> | ||
</properties> | ||
</properties> | ||
<build> | ||
<plugins> | ||
<!-- pull the gherkin tests as a git submodule --> | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package dev.openfeature.sdk.providers.memory; | ||
|
||
import dev.openfeature.sdk.EvaluationContext; | ||
|
||
/** | ||
* Context evaluator - use for resolving flag according to evaluation context, for handling targeting. | ||
* @param <T> expected value type | ||
*/ | ||
public interface ContextEvaluator<T> { | ||
|
||
T evaluate(Flag flag, EvaluationContext evaluationContext); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package dev.openfeature.sdk.providers.memory; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
import lombok.Singular; | ||
import lombok.ToString; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* Flag representation for the in-memory provider. | ||
*/ | ||
@ToString | ||
@Builder | ||
@Getter | ||
public class Flag<T> { | ||
@Singular | ||
private Map<String, Object> variants; | ||
private String defaultVariant; | ||
private ContextEvaluator<T> contextEvaluator; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than removing, IMO we should mention that the e2e tests use
InMemoryProvider
. Consider the GO SDK readme for reference - https://github.com/open-feature/go-sdk/blob/main/e2e/README.md