Skip to content

test: add offline-mode regression tests for RAC fixtures#28

Merged
rophy merged 2 commits into
masterfrom
test/offline-rac-fixtures
Jul 15, 2026
Merged

test: add offline-mode regression tests for RAC fixtures#28
rophy merged 2 commits into
masterfrom
test/offline-rac-fixtures

Conversation

@rophy

@rophy rophy commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds tests/fixtures/test_fixtures_offline.py — runs all 53 RAC fixtures through OLR's offline reader mode
  • Validates that OLR can discover multi-thread archive logs by directory scanning alone, with no Oracle connection and online-redo stripped from the checkpoint
  • Uses path-mapping to redirect ASM paths to staged archive directories
  • Same golden files as existing batch-mode tests — output must match exactly

Motivation

The existing fixture regression tests only exercise batch mode (explicit file list). This adds coverage for the offline reader code path, which scans <db-recovery-file-dest>/<context>/archivelog/<date>/ for archives matching log-archive-format.

Test plan

  • All 53 RAC fixtures pass in offline mode (verified locally, 9m16s)

Summary by CodeRabbit

  • Tests
    • Added automated coverage for offline processing with RAC fixtures.
    • Exercises fixture-driven offline configuration generation, archived redo staging, and offline OLR execution.
    • Verifies successful runs and performs deterministic byte-for-byte comparisons of generated output.json against golden expected results.
    • Executes across all discovered RAC fixture scenarios to improve confidence in offline-mode behavior.

Runs all 53 RAC fixtures through OLR's offline reader instead of batch.
Validates archive discovery by directory scanning with no Oracle access
and online-redo stripped from the checkpoint.
@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

This change adds a parametrized offline-mode test for RAC fixtures. It derives checkpoint and archive metadata, stages redo files, generates an OLR Docker configuration, runs OLR, and compares the resulting JSON with golden output.

Offline RAC validation

Layer / File(s) Summary
Test runner setup
tests/fixtures/test_fixtures_offline.py
Defines fixture paths and runs the OLR Docker image with the generated configuration.
Offline input and configuration preparation
tests/fixtures/test_fixtures_offline.py
Finds schema checkpoints, strips online redo, stages archives, detects archive format, and builds offline path mappings and OLR configuration.
RAC fixture parametrization and output validation
tests/fixtures/test_fixtures_offline.py
Selects -rac fixtures, validates required files, executes OLR, and compares generated output JSON with golden results.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Pytest
  participant OfflineConfig
  participant OLR_Docker
  participant FixtureFiles
  Pytest->>OfflineConfig: discover checkpoint and archive metadata
  OfflineConfig->>FixtureFiles: stage archives and write offline config
  Pytest->>OLR_Docker: run OLR with mounted configuration
  OLR_Docker-->>Pytest: produce output.json and return status
  Pytest->>FixtureFiles: compare output.json with golden JSON
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding offline-mode regression tests for RAC fixtures.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/offline-rac-fixtures

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
tests/fixtures/test_fixtures_offline.py (1)

39-54: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Filename-based archive-format detection is a fragile heuristic.

detect_archive_format guesses log-archive-format from a single sample filename via rsplit("_", 2) plus a digit-stripping loop. This works for a simple <prefix><thread>_<seq>_<resetlogs>.ext shape but breaks silently (producing a nonsensical format string) for other common Oracle archived-log naming conventions (e.g., OMF-style names with a trailing separator before the extension). Since this determines whether OLR can even discover the staged archives, a wrong guess would likely surface only as a confusing OLR failure rather than a clear test error.

