Skip to content

Commit a8d8f7c

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

36 files changed

+547
-1450
lines changed

pom.xml

Lines changed: 7 additions & 0 deletions
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>

providers/flagd/pom.xml

Lines changed: 4 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -253,23 +253,23 @@
253253
<artifactId>exec-maven-plugin</artifactId>
254254
<version>3.5.0</version>
255255
<executions>
256-
<execution>
256+
<!--<execution>
257257
<id>update-test-harness-submodule</id>
258258
<phase>validate</phase>
259259
<goals>
260260
<goal>exec</goal>
261261
</goals>
262262
<configuration>
263-
<!-- run: git submodule update \-\-init test-harness -->
263+
&lt;!&ndash; run: git submodule update \-\-init test-harness &ndash;&gt;
264264
<executable>git</executable>
265265
<arguments>
266266
<argument>submodule</argument>
267267
<argument>update</argument>
268-
<argument>--init</argument>
268+
<argument>&#45;&#45;init</argument>
269269
<argument>test-harness</argument>
270270
</arguments>
271271
</configuration>
272-
</execution>
272+
</execution>-->
273273
<execution>
274274
<id>update-spec-submodule</id>
275275
<phase>validate</phase>
@@ -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>

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

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

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

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

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

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

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

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

0 commit comments

Comments
 (0)