-
Notifications
You must be signed in to change notification settings - Fork 13
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
25 changed files
with
744 additions
and
331 deletions.
There are no files selected for viewing
Submodule test-harness
updated
7 files
+2 −2 | .gherkin-lintrc | |
+7 −2 | gherkin/config.feature | |
+17 −17 | gherkin/events.feature | |
+101 −81 | gherkin/flagd-json-evaluator.feature | |
+13 −11 | gherkin/flagd-reconnect.feature | |
+54 −38 | gherkin/flagd-rpc-caching.feature | |
+21 −24 | gherkin/flagd.feature |
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
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
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
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
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
16 changes: 6 additions & 10 deletions
16
providers/openfeature-provider-flagd/tests/e2e/conftest.py
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 |
---|---|---|
@@ -1,17 +1,13 @@ | ||
import typing | ||
|
||
from tests.e2e.steps import * # noqa: F403 | ||
from tests.e2e.step.config_steps import * # noqa: F403 | ||
from tests.e2e.step.context_steps import * # noqa: F403 | ||
from tests.e2e.step.event_steps import * # noqa: F403 | ||
from tests.e2e.step.flag_step import * # noqa: F403 | ||
from tests.e2e.step.provider_steps import * # noqa: F403 | ||
from tests.e2e.steps import * # noqa: F403 # noqa: F403 | ||
|
||
JsonPrimitive = typing.Union[str, bool, float, int] | ||
|
||
TEST_HARNESS_PATH = "../../openfeature/test-harness" | ||
SPEC_PATH = "../../openfeature/spec" | ||
|
||
|
||
# running all gherkin tests, except the ones, not implemented | ||
def pytest_collection_modifyitems(config): | ||
marker = "not customCert and not unixsocket and not sync and not targetURI" | ||
|
||
# this seems to not work with python 3.8 | ||
if hasattr(config.option, "markexpr") and config.option.markexpr == "": | ||
config.option.markexpr = marker |
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
Empty file.
134 changes: 134 additions & 0 deletions
134
providers/openfeature-provider-flagd/tests/e2e/in-process-file/conftest.py
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,134 @@ | ||
import json | ||
import os | ||
import tempfile | ||
|
||
import pytest | ||
import yaml | ||
from pytest_bdd import given, parsers, when | ||
from tests.e2e.conftest import TEST_HARNESS_PATH | ||
from tests.e2e.step._utils import wait_for | ||
from tests.e2e.testFilter import TestFilter | ||
|
||
from openfeature import api | ||
from openfeature.client import OpenFeatureClient | ||
from openfeature.contrib.provider.flagd import FlagdProvider | ||
from openfeature.contrib.provider.flagd.config import ResolverType | ||
from openfeature.provider import ProviderStatus | ||
|
||
# from tests.e2e.step.config_steps import * | ||
# from tests.e2e.step.event_steps import * | ||
# from tests.e2e.step.provider_steps import * | ||
|
||
resolver = ResolverType.IN_PROCESS | ||
feature_list = { | ||
"~targetURI", | ||
"~customCert", | ||
"~unixsocket", | ||
"~events", | ||
"~sync", | ||
"~caching", | ||
"~reconnect", | ||
"~grace", | ||
} | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): | ||
test_filter = TestFilter( | ||
config, feature_list=feature_list, resolver=resolver.value, base_path=__file__ | ||
) | ||
test_filter.filter_items(items) | ||
|
||
|
||
KEY_EVALUATORS = "$evaluators" | ||
|
||
KEY_FLAGS = "flags" | ||
|
||
MERGED_FILE = "merged_file" | ||
|
||
|
||
@pytest.fixture() | ||
def resolver_type() -> ResolverType: | ||
return resolver | ||
|
||
|
||
@pytest.fixture(scope="module") | ||
def all_flags(request): | ||
result = {KEY_FLAGS: {}, KEY_EVALUATORS: {}} | ||
|
||
path = os.path.abspath( | ||
os.path.join(os.path.dirname(__file__), f"../{TEST_HARNESS_PATH}/flags/") | ||
) | ||
|
||
for f in os.listdir(path): | ||
with open(path + "/" + f, "rb") as infile: | ||
loaded_json = json.load(infile) | ||
result[KEY_FLAGS] = {**result[KEY_FLAGS], **loaded_json[KEY_FLAGS]} | ||
if loaded_json.get(KEY_EVALUATORS): | ||
result[KEY_EVALUATORS] = { | ||
**result[KEY_EVALUATORS], | ||
**loaded_json[KEY_EVALUATORS], | ||
} | ||
|
||
return result | ||
|
||
|
||
@pytest.fixture(params=["json", "yaml"], scope="module") | ||
def file_name(request, all_flags): | ||
extension = request.param | ||
outfile = tempfile.NamedTemporaryFile("w", delete=False, suffix="." + extension) | ||
write_test_file(outfile, all_flags) | ||
yield outfile | ||
return outfile | ||
|
||
|
||
def write_test_file(outfile, all_flags): | ||
with open(outfile.name, "w") as file: | ||
if file.name.endswith("json"): | ||
json.dump(all_flags, file) | ||
else: | ||
yaml.dump(all_flags, file) | ||
|
||
|
||
@when( | ||
parsers.cfparse('a flag with key "{flag_key}" is modified'), | ||
target_fixture="changed_flag", | ||
) | ||
def changed_flag( | ||
flag_key: str, | ||
all_flags: dict, | ||
file_name, | ||
): | ||
flag = all_flags[KEY_FLAGS][flag_key] | ||
|
||
other_variant = [k for k in flag["variants"] if flag["defaultVariant"] in k].pop() | ||
|
||
flag["defaultVariant"] = other_variant | ||
|
||
all_flags[KEY_FLAGS][flag_key] = flag | ||
write_test_file(file_name, all_flags) | ||
return flag_key | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def container(request, file_name, all_flags, option_values): | ||
api.set_provider( | ||
FlagdProvider( | ||
resolver_type=ResolverType.IN_PROCESS, | ||
deadline_ms=500, | ||
stream_deadline_ms=0, | ||
retry_backoff_ms=1000, | ||
offline_flag_source_path=file_name.name, | ||
**option_values, | ||
), | ||
) | ||
pass | ||
|
||
|
||
@given(parsers.cfparse("a {provider_type} flagd provider"), target_fixture="client") | ||
def setup_provider( | ||
resolver_type: ResolverType, provider_type: str, option_values: dict, file_name | ||
) -> OpenFeatureClient: | ||
client = api.get_client() | ||
|
||
wait_for(lambda: client.get_provider_status() == ProviderStatus.READY) | ||
return client |
5 changes: 5 additions & 0 deletions
5
providers/openfeature-provider-flagd/tests/e2e/in-process-file/test_flaqd.py
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,5 @@ | ||
from e2e.conftest import SPEC_PATH | ||
from pytest_bdd import scenarios | ||
from tests.e2e.conftest import TEST_HARNESS_PATH | ||
|
||
scenarios(f"{TEST_HARNESS_PATH}/gherkin", f"{SPEC_PATH}/specification/assets/gherkin") |
Empty file.
Oops, something went wrong.