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 Jan 13, 2025
1 parent 8fb4194 commit 0a3b414
Show file tree
Hide file tree
Showing 33 changed files with 648 additions and 1,333 deletions.
7 changes: 7 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
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);
}
}

private String feature;

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

public FlagdContainer(String feature) {
super(generateContainerName(feature));
this.withReuse(true);
this.feature = feature;
if (!"socket".equals(this.feature))
this.addExposedPorts(8013, 8014, 8015, 8016);
}

@Override
public void start() {
if (!"socket".equals(this.feature))
this.addExposedPorts(8013, 8014, 8015, 8016);
super.start();
waitUntilContainerStarted();
}

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.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 0a3b414

Please sign in to comment.