-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Simon Schrottner <[email protected]>
- Loading branch information
Showing
7 changed files
with
201 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,7 @@ target | |
.vscode/ | ||
|
||
# IntelliJ files | ||
*.iml | ||
*.iml | ||
|
||
# tmp files | ||
providers/flagd/tmp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessSocketCucumberTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package dev.openfeature.contrib.providers.flagd.e2e; | ||
|
||
import org.apache.logging.log4j.core.config.Order; | ||
import org.junit.jupiter.api.Disabled; | ||
import org.junit.jupiter.api.condition.EnabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
import org.junit.platform.suite.api.ConfigurationParameter; | ||
import org.junit.platform.suite.api.IncludeEngines; | ||
import org.junit.platform.suite.api.SelectFile; | ||
import org.junit.platform.suite.api.Suite; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; | ||
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME; | ||
|
||
@Order(value = Integer.MAX_VALUE) | ||
@Suite(failIfNoTests = false) | ||
@IncludeEngines("cucumber") | ||
// Not implemented in flagd | ||
//@SelectFile("spec/specification/assets/gherkin/evaluation.feature") | ||
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") | ||
@ConfigurationParameter( | ||
key = GLUE_PROPERTY_NAME, | ||
value = | ||
"dev.openfeature.contrib.providers.flagd.e2e.socket.process,dev.openfeature.contrib.providers.flagd.e2e.steps") | ||
@Testcontainers | ||
@EnabledOnOs(OS.LINUX) | ||
public class RunFlagdInProcessSocketCucumberTest {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
.../test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcSocketCucumberTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package dev.openfeature.contrib.providers.flagd.e2e; | ||
|
||
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; | ||
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME; | ||
|
||
import org.apache.logging.log4j.core.config.Order; | ||
import org.junit.jupiter.api.condition.EnabledOnOs; | ||
import org.junit.jupiter.api.condition.OS; | ||
import org.junit.platform.suite.api.ConfigurationParameter; | ||
import org.junit.platform.suite.api.IncludeEngines; | ||
import org.junit.platform.suite.api.SelectFile; | ||
import org.junit.platform.suite.api.Suite; | ||
import org.testcontainers.junit.jupiter.Testcontainers; | ||
|
||
@Order(value = Integer.MAX_VALUE) | ||
@Suite | ||
@IncludeEngines("cucumber") | ||
@SelectFile("spec/specification/assets/gherkin/evaluation.feature") | ||
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") | ||
@ConfigurationParameter( | ||
key = GLUE_PROPERTY_NAME, | ||
value = | ||
"dev.openfeature.contrib.providers.flagd.e2e.socket.rpc,dev.openfeature.contrib.providers.flagd.e2e.steps") | ||
@Testcontainers | ||
@EnabledOnOs(OS.LINUX) | ||
public class RunFlagdRpcSocketCucumberTest {} |
71 changes: 71 additions & 0 deletions
71
.../java/dev/openfeature/contrib/providers/flagd/e2e/socket/process/FlagdInProcessSetup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
package dev.openfeature.contrib.providers.flagd.e2e.socket.process; | ||
|
||
import dev.openfeature.contrib.providers.flagd.Config; | ||
import dev.openfeature.contrib.providers.flagd.FlagdOptions; | ||
import dev.openfeature.contrib.providers.flagd.FlagdProvider; | ||
import dev.openfeature.contrib.providers.flagd.e2e.ContainerConfig; | ||
import dev.openfeature.contrib.providers.flagd.e2e.steps.StepDefinitions; | ||
import dev.openfeature.sdk.FeatureProvider; | ||
import io.cucumber.java.AfterAll; | ||
import io.cucumber.java.Before; | ||
import io.cucumber.java.BeforeAll; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.attribute.FileAttribute; | ||
import java.nio.file.attribute.PosixFilePermission; | ||
import java.nio.file.attribute.PosixFilePermissions; | ||
import java.util.Set; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.parallel.Isolated; | ||
import org.testcontainers.containers.BindMode; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.shaded.org.apache.commons.io.FileUtils; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
|
||
@Isolated() | ||
@Order(value = Integer.MAX_VALUE) | ||
public class FlagdInProcessSetup { | ||
|
||
static Path sharedTempDir; | ||
|
||
static { | ||
try { | ||
sharedTempDir = Files.createDirectories( | ||
Paths.get("tmp/" + RandomStringUtils.randomAlphanumeric(8).toLowerCase() +"/")); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private static final GenericContainer flagdContainer = new GenericContainer( | ||
DockerImageName.parse(ContainerConfig.generateContainerName("flagd", "socket"))) | ||
.withFileSystemBind(sharedTempDir.toAbsolutePath().toString(), "/tmp", BindMode.READ_WRITE); | ||
|
||
@BeforeAll() | ||
public static void setups() throws InterruptedException, IOException { | ||
flagdContainer.start(); | ||
} | ||
|
||
@AfterAll() | ||
public static void cleanup() throws IOException { | ||
flagdContainer.stop(); | ||
FileUtils.deleteDirectory(sharedTempDir.toFile()); | ||
} | ||
|
||
@Before() | ||
public static void setupTest() throws InterruptedException { | ||
String string = sharedTempDir.resolve("socket.sock").toAbsolutePath().toString(); | ||
FeatureProvider workingProvider = new FlagdProvider(FlagdOptions.builder() | ||
.resolverType(Config.Resolver.IN_PROCESS) | ||
.deadline(10000) | ||
.streamDeadlineMs(0) // this makes reconnect tests more predictable | ||
.socketPath(string) | ||
.build()); | ||
StepDefinitions.setProvider(workingProvider); | ||
} | ||
} |
69 changes: 69 additions & 0 deletions
69
...d/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/socket/rpc/FlagdRpcSetup.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package dev.openfeature.contrib.providers.flagd.e2e.socket.rpc; | ||
|
||
import dev.openfeature.contrib.providers.flagd.Config; | ||
import dev.openfeature.contrib.providers.flagd.FlagdOptions; | ||
import dev.openfeature.contrib.providers.flagd.FlagdProvider; | ||
import dev.openfeature.contrib.providers.flagd.e2e.ContainerConfig; | ||
import dev.openfeature.contrib.providers.flagd.e2e.steps.StepDefinitions; | ||
import dev.openfeature.sdk.FeatureProvider; | ||
import io.cucumber.java.AfterAll; | ||
import io.cucumber.java.Before; | ||
import io.cucumber.java.BeforeAll; | ||
import java.io.File; | ||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.nio.file.attribute.FileAttribute; | ||
import java.nio.file.attribute.PosixFilePermission; | ||
import java.nio.file.attribute.PosixFilePermissions; | ||
import java.util.Set; | ||
import org.apache.commons.lang3.RandomStringUtils; | ||
import org.junit.jupiter.api.Order; | ||
import org.junit.jupiter.api.parallel.Isolated; | ||
import org.testcontainers.containers.BindMode; | ||
import org.testcontainers.containers.GenericContainer; | ||
import org.testcontainers.shaded.org.apache.commons.io.FileUtils; | ||
import org.testcontainers.utility.DockerImageName; | ||
|
||
@Isolated() | ||
@Order(value = Integer.MAX_VALUE) | ||
public class FlagdRpcSetup { | ||
|
||
static Path sharedTempDir; | ||
|
||
static { | ||
try { | ||
sharedTempDir = Files.createDirectories(Paths.get("tmp/" + RandomStringUtils.randomAlphanumeric(8).toLowerCase() +"/")); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
private static final GenericContainer flagdContainer = new GenericContainer( | ||
DockerImageName.parse(ContainerConfig.generateContainerName("flagd", "socket"))) | ||
.withFileSystemBind(sharedTempDir.toAbsolutePath().toString(), "/tmp", BindMode.READ_WRITE); | ||
|
||
@BeforeAll() | ||
public static void setups() throws InterruptedException, IOException { | ||
flagdContainer.start(); | ||
} | ||
|
||
@AfterAll() | ||
public static void cleanup() throws IOException { | ||
flagdContainer.stop(); | ||
FileUtils.deleteDirectory(sharedTempDir.toFile()); | ||
} | ||
|
||
@Before() | ||
public static void setupTest() throws InterruptedException { | ||
String string = sharedTempDir.resolve("socket.sock").toAbsolutePath().toString(); | ||
FeatureProvider workingProvider = new FlagdProvider(FlagdOptions.builder() | ||
.resolverType(Config.Resolver.RPC) | ||
.deadline(10000) | ||
.streamDeadlineMs(0) // this makes reconnect tests more predictable | ||
.socketPath(string) | ||
.build()); | ||
StepDefinitions.setProvider(workingProvider); | ||
} | ||
} |