Skip to content

Commit 59e0878

Browse files
committed
Properly use vmlens
Signed-off-by: christian.lutnik <[email protected]>
1 parent b8c43e7 commit 59e0878

27 files changed

+103
-307
lines changed

.github/workflows/pullrequest.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ jobs:
4444
- name: Verify with Maven
4545
run: mvn --batch-mode --update-snapshots --activate-profiles e2e,${{ matrix.build.profile }} verify
4646

47+
- name: Verify with vmlens
48+
run: mvn vmlens-maven-plugin:test
49+
4750
- if: matrix.build.java == '17'
4851
name: Upload coverage to Codecov
4952
uses: codecov/[email protected]

pom.xml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
<dependency>
171171
<groupId>com.vmlens</groupId>
172172
<artifactId>api</artifactId>
173-
<version>1.2.10</version>
173+
<version>1.2.11</version>
174174
</dependency>
175175

176176
</dependencies>
@@ -307,13 +307,16 @@
307307
<plugin>
308308
<groupId>com.vmlens</groupId>
309309
<artifactId>vmlens-maven-plugin</artifactId>
310-
<version>1.2.10</version>
310+
<version>1.2.11</version>
311311
<executions>
312312
<execution>
313313
<id>test</id>
314314
<goals>
315315
<goal>test</goal>
316316
</goals>
317+
<configuration>
318+
<agentDirectory>vmlens-agent</agentDirectory>
319+
</configuration>
317320
</execution>
318321
</executions>
319322
</plugin>

src/main/java/dev/openfeature/sdk/VmLensTest.java

Lines changed: 0 additions & 44 deletions
This file was deleted.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
package dev.openfeature.sdk;
2+
3+
import com.vmlens.api.AllInterleavings;
4+
import com.vmlens.api.Runner;
5+
import dev.openfeature.sdk.providers.memory.Flag;
6+
import dev.openfeature.sdk.providers.memory.InMemoryProvider;
7+
import java.util.HashMap;
8+
import java.util.Map;
9+
import org.junit.jupiter.api.AfterEach;
10+
import org.junit.jupiter.api.BeforeEach;
11+
import org.junit.jupiter.api.Test;
12+
13+
import static org.junit.jupiter.api.Assertions.assertEquals;
14+
import static org.junit.jupiter.api.Assertions.assertTrue;
15+
16+
/**
17+
* Javadoc.
18+
*/
19+
class VmLensTest {
20+
final OpenFeatureAPI api = new OpenFeatureAPI();
21+
22+
@BeforeEach
23+
void setUp() {
24+
var flags = new HashMap<String, Flag<?>>();
25+
flags.put("a", Flag.builder().variant("a", "def").defaultVariant("a").build());
26+
flags.put("b", Flag.builder().variant("a", "as").defaultVariant("a").build());
27+
api.setProviderAndWait(new InMemoryProvider(flags));
28+
}
29+
30+
@AfterEach
31+
void tearDown() {
32+
api.clearHooks();
33+
api.shutdown();
34+
}
35+
36+
@Test
37+
void concurrentFlagEvaluations() {
38+
var client = api.getClient();
39+
try (AllInterleavings allInterleavings = new AllInterleavings("Concurrent evaluations")) {
40+
while (allInterleavings.hasNext()) {
41+
Runner.runParallel(
42+
() -> assertEquals("def", client.getStringValue("a", "a")),
43+
() -> assertEquals("as", client.getStringValue("b", "b"))
44+
);
45+
}
46+
}
47+
}
48+
49+
@Test
50+
void concurrentFlagEvaluationsAndHookAdditions() {
51+
var client = api.getClient();
52+
try (AllInterleavings allInterleavings = new AllInterleavings("Concurrent evaluations and hook additions")) {
53+
while (allInterleavings.hasNext()) {
54+
Runner.runParallel(
55+
() -> assertEquals("def", client.getStringValue("a", "a")),
56+
() -> client.addHooks(new StringHook() {})
57+
);
58+
}
59+
}
60+
}
61+
// todo add tests:
62+
// concurrent changing of context thorugh client.setctx... and flags with a targeting rule depending on that context
63+
// concurrent setting of context thorugh client.setctx... and flags with a targeting rule depending on that context
64+
// concurrent changing of context through a hook and flags with a targeting rule depending on that context
65+
// concurrent setting of context through a hook and flags with a targeting rule depending on that context
66+
67+
@Test
68+
void concurrentClientCreations() {
69+
try (AllInterleavings allInterleavings = new AllInterleavings("Concurrent creations of the Client")) {
70+
while (allInterleavings.hasNext()) {
71+
Runner.runParallel(
72+
api::getClient,
73+
api::getClient
74+
);
75+
}
76+
}
77+
// keep the linter happy
78+
assertTrue(true);
79+
}
80+
81+
@Test
82+
void concurrentContextSetting() {
83+
var client = api.getClient();
84+
try (AllInterleavings allInterleavings = new AllInterleavings(
85+
"Concurrently setting the context and evaluating a flag")) {
86+
while (allInterleavings.hasNext()) {
87+
Runner.runParallel(
88+
() -> assertEquals("def", client.getStringValue("a", "a")),
89+
() -> client.setEvaluationContext(new ImmutableContext(Map.of("a", new Value("b")))),
90+
() -> client.setEvaluationContext(new ImmutableContext(Map.of("c", new Value("d"))))
91+
);
92+
}
93+
}
94+
}
95+
}

src/test/java/dev/openfeature/sdk/testutils/VmLensTest.java

Lines changed: 0 additions & 36 deletions
This file was deleted.

standalone/pom.xml

Lines changed: 0 additions & 137 deletions
This file was deleted.

standalone/src/main/java/com/vmlens/Install.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)