Skip to content

Commit d2b3cd4

Browse files
committed
test(flagd): rework e2e tests to new format
Signed-off-by: Simon Schrottner <[email protected]>
1 parent 819abe3 commit d2b3cd4

36 files changed

+557
-1446
lines changed

Diff for: pom.xml

+7
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,13 @@
213213
<scope>test</scope>
214214
</dependency>
215215

216+
<dependency>
217+
<groupId>io.cucumber</groupId>
218+
<artifactId>cucumber-picocontainer</artifactId>
219+
<version>7.20.1</version>
220+
<scope>test</scope>
221+
</dependency>
222+
216223
<dependency>
217224
<groupId>org.awaitility</groupId>
218225
<artifactId>awaitility</artifactId>

Diff for: providers/flagd/pom.xml

-94
Original file line numberDiff line numberDiff line change
@@ -287,100 +287,6 @@
287287
</arguments>
288288
</configuration>
289289
</execution>
290-
<execution>
291-
<id>copy-gherkin-evaluation.feature</id>
292-
<phase>validate</phase>
293-
<goals>
294-
<goal>exec</goal>
295-
</goals>
296-
<configuration>
297-
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
298-
<!-- run: cp test-harness/features/evaluation.feature src/test/resources/features/ -->
299-
<executable>cp</executable>
300-
<arguments>
301-
<argument>spec/specification/assets/gherkin/evaluation.feature</argument>
302-
<argument>src/test/resources/features/</argument>
303-
</arguments>
304-
</configuration>
305-
</execution>
306-
<execution>
307-
<id>copy-gherkin-flagd-json-evaluator.feature</id>
308-
<phase>validate</phase>
309-
<goals>
310-
<goal>exec</goal>
311-
</goals>
312-
<configuration>
313-
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
314-
<!-- run: cp test-harness/features/flagd-json-evaluator.feature src/test/resources/features/ -->
315-
<executable>cp</executable>
316-
<arguments>
317-
<argument>test-harness/gherkin/flagd-json-evaluator.feature</argument>
318-
<argument>src/test/resources/features/</argument>
319-
</arguments>
320-
</configuration>
321-
</execution>
322-
<execution>
323-
<id>copy-gherkin-flagd.feature</id>
324-
<phase>validate</phase>
325-
<goals>
326-
<goal>exec</goal>
327-
</goals>
328-
<configuration>
329-
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
330-
<!-- run: cp test-harness/features/flagd.feature src/test/resources/features/ -->
331-
<executable>cp</executable>
332-
<arguments>
333-
<argument>test-harness/gherkin/flagd.feature</argument>
334-
<argument>src/test/resources/features/</argument>
335-
</arguments>
336-
</configuration>
337-
</execution>
338-
<execution>
339-
<id>copy-gherkin-flagd-rpc-caching.feature</id>
340-
<phase>validate</phase>
341-
<goals>
342-
<goal>exec</goal>
343-
</goals>
344-
<configuration>
345-
<executable>cp</executable>
346-
<arguments>
347-
<argument>test-harness/gherkin/flagd-rpc-caching.feature</argument>
348-
<argument>src/test/resources/features/</argument>
349-
</arguments>
350-
</configuration>
351-
</execution>
352-
<execution>
353-
<id>copy-gherkin-config.feature</id>
354-
<phase>validate</phase>
355-
<goals>
356-
<goal>exec</goal>
357-
</goals>
358-
<configuration>
359-
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
360-
<!-- run: cp test-harness/features/flagd.feature src/test/resources/features/ -->
361-
<executable>cp</executable>
362-
<arguments>
363-
<argument>test-harness/gherkin/config.feature</argument>
364-
<argument>src/test/resources/features/</argument>
365-
</arguments>
366-
</configuration>
367-
</execution>
368-
<execution>
369-
<id>copy-gherkin-flagd-reconnect.feature</id>
370-
<phase>validate</phase>
371-
<goals>
372-
<goal>exec</goal>
373-
</goals>
374-
<configuration>
375-
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
376-
<!-- run: cp test-harness/features/flagd-reconnect.feature src/test/resources/features/ -->
377-
<executable>cp</executable>
378-
<arguments>
379-
<argument>test-harness/gherkin/flagd-reconnect.feature</argument>
380-
<argument>src/test/resources/features/</argument>
381-
</arguments>
382-
</configuration>
383-
</execution>
384290
</executions>
385291
</plugin>
386292
</plugins>

Diff for: providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/ContainerConfig.java

-97
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
package dev.openfeature.contrib.providers.flagd.e2e;
2+
3+
import dev.openfeature.contrib.providers.flagd.Config;
4+
import org.apache.logging.log4j.util.Strings;
5+
import org.jetbrains.annotations.NotNull;
6+
import org.testcontainers.containers.GenericContainer;
7+
import org.testcontainers.containers.Network;
8+
import org.testcontainers.containers.wait.strategy.Wait;
9+
import org.testcontainers.containers.wait.strategy.WaitStrategy;
10+
import org.testcontainers.utility.DockerImageName;
11+
import org.testcontainers.utility.MountableFile;
12+
13+
import java.io.File;
14+
import java.nio.file.Files;
15+
import java.util.List;
16+
17+
public class FlagdContainer extends GenericContainer<FlagdContainer> {
18+
private static final String version;
19+
private static final Network network = Network.newNetwork();
20+
21+
static {
22+
String path = "test-harness/version.txt";
23+
File file = new File(path);
24+
try {
25+
List<String> lines = Files.readAllLines(file.toPath());
26+
version = lines.get(0);
27+
} catch (Exception e) {
28+
throw new RuntimeException(e);
29+
}
30+
}
31+
32+
public FlagdContainer() {
33+
this("");
34+
}
35+
36+
public FlagdContainer(String feature) {
37+
super(generateContainerName(feature));
38+
this.addExposedPorts(8013, 8014, 8015, 8016);
39+
}
40+
41+
public int getPort(Config.Resolver resolver) {
42+
waitUntilContainerStarted();
43+
switch (resolver) {
44+
case RPC:
45+
return this.getMappedPort(8013);
46+
case IN_PROCESS:
47+
return this.getMappedPort(8015);
48+
default:
49+
throw new IllegalArgumentException("Unsupported resolver: " + resolver);
50+
}
51+
}
52+
53+
54+
/**
55+
* @return a {@link org.testcontainers.containers.GenericContainer} instance of envoy container using
56+
* flagd sync service as backend expose on port 9211
57+
*/
58+
public static GenericContainer envoy() {
59+
final String container = "envoyproxy/envoy:v1.31.0";
60+
return new GenericContainer(DockerImageName.parse(container))
61+
.withCopyFileToContainer(MountableFile.forClasspathResource("/envoy-config/envoy-custom.yaml"),
62+
"/etc/envoy/envoy.yaml")
63+
.withExposedPorts(9211)
64+
.withNetwork(network)
65+
.withNetworkAliases("envoy");
66+
}
67+
68+
public static @NotNull String generateContainerName(String feature) {
69+
String container = "ghcr.io/open-feature/flagd-testbed";
70+
if (!Strings.isBlank(feature)) {
71+
container += "-" + feature;
72+
}
73+
container += ":v" + version;
74+
return container;
75+
}
76+
}

Diff for: providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunConfigCucumberTest.java

-24
This file was deleted.

Diff for: providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java

-27
This file was deleted.

Diff for: providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessEnvoyCucumberTest.java

-27
This file was deleted.

Diff for: providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessReconnectCucumberTest.java

-25
This file was deleted.

0 commit comments

Comments
 (0)