-
Notifications
You must be signed in to change notification settings - Fork 50
feat: Add vmlens checks #1567
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
Merged
Merged
feat: Add vmlens checks #1567
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
14c6f8b
Add vmlens
chrfwow 74782fc
fix test and gitignore
chrfwow 3446f99
remove vmlens agent binary
chrfwow e17c78b
Merge branch 'main' into make-hooks-thread-safer
aepfli 0fdedcb
remove unused import
chrfwow bfc1db3
Merge remote-tracking branch 'origin/make-hooks-thread-safer' into ma…
chrfwow b35e3d8
remove vmlens from gitignore, add failing test to check if vmlens sti…
chrfwow 41b362e
remove failing test
chrfwow 5cc735e
remove volatile
chrfwow 2a6bc56
update vmlens
chrfwow 670a7a8
Merge branch 'main' into make-hooks-thread-safer
chrfwow 2deca55
Merge branch 'main' into make-hooks-thread-safer
chrfwow 93cc4f9
Merge remote-tracking branch 'origin/main' into make-hooks-thread-safer
chrfwow 16afb2d
Merge remote-tracking branch 'origin/make-hooks-thread-safer' into ma…
chrfwow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,3 +13,6 @@ target | |
|
||
# used for spec compliance tooling | ||
java-report.json | ||
|
||
# vmlens stuff | ||
/vmlens-agent/vmlens/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package dev.openfeature.sdk.vmlens; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import com.vmlens.api.AllInterleavings; | ||
import com.vmlens.api.Runner; | ||
import dev.openfeature.sdk.ImmutableContext; | ||
import dev.openfeature.sdk.OpenFeatureAPI; | ||
import dev.openfeature.sdk.OpenFeatureAPITestUtil; | ||
import dev.openfeature.sdk.Value; | ||
import dev.openfeature.sdk.providers.memory.Flag; | ||
import dev.openfeature.sdk.providers.memory.InMemoryProvider; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import org.junit.jupiter.api.AfterEach; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class VmLensTest { | ||
final OpenFeatureAPI api = OpenFeatureAPITestUtil.createAPI(); | ||
|
||
@BeforeEach | ||
void setUp() { | ||
var flags = new HashMap<String, Flag<?>>(); | ||
flags.put("a", Flag.builder().variant("a", "def").defaultVariant("a").build()); | ||
flags.put("b", Flag.builder().variant("a", "as").defaultVariant("a").build()); | ||
api.setProviderAndWait(new InMemoryProvider(flags)); | ||
} | ||
|
||
@AfterEach | ||
void tearDown() { | ||
api.clearHooks(); | ||
api.shutdown(); | ||
} | ||
|
||
@Test | ||
void concurrentClientCreations() { | ||
try (AllInterleavings allInterleavings = new AllInterleavings("Concurrent creations of the Client")) { | ||
while (allInterleavings.hasNext()) { | ||
Runner.runParallel(api::getClient, api::getClient); | ||
} | ||
} | ||
// keep the linter happy | ||
assertTrue(true); | ||
} | ||
|
||
@Test | ||
void concurrentFlagEvaluations() { | ||
var client = api.getClient(); | ||
try (AllInterleavings allInterleavings = new AllInterleavings("Concurrent evaluations")) { | ||
while (allInterleavings.hasNext()) { | ||
Runner.runParallel( | ||
() -> assertEquals("def", client.getStringValue("a", "a")), | ||
() -> assertEquals("as", client.getStringValue("b", "b"))); | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
void concurrentContextSetting() { | ||
var client = api.getClient(); | ||
var contextA = new ImmutableContext(Map.of("a", new Value("b"))); | ||
var contextB = new ImmutableContext(Map.of("c", new Value("d"))); | ||
try (AllInterleavings allInterleavings = | ||
new AllInterleavings("Concurrently setting the context and evaluating a flag")) { | ||
while (allInterleavings.hasNext()) { | ||
Runner.runParallel( | ||
() -> assertEquals("def", client.getStringValue("a", "a")), | ||
() -> client.setEvaluationContext(contextA), | ||
() -> client.setEvaluationContext(contextB)); | ||
assertThat(client.getEvaluationContext()).isIn(contextA, contextB); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.