-
Notifications
You must be signed in to change notification settings - Fork 15
test(php): cover OpenFeature in all weblog environments #7393
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
base: main
Are you sure you want to change the base?
Changes from all commits
ea806c0
b723d1a
c4c101f
0dad5d4
336e6f2
de9acac
121d7ce
54a205d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ | |
| import uuid | ||
| from http import HTTPStatus | ||
|
|
||
| from tests.ffe.utils.fixtures import make_ufc_fixture | ||
| from utils import ( | ||
| weblog, | ||
| interfaces, | ||
|
|
@@ -43,6 +44,44 @@ | |
| } | ||
|
|
||
|
|
||
| @scenarios.feature_flagging_and_experimentation | ||
| @features.feature_flags_dynamic_evaluation | ||
| class Test_FFE_OpenFeature_Evaluation: | ||
| """The weblog must use OpenFeature for evaluation by default.""" | ||
|
|
||
| def setup_openfeature_evaluation(self) -> None: | ||
| self.flag_key = "openfeature-evaluation" | ||
| config = make_ufc_fixture(self.flag_key, variation_type="BOOLEAN") | ||
| rc.tracer_rc_state.reset().set_config(f"{RC_PATH}/openfeature-evaluation/config", config).apply() | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
AGENTS.md reference: AGENTS.md:L33-L35 Useful? React with 👍 / 👎. |
||
|
|
||
| self.response = weblog.post( | ||
| "/ffe", | ||
| json={ | ||
| "flag": self.flag_key, | ||
| "variationType": "BOOLEAN", | ||
| "defaultValue": False, | ||
| "targetingKey": "customer-request", | ||
| "attributes": {}, | ||
| }, | ||
| ) | ||
|
|
||
| def test_openfeature_evaluation(self) -> None: | ||
| assert self.response.status_code == 200, f"Flag evaluation failed: {self.response.text}" | ||
| result = json.loads(self.response.text) | ||
|
|
||
| if result.get("errorCode") == "PROVIDER_NOT_READY": | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On PHP 8 weblogs, where this commit installs the OpenFeature SDK and activates the test, this branch lets the test pass when OpenFeature is completely broken or unwired. The PHP handler catches any Useful? React with 👍 / 👎. |
||
| assert result["value"] is False, f"Unavailable providers must return the supplied default: {result}" | ||
| assert result.get("reason") == "ERROR", f"Unavailable providers must return an error result: {result}" | ||
| assert result.get("errorMessage"), ( | ||
| f"Unavailable providers must explain why evaluation is unavailable: {result}" | ||
| ) | ||
| return | ||
|
|
||
| assert result["value"] is True, f"OpenFeature evaluation did not return the configured value: {result}" | ||
| assert result.get("reason") != "ERROR", f"OpenFeature evaluation returned an unexpected error: {result}" | ||
| assert result.get("errorCode") is None, f"OpenFeature evaluation returned an unexpected error code: {result}" | ||
|
|
||
|
|
||
| @scenarios.feature_flagging_and_experimentation | ||
| @features.feature_flags_dynamic_evaluation | ||
| class Test_FFE_Unknown_Operator_Tolerance: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,7 +10,7 @@ fi | |
|
|
||
| cd /var/www/html | ||
| export COMPOSER=composer.json | ||
| if [ "$(printf '%s\n' "$PHP_VERSION" "8.2" | sort -V | head -n1)" = "8.2" ]; then | ||
| if [ "$(printf '%s\n' "$PHP_VERSION" "8.2" | sort -V | head -n1)" = "8.2" ] && [ -f composer.gte8.2.json ]; then | ||
| export COMPOSER=composer.gte8.2.json | ||
| fi | ||
| if [ -f "$COMPOSER" ] && grep -Fq 'stripe/stripe-php' "$COMPOSER"; then | ||
|
|
@@ -26,6 +26,11 @@ if [ -f "$COMPOSER" ] && grep -Fq 'stripe/stripe-php' "$COMPOSER"; then | |
| fi | ||
| fi | ||
|
|
||
| if [[ "$(printf '%s\n' "$PHP_VERSION" "8.0" | sort -V | head -n1)" = "8.0" ]]; then | ||
| COMPOSER_DISCARD_CHANGES=true composer require "open-feature/sdk:^2.2" \ | ||
| --prefer-dist --no-interaction --ignore-platform-req=ext-mbstring | ||
|
Comment on lines
+29
to
+31
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This shared installer is also called by Useful? React with 👍 / 👎. |
||
| fi | ||
|
|
||
| cd /binaries | ||
|
|
||
| ARCH=$(uname -m) | ||
|
|
||
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.
php.ymlhad norefssection before this change, so this adds its first reusable anchor..cursor/rules/test-activation.mdcpermits new references only in manifests that already contain references and with explicit approval; expand this weblog list at the affected conditions rather than introducingrefs:here.AGENTS.md reference: AGENTS.md:L24-L24
Useful? React with 👍 / 👎.