Skip to content

LCORE-1221: fix before all hook not to fail on prow#1428

Merged
radofuchs merged 1 commit into
lightspeed-core:mainfrom
radofuchs:e2e_before_all_fix
Mar 29, 2026
Merged

LCORE-1221: fix before all hook not to fail on prow#1428
radofuchs merged 1 commit into
lightspeed-core:mainfrom
radofuchs:e2e_before_all_fix

Conversation

@radofuchs

@radofuchs radofuchs commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Description

Type of change

  • Refactor
  • New feature
  • Bug fix
  • CVE fix
  • Optimization
  • Documentation Update
  • Configuration Update
  • Bump-up service version
  • Bump-up dependent library
  • Bump-up library or tool used for development (does not change the final image)
  • CI configuration change
  • Konflux configuration change
  • Unit tests improvement
  • Integration tests improvement
  • End to end tests improvement
  • Benchmarks improvement

Tools used to create PR

Identify any AI code assistants used in this PR (for transparency and review context)

  • Assisted-by: (e.g., Claude, CodeRabbit, Ollama, etc., N/A if not used)
  • Generated by: (e.g., tool name and version; N/A if not used)

Related Tickets & Documents

  • Related Issue #
  • Closes #

Checklist before requesting a review

  • I have performed a self-review of my code.
  • PR has passed all pre-merge test jobs.
  • If it is a core feature, I have added thorough tests.

Testing

  • Please provide detailed steps to perform tests related to this code change.
  • How were the fix/results from this change verified? Please provide relevant screenshots or results.

Summary by CodeRabbit

  • Tests
    • Enhanced environment detection for Prow CI/CD pipeline testing.

@coderabbitai

coderabbitai Bot commented Mar 29, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

The _is_docker_mode() function in the proxy test step handler was updated to check if the test is running in a Prow environment and immediately return False when detected, before proceeding with existing Docker mode detection logic.

Changes

Cohort / File(s) Summary
Prow Environment Detection
tests/e2e/features/steps/proxy.py
Added import of is_prow_environment utility and modified _is_docker_mode() to return False when running in Prow environment, bypassing standard Docker container detection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and specifically describes the main change: fixing the before-all hook to not fail on Prow environment.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
✨ Simplify code
  • Create PR with simplified code

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@tests/e2e/features/steps/proxy.py`:
- Around line 39-40: The is_prow_environment() check is treating any defined
RUNNING_PROW value (including empty string) as truthy and can incorrectly force
context.is_docker_mode False; update is_prow_environment() to return a strict
boolean by reading the env var (e.g., os.getenv("RUNNING_PROW") in utils and
compare to a specific expected value like "1" or "true") and change the proxy
step to rely on that strict boolean; additionally, ensure per-scenario state is
reset by clearing or reinitializing context.is_docker_mode in the Behave
before_scenario hook (or equivalent) so the Docker mode decision
(context.is_docker_mode) cannot leak between scenarios.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 483ffe07-a2ee-48fd-9653-871a6e1a45ca

📥 Commits

Reviewing files that changed from the base of the PR and between 7cebde3 and df4aa4e.

📒 Files selected for processing (1)
  • tests/e2e/features/steps/proxy.py
📜 Review details
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (5)
  • GitHub Check: build-pr
  • GitHub Check: E2E: library mode / ci
  • GitHub Check: E2E: server mode / ci
  • GitHub Check: E2E Tests for Lightspeed Evaluation job
  • GitHub Check: Konflux kflux-prd-rh02 / lightspeed-stack-on-pull-request
🧰 Additional context used
📓 Path-based instructions (3)
**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Use absolute imports for internal modules from the Lightspeed Core Stack (e.g., from authentication import get_auth_dependency)

Files:

  • tests/e2e/features/steps/proxy.py
tests/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

tests/**/*.py: Use pytest for all unit and integration tests; do not use unittest
Maintain test coverage of at least 60% for unit tests and 10% for integration tests

Files:

  • tests/e2e/features/steps/proxy.py
tests/e2e/features/steps/**/*.py

📄 CodeRabbit inference engine (AGENTS.md)

Define E2E test step implementations in tests/e2e/features/steps/ directory

Files:

  • tests/e2e/features/steps/proxy.py
🧠 Learnings (1)
📚 Learning: 2025-08-25T09:11:38.701Z
Learnt from: radofuchs
Repo: lightspeed-core/lightspeed-stack PR: 445
File: tests/e2e/features/environment.py:0-0
Timestamp: 2025-08-25T09:11:38.701Z
Learning: In the Behave Python testing framework, the Context object is created once for the entire test run and reused across all features and scenarios. Custom attributes added to the context persist until explicitly cleared, so per-scenario state should be reset in hooks to maintain test isolation.

Applied to files:

  • tests/e2e/features/steps/proxy.py
🔇 Additional comments (1)
tests/e2e/features/steps/proxy.py (1)

27-30: Import update looks good.

The added is_prow_environment import is clean and keeps the new guard logic explicit.

Comment on lines +39 to +40
if is_prow_environment():
return False

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

RUNNING_PROW presence check can incorrectly disable Docker mode.

On Line 39, is_prow_environment() is truthy for any defined value (including empty string), so Line 40 can force False outside real Prow runs. That can mis-set context.is_docker_mode for the whole scenario.

Proposed fix (in tests/e2e/utils/utils.py)
def is_prow_environment() -> bool:
    """Check if running in Prow/OpenShift environment."""
-    return os.getenv("RUNNING_PROW") is not None
+    value = os.getenv("RUNNING_PROW")
+    return value is not None and value.strip().lower() in {"1", "true", "yes", "on"}

Based on learnings: In the Behave Python testing framework, the Context object is created once for the entire test run and reused across all features and scenarios. Custom attributes added to the context persist until explicitly cleared, so per-scenario state should be reset in hooks to maintain test isolation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@tests/e2e/features/steps/proxy.py` around lines 39 - 40, The
is_prow_environment() check is treating any defined RUNNING_PROW value
(including empty string) as truthy and can incorrectly force
context.is_docker_mode False; update is_prow_environment() to return a strict
boolean by reading the env var (e.g., os.getenv("RUNNING_PROW") in utils and
compare to a specific expected value like "1" or "true") and change the proxy
step to rely on that strict boolean; additionally, ensure per-scenario state is
reset by clearing or reinitializing context.is_docker_mode in the Behave
before_scenario hook (or equivalent) so the Docker mode decision
(context.is_docker_mode) cannot leak between scenarios.

@are-ces are-ces left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@radofuchs
radofuchs merged commit 509987f into lightspeed-core:main Mar 29, 2026
21 of 24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants