-
Notifications
You must be signed in to change notification settings - Fork 51
feat(flagd): Improve e2e coverage #1092
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
Merged
aepfli
merged 8 commits into
open-feature:main
from
open-feature-forking:feat/use_more_gherkin_files
Dec 18, 2024
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
c0e2e79
feat(flagd): Improve e2e coverage
aepfli ac411ae
Merge branch 'main' into feat/use_more_gherkin_files
aepfli 4c9010f
feat(flagd): Improve e2e coverage
aepfli 5c684aa
Merge branch 'main' into feat/use_more_gherkin_files
aepfli ac044fd
feat(flagd): Improve e2e coverage
aepfli 5d6f145
Merge branch 'main' into feat/use_more_gherkin_files
toddbaert d619327
fixup: remove comments
aepfli 38ef96d
Merge branch 'main' into feat/use_more_gherkin_files
aepfli 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 hidden or 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
24 changes: 24 additions & 0 deletions
24
...lagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunConfigCucumberTest.java
This file contains hidden or 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,24 @@ | ||
package dev.openfeature.contrib.providers.flagd.e2e; | ||
|
||
import org.junit.jupiter.api.Order; | ||
import org.junit.platform.suite.api.ConfigurationParameter; | ||
import org.junit.platform.suite.api.IncludeEngines; | ||
import org.junit.platform.suite.api.SelectClasspathResource; | ||
import org.junit.platform.suite.api.Suite; | ||
|
||
import static io.cucumber.junit.platform.engine.Constants.GLUE_PROPERTY_NAME; | ||
import static io.cucumber.junit.platform.engine.Constants.PLUGIN_PROPERTY_NAME; | ||
|
||
/** | ||
* Class for running the tests associated with "stable" e2e tests (no fake disconnection) for the in-process provider | ||
*/ | ||
@Order(value = Integer.MAX_VALUE) | ||
@Suite | ||
@IncludeEngines("cucumber") | ||
@SelectClasspathResource("features/config.feature") | ||
@ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") | ||
@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.steps.config") | ||
public class RunConfigCucumberTest { | ||
|
||
|
||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
18 changes: 10 additions & 8 deletions
18
...rc/test/java/dev/openfeature/contrib/providers/flagd/e2e/reconnect/rpc/FlagdRpcSetup.java
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
103 changes: 103 additions & 0 deletions
103
...d/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/config/ConfigSteps.java
This file contains hidden or 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,103 @@ | ||
package dev.openfeature.contrib.providers.flagd.e2e.steps.config; | ||
|
||
import dev.openfeature.contrib.providers.flagd.Config; | ||
import dev.openfeature.contrib.providers.flagd.FlagdOptions; | ||
import dev.openfeature.contrib.providers.flagd.resolver.grpc.cache.CacheType; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.Arrays; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class ConfigSteps { | ||
|
||
FlagdOptions.FlagdOptionsBuilder builder = FlagdOptions.builder(); | ||
FlagdOptions options; | ||
|
||
@When("we initialize a config") | ||
aepfli marked this conversation as resolved.
Show resolved
Hide resolved
|
||
public void we_initialize_a_config() { | ||
options = builder.build(); | ||
} | ||
|
||
@When("we initialize a config for {string}") | ||
public void we_initialize_a_config_for(String string) { | ||
switch (string.toLowerCase()) { | ||
case "in-process": | ||
options = builder.resolverType(Config.Resolver.IN_PROCESS).build(); | ||
break; | ||
case "rpc": | ||
options = builder.resolverType(Config.Resolver.RPC).build(); | ||
break; | ||
default: | ||
throw new RuntimeException("Unknown resolver type: " + string); | ||
} | ||
} | ||
|
||
@When("we have an option {string} of type {string} with value {string}") | ||
public void we_have_an_option_of_type_with_value(String option, String type, String value) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { | ||
Object converted = convert(value, type); | ||
Method method = Arrays.stream(builder.getClass().getMethods()) | ||
.filter(method1 -> method1.getName().equals(option)) | ||
.findFirst() | ||
.orElseThrow(RuntimeException::new); | ||
method.invoke(builder, converted); | ||
} | ||
|
||
|
||
Map<String, String> envVarsSet = new HashMap<>(); | ||
|
||
@When("we have an environment variable {string} with value {string}") | ||
public void we_have_an_environment_variable_with_value(String varName, String value) throws IllegalAccessException, NoSuchFieldException { | ||
String getenv = System.getenv(varName); | ||
envVarsSet.put(varName, getenv); | ||
EnvironmentVariableUtils.set(varName, value); | ||
} | ||
|
||
private Object convert(String value, String type) throws ClassNotFoundException { | ||
if (Objects.equals(value, "null")) return null; | ||
switch (type) { | ||
case "Boolean": | ||
return Boolean.parseBoolean(value); | ||
case "String": | ||
return value; | ||
case "Integer": | ||
return Integer.parseInt(value); | ||
case "Long": | ||
return Long.parseLong(value); | ||
case "ResolverType": | ||
switch (value.toLowerCase()) { | ||
case "in-process": | ||
return Config.Resolver.IN_PROCESS; | ||
case "rpc": | ||
return Config.Resolver.RPC; | ||
default: | ||
throw new RuntimeException("Unknown resolver type: " + value); | ||
} | ||
case "CacheType": | ||
return CacheType.valueOf(value.toUpperCase()).getValue(); | ||
} | ||
throw new RuntimeException("Unknown config type: " + type); | ||
} | ||
|
||
@Then("the option {string} of type {string} should have the value {string}") | ||
public void the_option_of_type_should_have_the_value(String option, String type, String value) throws Throwable { | ||
Object convert = convert(value, type); | ||
|
||
assertThat(options).hasFieldOrPropertyWithValue(option, convert); | ||
|
||
// Resetting env vars | ||
for (Map.Entry<String, String> envVar : envVarsSet.entrySet()) { | ||
if (envVar.getValue() == null) { | ||
EnvironmentVariableUtils.clear(envVar.getKey()); | ||
} else { | ||
EnvironmentVariableUtils.set(envVar.getKey(), envVar.getValue()); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.