Skip to content

Commit

Permalink
test(flagd): rework e2e tests to new format
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Schrottner <[email protected]>
  • Loading branch information
aepfli committed Dec 28, 2024
1 parent 819abe3 commit d2b3cd4
Show file tree
Hide file tree
Showing 36 changed files with 557 additions and 1,446 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>7.20.1</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
Expand Down
94 changes: 0 additions & 94 deletions providers/flagd/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -287,100 +287,6 @@
</arguments>
</configuration>
</execution>
<execution>
<id>copy-gherkin-evaluation.feature</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
<!-- run: cp test-harness/features/evaluation.feature src/test/resources/features/ -->
<executable>cp</executable>
<arguments>
<argument>spec/specification/assets/gherkin/evaluation.feature</argument>
<argument>src/test/resources/features/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>copy-gherkin-flagd-json-evaluator.feature</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
<!-- run: cp test-harness/features/flagd-json-evaluator.feature src/test/resources/features/ -->
<executable>cp</executable>
<arguments>
<argument>test-harness/gherkin/flagd-json-evaluator.feature</argument>
<argument>src/test/resources/features/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>copy-gherkin-flagd.feature</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
<!-- run: cp test-harness/features/flagd.feature src/test/resources/features/ -->
<executable>cp</executable>
<arguments>
<argument>test-harness/gherkin/flagd.feature</argument>
<argument>src/test/resources/features/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>copy-gherkin-flagd-rpc-caching.feature</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<executable>cp</executable>
<arguments>
<argument>test-harness/gherkin/flagd-rpc-caching.feature</argument>
<argument>src/test/resources/features/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>copy-gherkin-config.feature</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
<!-- run: cp test-harness/features/flagd.feature src/test/resources/features/ -->
<executable>cp</executable>
<arguments>
<argument>test-harness/gherkin/config.feature</argument>
<argument>src/test/resources/features/</argument>
</arguments>
</configuration>
</execution>
<execution>
<id>copy-gherkin-flagd-reconnect.feature</id>
<phase>validate</phase>
<goals>
<goal>exec</goal>
</goals>
<configuration>
<!-- copy the feature spec we want to test into resources so them can be easily loaded -->
<!-- run: cp test-harness/features/flagd-reconnect.feature src/test/resources/features/ -->
<executable>cp</executable>
<arguments>
<argument>test-harness/gherkin/flagd-reconnect.feature</argument>
<argument>src/test/resources/features/</argument>
</arguments>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
package dev.openfeature.contrib.providers.flagd.e2e;

import dev.openfeature.contrib.providers.flagd.Config;
import org.apache.logging.log4j.util.Strings;
import org.jetbrains.annotations.NotNull;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.containers.wait.strategy.WaitStrategy;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;

import java.io.File;
import java.nio.file.Files;
import java.util.List;

public class FlagdContainer extends GenericContainer<FlagdContainer> {
private static final String version;
private static final Network network = Network.newNetwork();

static {
String path = "test-harness/version.txt";
File file = new File(path);
try {
List<String> lines = Files.readAllLines(file.toPath());
version = lines.get(0);
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public FlagdContainer() {
this("");
}

public FlagdContainer(String feature) {
super(generateContainerName(feature));
this.addExposedPorts(8013, 8014, 8015, 8016);
}

public int getPort(Config.Resolver resolver) {
waitUntilContainerStarted();
switch (resolver) {
case RPC:
return this.getMappedPort(8013);
case IN_PROCESS:
return this.getMappedPort(8015);
default:
throw new IllegalArgumentException("Unsupported resolver: " + resolver);
}
}


/**
* @return a {@link org.testcontainers.containers.GenericContainer} instance of envoy container using
* flagd sync service as backend expose on port 9211
*/
public static GenericContainer envoy() {
final String container = "envoyproxy/envoy:v1.31.0";
return new GenericContainer(DockerImageName.parse(container))
.withCopyFileToContainer(MountableFile.forClasspathResource("/envoy-config/envoy-custom.yaml"),
"/etc/envoy/envoy.yaml")
.withExposedPorts(9211)
.withNetwork(network)
.withNetworkAliases("envoy");
}

public static @NotNull String generateContainerName(String feature) {
String container = "ghcr.io/open-feature/flagd-testbed";
if (!Strings.isBlank(feature)) {
container += "-" + feature;
}
container += ":v" + version;
return container;
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit d2b3cd4

Please sign in to comment.