From 4b7e7bf7717aed65ef3547b4f9ac1edcc73d6588 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Mon, 18 Sep 2023 15:26:28 -0400 Subject: [PATCH 1/4] chore: implement json-evaluator e2e Signed-off-by: Todd Baert --- providers/flagd/pom.xml | 18 ++- .../e2e/RunFlagdInProcessCucumberTest.java | 3 +- .../flagd/e2e/RunFlagdRpcCucumberTest.java | 2 +- .../providers/flagd/e2e/StepDefinitions.java | 138 +++++++++++++----- .../rpc/JsonEvaluationStepDefinitions.java | 41 ++++++ 5 files changed, 161 insertions(+), 41 deletions(-) create mode 100644 providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/JsonEvaluationStepDefinitions.java diff --git a/providers/flagd/pom.xml b/providers/flagd/pom.xml index 22ce297e9..e2e6e026b 100644 --- a/providers/flagd/pom.xml +++ b/providers/flagd/pom.xml @@ -290,7 +290,23 @@ src/test/resources/features/ - + + + copy-gherkin-flagd-json-evaluator.feature + validate + + exec + + + + + cp + + test-harness/gherkin/flagd-json-evaluator.feature + src/test/resources/features/ + + + diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java index fea0c47df..db30ef56b 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java @@ -10,7 +10,8 @@ @Suite @IncludeEngines("cucumber") -@SelectClasspathResource("features") +@SelectClasspathResource("features/evaluation.feature") +@SelectClasspathResource("features/flagd-json-evaluator.feature") @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.process,dev.openfeature.contrib.providers.flagd.e2e") public class RunFlagdInProcessCucumberTest { diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcCucumberTest.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcCucumberTest.java index e2a767933..8c95fd82e 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcCucumberTest.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcCucumberTest.java @@ -10,7 +10,7 @@ @Suite @IncludeEngines("cucumber") -@SelectClasspathResource("features") +@SelectClasspathResource("features/evaluation.feature") @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") @ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.rpc,dev.openfeature.contrib.providers.flagd.e2e") public class RunFlagdRpcCucumberTest { diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/StepDefinitions.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/StepDefinitions.java index 44c7265cd..4c4b8890c 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/StepDefinitions.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/StepDefinitions.java @@ -10,33 +10,37 @@ import dev.openfeature.sdk.EvaluationContext; import dev.openfeature.sdk.FlagEvaluationDetails; import dev.openfeature.sdk.ImmutableContext; +import dev.openfeature.sdk.ImmutableStructure; import dev.openfeature.sdk.Reason; import dev.openfeature.sdk.Structure; import dev.openfeature.sdk.Value; import io.cucumber.java.AfterAll; import io.cucumber.java.BeforeAll; +import io.cucumber.java.en.And; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; /** - * Common test suite used by both RPC and in-process flagd. + * Common test suite used by both RPC and in-process flagd providers. */ public class StepDefinitions { private static final ReentrantReadWriteLock sync = new ReentrantReadWriteLock(); private static Client client; - private boolean booleanFlagValue; - private String stringFlagValue; - private int intFlagValue; - private double doubleFlagValue; - private Value objectFlagValue; + private String booleanFlagKey; + private String stringFlagKey; + private String intFlagKey; + private String doubleFlagKey; + private String objectFlagKey; + + private boolean booleanFlagDefaultValue; + private String stringFlagDefaultValue; + private int intFlagDefaultValue; + private double doubleFlagDefaultValue; + private Value objectFlagDefaultValue; - private FlagEvaluationDetails booleanFlagDetails; - private FlagEvaluationDetails stringFlagDetails; - private FlagEvaluationDetails intFlagDetails; - private FlagEvaluationDetails doubleFlagDetails; private FlagEvaluationDetails objectFlagDetails; private String contextAwareFlagKey; @@ -51,9 +55,12 @@ public class StepDefinitions { private int typeErrorDefaultValue; private FlagEvaluationDetails typeErrorDetails; + private EvaluationContext customEvaluatorContext; + /** * Injects the client to use for this test. - * Tests run one at a time, but just in case, a lock is used to make sure the client is not updated mid-test. + * Tests run one at a time, but just in case, a lock is used to make sure the + * client is not updated mid-test. * * @param client client to inject into test. */ @@ -69,6 +76,7 @@ public static void cleanUp() { @BeforeAll() @Given("a provider is registered") + @Given("a flagd provider is set") public static void setup() { // this is handled by the "Setup" files } @@ -81,57 +89,67 @@ public static void setup() { @When("a boolean flag with key {string} is evaluated with default value {string}") public void a_boolean_flag_with_key_boolean_flag_is_evaluated_with_default_value_false(String flagKey, String defaultValue) { - this.booleanFlagValue = client.getBooleanValue(flagKey, Boolean.valueOf(defaultValue)); + this.booleanFlagKey = flagKey; + this.booleanFlagDefaultValue = Boolean.valueOf(defaultValue); } @Then("the resolved boolean value should be {string}") public void the_resolved_boolean_value_should_be_true(String expected) { - assertEquals(Boolean.valueOf(expected), this.booleanFlagValue); + boolean value = client.getBooleanValue(this.booleanFlagKey, Boolean.valueOf(this.booleanFlagDefaultValue)); + assertEquals(Boolean.valueOf(expected), value); } // string value @When("a string flag with key {string} is evaluated with default value {string}") public void a_string_flag_with_key_is_evaluated_with_default_value(String flagKey, String defaultValue) { - this.stringFlagValue = client.getStringValue(flagKey, defaultValue); + this.stringFlagKey = flagKey; + this.stringFlagDefaultValue = defaultValue; } @Then("the resolved string value should be {string}") public void the_resolved_string_value_should_be(String expected) { - assertEquals(expected, this.stringFlagValue); + String value = client.getStringValue(this.stringFlagKey, this.stringFlagDefaultValue); + assertEquals(expected, value); } // integer value @When("an integer flag with key {string} is evaluated with default value {int}") public void an_integer_flag_with_key_is_evaluated_with_default_value(String flagKey, Integer defaultValue) { - this.intFlagValue = client.getIntegerValue(flagKey, defaultValue); + this.intFlagKey = flagKey; + this.intFlagDefaultValue = defaultValue; } @Then("the resolved integer value should be {int}") public void the_resolved_integer_value_should_be(int expected) { - assertEquals(expected, this.intFlagValue); + int value = client.getIntegerValue(this.intFlagKey, this.intFlagDefaultValue); + assertEquals(expected, value); } // float/double value @When("a float flag with key {string} is evaluated with default value {double}") public void a_float_flag_with_key_is_evaluated_with_default_value(String flagKey, double defaultValue) { - this.doubleFlagValue = client.getDoubleValue(flagKey, defaultValue); + this.doubleFlagKey = flagKey; + this.doubleFlagDefaultValue = defaultValue; } @Then("the resolved float value should be {double}") public void the_resolved_float_value_should_be(double expected) { - assertEquals(expected, this.doubleFlagValue); + double value = client.getDoubleValue(this.doubleFlagKey, this.doubleFlagDefaultValue); + assertEquals(expected, value); } // object value @When("an object flag with key {string} is evaluated with a null default value") public void an_object_flag_with_key_is_evaluated_with_a_null_default_value(String flagKey) { - this.objectFlagValue = client.getObjectValue(flagKey, new Value()); + this.objectFlagKey = flagKey; + this.objectFlagDefaultValue = new Value(); // empty value is equivalent to null } @Then("the resolved object value should be contain fields {string}, {string}, and {string}, with values {string}, {string} and {int}, respectively") public void the_resolved_object_value_should_be_contain_fields_and_with_values_and_respectively(String boolField, String stringField, String numberField, String boolValue, String stringValue, int numberValue) { - Structure structure = this.objectFlagValue.asStructure(); + Value value = client.getObjectValue(this.objectFlagKey, this.objectFlagDefaultValue); + Structure structure = value.asStructure(); assertEquals(Boolean.valueOf(boolValue), structure.asMap().get(boolField).asBoolean()); assertEquals(stringValue, structure.asMap().get(stringField).asString()); @@ -146,71 +164,88 @@ public void the_resolved_object_value_should_be_contain_fields_and_with_values_a @When("a boolean flag with key {string} is evaluated with details and default value {string}") public void a_boolean_flag_with_key_is_evaluated_with_details_and_default_value(String flagKey, String defaultValue) { - this.booleanFlagDetails = client.getBooleanDetails(flagKey, Boolean.valueOf(defaultValue)); + this.booleanFlagKey = flagKey; + this.booleanFlagDefaultValue = Boolean.valueOf(defaultValue); } @Then("the resolved boolean details value should be {string}, the variant should be {string}, and the reason should be {string}") public void the_resolved_boolean_value_should_be_the_variant_should_be_and_the_reason_should_be( String expectedValue, String expectedVariant, String expectedReason) { - assertEquals(Boolean.valueOf(expectedValue), booleanFlagDetails.getValue()); - assertEquals(expectedVariant, booleanFlagDetails.getVariant()); - assertEquals(expectedReason, booleanFlagDetails.getReason()); + FlagEvaluationDetails details = client.getBooleanDetails(this.booleanFlagKey, + Boolean.valueOf(this.booleanFlagDefaultValue)); + + assertEquals(Boolean.valueOf(expectedValue), details.getValue()); + assertEquals(expectedVariant, details.getVariant()); + assertEquals(expectedReason, details.getReason()); } // string details @When("a string flag with key {string} is evaluated with details and default value {string}") public void a_string_flag_with_key_is_evaluated_with_details_and_default_value(String flagKey, String defaultValue) { - this.stringFlagDetails = client.getStringDetails(flagKey, defaultValue); + this.stringFlagKey = flagKey; + this.stringFlagDefaultValue = defaultValue; } @Then("the resolved string details value should be {string}, the variant should be {string}, and the reason should be {string}") public void the_resolved_string_value_should_be_the_variant_should_be_and_the_reason_should_be(String expectedValue, String expectedVariant, String expectedReason) { - assertEquals(expectedValue, this.stringFlagDetails.getValue()); - assertEquals(expectedVariant, this.stringFlagDetails.getVariant()); - assertEquals(expectedReason, this.stringFlagDetails.getReason()); + FlagEvaluationDetails details = client.getStringDetails(this.stringFlagKey, + this.stringFlagDefaultValue); + + assertEquals(expectedValue, details.getValue()); + assertEquals(expectedVariant, details.getVariant()); + assertEquals(expectedReason, details.getReason()); } // integer details @When("an integer flag with key {string} is evaluated with details and default value {int}") public void an_integer_flag_with_key_is_evaluated_with_details_and_default_value(String flagKey, int defaultValue) { - this.intFlagDetails = client.getIntegerDetails(flagKey, defaultValue); + this.intFlagKey = flagKey; + this.intFlagDefaultValue = defaultValue; } @Then("the resolved integer details value should be {int}, the variant should be {string}, and the reason should be {string}") public void the_resolved_integer_value_should_be_the_variant_should_be_and_the_reason_should_be(int expectedValue, String expectedVariant, String expectedReason) { - assertEquals(expectedValue, this.intFlagDetails.getValue()); - assertEquals(expectedVariant, this.intFlagDetails.getVariant()); - assertEquals(expectedReason, this.intFlagDetails.getReason()); + FlagEvaluationDetails details = client.getIntegerDetails(this.intFlagKey, this.intFlagDefaultValue); + + assertEquals(expectedValue, details.getValue()); + assertEquals(expectedVariant, details.getVariant()); + assertEquals(expectedReason, details.getReason()); } // float/double details @When("a float flag with key {string} is evaluated with details and default value {double}") public void a_float_flag_with_key_is_evaluated_with_details_and_default_value(String flagKey, double defaultValue) { - this.doubleFlagDetails = client.getDoubleDetails(flagKey, defaultValue); + this.doubleFlagKey = flagKey; + this.doubleFlagDefaultValue = defaultValue; } @Then("the resolved float details value should be {double}, the variant should be {string}, and the reason should be {string}") public void the_resolved_float_value_should_be_the_variant_should_be_and_the_reason_should_be(double expectedValue, String expectedVariant, String expectedReason) { - assertEquals(expectedValue, this.doubleFlagDetails.getValue()); - assertEquals(expectedVariant, this.doubleFlagDetails.getVariant()); - assertEquals(expectedReason, this.doubleFlagDetails.getReason()); + FlagEvaluationDetails details = client.getDoubleDetails(this.doubleFlagKey, + this.doubleFlagDefaultValue); + + assertEquals(expectedValue, details.getValue()); + assertEquals(expectedVariant, details.getVariant()); + assertEquals(expectedReason, details.getReason()); } // object details @When("an object flag with key {string} is evaluated with details and a null default value") public void an_object_flag_with_key_is_evaluated_with_details_and_a_null_default_value(String flagKey) { - this.objectFlagDetails = client.getObjectDetails(flagKey, new Value()); + this.objectFlagKey = flagKey; + this.objectFlagDefaultValue = new Value(); } @Then("the resolved object details value should be contain fields {string}, {string}, and {string}, with values {string}, {string} and {int}, respectively") public void the_resolved_object_value_should_be_contain_fields_and_with_values_and_respectively_again( String boolField, String stringField, String numberField, String boolValue, String stringValue, int numberValue) { + this.objectFlagDetails = client.getObjectDetails(this.objectFlagKey, this.objectFlagDefaultValue); Structure structure = this.objectFlagDetails.getValue().asStructure(); assertEquals(Boolean.valueOf(boolValue), structure.asMap().get(boolField).asBoolean()); @@ -303,4 +338,31 @@ public void the_reason_should_indicate_an_error_and_the_error_code_should_be_typ assertEquals(errorCode, typeErrorDetails.getErrorCode().toString()); } + /* + * Custom JSON evaluators (only run for flagd-in-process) + */ + + @And("a context containing a nested property with outer key {string} and inner key {string}, with value {string}") + public void a_context_containing_a_nested_property_with_outer_key_and_inner_key_with_value(String outerKey, + String innerKey, String value) throws InstantiationException { + Map innerMap = new HashMap(); + innerMap.put(innerKey, new Value(value)); + Map outerMap = new HashMap(); + outerMap.put(outerKey, new Value(new ImmutableStructure(innerMap))); + this.customEvaluatorContext = new ImmutableContext(outerMap); + } + + @And("a context containing a key {string}, with value {string}") + public void a_context_containing_a_key_with_value(String key, String value) { + Map attrs = new HashMap(); + attrs.put(key, new Value(value)); + this.customEvaluatorContext = new ImmutableContext(attrs); + } + + @Then("the returned value should be {string}") + public void the_returned_value_should_be(String expected) { + String value = client.getStringValue(this.stringFlagKey, this.stringFlagDefaultValue, this.customEvaluatorContext); + assertEquals(expected, value); + } + } \ No newline at end of file diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/JsonEvaluationStepDefinitions.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/JsonEvaluationStepDefinitions.java new file mode 100644 index 000000000..b4b040fa0 --- /dev/null +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/JsonEvaluationStepDefinitions.java @@ -0,0 +1,41 @@ +// package dev.openfeature.contrib.providers.flagd.e2e.rpc; + +// import dev.openfeature.sdk.Client; +// import dev.openfeature.sdk.OpenFeatureAPI; +// import io.cucumber.java.en.And; +// import io.cucumber.java.en.Given; +// import io.cucumber.java.en.Then; +// import io.cucumber.java.en.When; + +// /** +// * Test suite used by in-process flagd provider. +// * The RPC provider doesn't implement evaluator itself, flagd does. +// */ +// public class JsonEvaluationStepDefinitions { + +// private Client client; + +// @Given("a flagd provider is set") +// public void a_flagd_provider_is_set() { +// client = OpenFeatureAPI.getInstance().getClient("process"); +// } + +// @And("a context containing a nested property with outer key {string} and inner key {string}, with value {string}") +// public void a_context_containing_a_nested_property_with_outer_key_and_inner_key_with_value(String outerKey, +// String innerKey, String value) { +// // Write code here that turns the phrase above into concrete actions +// // throw new io.cucumber.java.PendingException(); +// } + +// @And("a context containing a key {string}, with value {string}") +// public void a_context_containing_a_key_with_value(String string, String string2) { +// // Write code here that turns the phrase above into concrete actions +// // throw new io.cucumber.java.PendingException(); +// } + +// @Then("the returned value should be {string}") +// public void the_returned_value_should_be(String string) { +// // Write code here that turns the phrase above into concrete actions +// // throw new io.cucumber.java.PendingException(); +// } +// } From 96e85500e6f9806d9b1cfd3db19df1da0d01b7fd Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Mon, 18 Sep 2023 19:56:29 -0400 Subject: [PATCH 2/4] fixup: test discovery Signed-off-by: Todd Baert --- .../flagd/e2e/RunFlagdInProcessCucumberTest.java | 2 +- .../providers/flagd/e2e/RunFlagdRpcCucumberTest.java | 3 ++- .../flagd/e2e/process/FlagdInProcessSetup.java | 2 +- .../contrib/providers/flagd/e2e/rpc/FlagdRpcSetup.java | 2 +- .../flagd/e2e/{ => steps}/StepDefinitions.java | 10 +--------- 5 files changed, 6 insertions(+), 13 deletions(-) rename providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/{ => steps}/StepDefinitions.java (98%) diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java index db30ef56b..1afbb571b 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdInProcessCucumberTest.java @@ -13,7 +13,7 @@ @SelectClasspathResource("features/evaluation.feature") @SelectClasspathResource("features/flagd-json-evaluator.feature") @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") -@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.process,dev.openfeature.contrib.providers.flagd.e2e") +@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.process,dev.openfeature.contrib.providers.flagd.e2e.steps") public class RunFlagdInProcessCucumberTest { } diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcCucumberTest.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcCucumberTest.java index 8c95fd82e..d334bd05b 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcCucumberTest.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/RunFlagdRpcCucumberTest.java @@ -11,8 +11,9 @@ @Suite @IncludeEngines("cucumber") @SelectClasspathResource("features/evaluation.feature") +@SelectClasspathResource("features/flagd-json-evaluator.feature") @ConfigurationParameter(key = PLUGIN_PROPERTY_NAME, value = "pretty") -@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.rpc,dev.openfeature.contrib.providers.flagd.e2e") +@ConfigurationParameter(key = GLUE_PROPERTY_NAME, value = "dev.openfeature.contrib.providers.flagd.e2e.rpc,dev.openfeature.contrib.providers.flagd.e2e.steps") public class RunFlagdRpcCucumberTest { } diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/process/FlagdInProcessSetup.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/process/FlagdInProcessSetup.java index e4cf8ab76..06e3198d3 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/process/FlagdInProcessSetup.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/process/FlagdInProcessSetup.java @@ -3,7 +3,7 @@ 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.StepDefinitions; +import dev.openfeature.contrib.providers.flagd.e2e.steps.StepDefinitions; import dev.openfeature.sdk.Client; import dev.openfeature.sdk.OpenFeatureAPI; import io.cucumber.java.BeforeAll; diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/FlagdRpcSetup.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/FlagdRpcSetup.java index 0b86d6ba8..b384fa2d0 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/FlagdRpcSetup.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/FlagdRpcSetup.java @@ -3,7 +3,7 @@ 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.StepDefinitions; +import dev.openfeature.contrib.providers.flagd.e2e.steps.StepDefinitions; import dev.openfeature.sdk.Client; import dev.openfeature.sdk.OpenFeatureAPI; import io.cucumber.java.BeforeAll; diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/StepDefinitions.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/StepDefinitions.java similarity index 98% rename from providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/StepDefinitions.java rename to providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/StepDefinitions.java index 4c4b8890c..482a3f77f 100644 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/StepDefinitions.java +++ b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/steps/StepDefinitions.java @@ -1,4 +1,4 @@ -package dev.openfeature.contrib.providers.flagd.e2e; +package dev.openfeature.contrib.providers.flagd.e2e.steps; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -14,7 +14,6 @@ import dev.openfeature.sdk.Reason; import dev.openfeature.sdk.Structure; import dev.openfeature.sdk.Value; -import io.cucumber.java.AfterAll; import io.cucumber.java.BeforeAll; import io.cucumber.java.en.And; import io.cucumber.java.en.Given; @@ -66,12 +65,6 @@ public class StepDefinitions { */ public static void setClient(Client client) { StepDefinitions.client = client; - sync.writeLock().lock(); - } - - @AfterAll() - public static void cleanUp() { - sync.writeLock().unlock(); } @BeforeAll() @@ -364,5 +357,4 @@ public void the_returned_value_should_be(String expected) { String value = client.getStringValue(this.stringFlagKey, this.stringFlagDefaultValue, this.customEvaluatorContext); assertEquals(expected, value); } - } \ No newline at end of file From 4d6e86af9714da6b74ec1d23def53c9fb5572463 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Mon, 18 Sep 2023 23:41:44 -0400 Subject: [PATCH 3/4] fixup: update ci service imgs Signed-off-by: Todd Baert --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e5bff7cc7..6b0a6c329 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,12 +14,12 @@ jobs: services: # flagd-testbed for flagd-provider e2e tests flagd: - image: ghcr.io/open-feature/flagd-testbed:v0.4.0 + image: ghcr.io/open-feature/flagd-testbed:v0.4.2 ports: - 8013:8013 # sync-testbed for flagd-provider e2e tests sync: - image: ghcr.io/open-feature/sync-testbed:v0.4.0 + image: ghcr.io/open-feature/sync-testbed:v0.4.2 ports: - 9090:9090 From d1a779db17158233809853dd6bac3a9b5b586333 Mon Sep 17 00:00:00 2001 From: Todd Baert Date: Mon, 18 Sep 2023 23:48:15 -0400 Subject: [PATCH 4/4] fixup: remove json steps Signed-off-by: Todd Baert --- .../rpc/JsonEvaluationStepDefinitions.java | 41 ------------------- 1 file changed, 41 deletions(-) delete mode 100644 providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/JsonEvaluationStepDefinitions.java diff --git a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/JsonEvaluationStepDefinitions.java b/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/JsonEvaluationStepDefinitions.java deleted file mode 100644 index b4b040fa0..000000000 --- a/providers/flagd/src/test/java/dev/openfeature/contrib/providers/flagd/e2e/rpc/JsonEvaluationStepDefinitions.java +++ /dev/null @@ -1,41 +0,0 @@ -// package dev.openfeature.contrib.providers.flagd.e2e.rpc; - -// import dev.openfeature.sdk.Client; -// import dev.openfeature.sdk.OpenFeatureAPI; -// import io.cucumber.java.en.And; -// import io.cucumber.java.en.Given; -// import io.cucumber.java.en.Then; -// import io.cucumber.java.en.When; - -// /** -// * Test suite used by in-process flagd provider. -// * The RPC provider doesn't implement evaluator itself, flagd does. -// */ -// public class JsonEvaluationStepDefinitions { - -// private Client client; - -// @Given("a flagd provider is set") -// public void a_flagd_provider_is_set() { -// client = OpenFeatureAPI.getInstance().getClient("process"); -// } - -// @And("a context containing a nested property with outer key {string} and inner key {string}, with value {string}") -// public void a_context_containing_a_nested_property_with_outer_key_and_inner_key_with_value(String outerKey, -// String innerKey, String value) { -// // Write code here that turns the phrase above into concrete actions -// // throw new io.cucumber.java.PendingException(); -// } - -// @And("a context containing a key {string}, with value {string}") -// public void a_context_containing_a_key_with_value(String string, String string2) { -// // Write code here that turns the phrase above into concrete actions -// // throw new io.cucumber.java.PendingException(); -// } - -// @Then("the returned value should be {string}") -// public void the_returned_value_should_be(String string) { -// // Write code here that turns the phrase above into concrete actions -// // throw new io.cucumber.java.PendingException(); -// } -// }