Since checkpoints/schema files may already encode redo log locations/format (per OLR's schema-file semantics), consider deriving the format from checkpoint metadata instead of reverse-engineering it from a filename sample, if such metadata is available.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/fixtures/test_fixtures_offline.py` around lines 39 - 54, Replace the
filename-based heuristic in detect_archive_format with the archive format
recorded in the available checkpoint or schema metadata, using the existing
metadata representation and OLR schema-file semantics. Ensure the derived format
is passed through unchanged for staged archive discovery, and add an explicit
failure or validation path when the metadata does not provide a usable format
instead of silently guessing from a sample filename.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@tests/fixtures/test_fixtures_offline.py`:
- Around line 23-36: Update the subprocess.run call in _run_olr to include a
finite timeout for the Docker-launched OLR process, using the test suite’s
established timeout configuration if available. Preserve the existing command
arguments and output-capture behavior while ensuring hangs raise the standard
subprocess timeout exception.

---

Nitpick comments:
In `@tests/fixtures/test_fixtures_offline.py`:
- Around line 39-54: Replace the filename-based heuristic in
detect_archive_format with the archive format recorded in the available
checkpoint or schema metadata, using the existing metadata representation and
OLR schema-file semantics. Ensure the derived format is passed through unchanged
for staged archive discovery, and add an explicit failure or validation path
when the metadata does not provide a usable format instead of silently guessing
from a sample filename.
🪄 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: CHILL

Plan: Pro

Run ID: 831e93f5-5acf-4dfc-819d-251a5322b2e0

📥 Commits

Reviewing files that changed from the base of the PR and between a6a12f9 and 532ff7c.

📒 Files selected for processing (1)
  • tests/fixtures/test_fixtures_offline.py

Comment thread tests/fixtures/test_fixtures_offline.py Outdated
- Add 120s timeout to docker run to prevent hanging tests
- Read log-archive-format from checkpoint metadata first, fall back to
  filename inference only when checkpoint format doesn't match actual files

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
tests/fixtures/test_fixtures_offline.py (1)

49-62: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Avoid relying strictly on files[0] from directory globs.

Evaluating only the first item makes the test fragile. If a hidden or unrelated file (such as .DS_Store) is evaluated first, the format inference will fail or falsely reject the pattern, causing the test suite to crash.

  • tests/fixtures/test_fixtures_offline.py#L49-L62: Iterate over files and return the inferred format based on the first valid file that splits into at least 3 parts, instead of strictly assuming files[0] is a valid redo log.
  • tests/fixtures/test_fixtures_offline.py#L77-L79: Use any(...) to check if the pattern matches any file in the directory, rather than only testing files[0].
🛠️ Proposed fixes

For _infer_format_from_filename (around lines 49-62):

     files = sorted(f for f in glob.glob(os.path.join(redo_dir, "*")) if os.path.isfile(f))
-    if not files:
-        return None
-    fname = os.path.basename(files[0])
-    stem, ext = os.path.splitext(fname)
-    parts = stem.rsplit("_", 2)
-    if len(parts) < 3:
-        return None
-    prefix_thread = parts[0]
-    i = len(prefix_thread)
-    while i > 0 and prefix_thread[i - 1].isdigit():
-        i -= 1
-    prefix = prefix_thread[:i]
-    return f"{prefix}%t_%s_%r{ext}"
+    for f in files:
+        fname = os.path.basename(f)
+        stem, ext = os.path.splitext(fname)
+        parts = stem.rsplit("_", 2)
+        if len(parts) >= 3:
+            prefix_thread = parts[0]
+            i = len(prefix_thread)
+            while i > 0 and prefix_thread[i - 1].isdigit():
+                i -= 1
+            prefix = prefix_thread[:i]
+            return f"{prefix}%t_%s_%r{ext}"
+    return None

For _detect_archive_format (around lines 77-79):

         files = [os.path.basename(f) for f in glob.glob(os.path.join(redo_dir, "*")) if os.path.isfile(f)]
-        if files and re.fullmatch(pattern, files[0]):
-            return chkpt_fmt
+        if any(re.fullmatch(pattern, f) for f in files):
+            return chkpt_fmt
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/fixtures/test_fixtures_offline.py` around lines 49 - 62, Update
_infer_format_from_filename in tests/fixtures/test_fixtures_offline.py at lines
49-62 to iterate through files and return the format inferred from the first
filename whose stem splits into at least three parts; return None only if no
file is valid. Update _detect_archive_format at lines 77-79 to use any(...) so
pattern matching succeeds when any directory file matches, rather than checking
only files[0].
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@tests/fixtures/test_fixtures_offline.py`:
- Around line 49-62: Update _infer_format_from_filename in
tests/fixtures/test_fixtures_offline.py at lines 49-62 to iterate through files
and return the format inferred from the first filename whose stem splits into at
least three parts; return None only if no file is valid. Update
_detect_archive_format at lines 77-79 to use any(...) so pattern matching
succeeds when any directory file matches, rather than checking only files[0].

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0893f0f5-56e4-4f8d-92d4-c058b7664e94

📥 Commits

Reviewing files that changed from the base of the PR and between 532ff7c and 05d0f0b.

📒 Files selected for processing (1)
  • tests/fixtures/test_fixtures_offline.py

@rophy
rophy merged commit 44ef194 into master Jul 15, 2026
2 checks passed
@rophy
rophy deleted the test/offline-rac-fixtures branch July 15, 2026 18:42
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