-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test(flagd): add socket path tests #1153
Closed
aepfli
wants to merge
3
commits into
open-feature:main
from
open-feature-forking:test/add_socket_test
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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); | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
again, this does not work for in_process connection