Files
ocf-managed-container/tests/plugin_test_support.py
T
Lyncoln ec2077f979 Freeze lab-tested PostgreSQL plugin engine
Extract PostgreSQL, Podman runtime and systemd lifecycle adapters while preserving existing lifecycle and scoring behavior. Update RPM layout and add guarded operator-run lab harnesses.

Record successful manual stop/start, promotion, demotion and rewind-only rejoin with pinned installed hashes. The unfenced lab does not validate automatic failover, Pacemaker-managed transitions or divergent-data rewind.

Validation: 103 offline tests, original-function differential checks, checksum manifest and whitespace checks passed.
2026-09-13 01:57:04 -04:00

34 lines
1.5 KiB
Python

"""Shared test loader and narrowly reversible command-boundary substitutions."""
from pathlib import Path
import re
import shlex
ROOT = Path(__file__).resolve().parents[1]
MODULE_DIR = ROOT / 'refactored/managed-container.d'
LOAD = '''MC_PROMOTION_RESOURCE_INSTANCE="${OCF_RESOURCE_INSTANCE:-}"
: "${OCF_ROOT:=/usr/lib/ocf}"
. "$OCF_ROOT/lib/heartbeat/ocf-shellfuncs"
: "${OCF_RUNNING_PROMOTED:=${OCF_RUNNING_MASTER:-8}}"
MC_MODULE_DIR=''' + shlex.quote(str(MODULE_DIR)) + '''
. "$MC_MODULE_DIR/common.sh"
. "$MC_MODULE_DIR/container.sh"
. "$MC_MODULE_DIR/engine.sh"
mc_engine_load || exit $?
'''
def restore_boundaries(source):
"""Project only adapter calls back to their frozen original spelling.
This is not whitespace normalization or a general semantic equivalence
claim. All remaining function bytes must match the immutable reference.
"""
source = source.replace('mc_runtime_inspect', 'as_service_user podman inspect')
source = source.replace('mc_runtime_info', 'as_service_user podman info')
pattern = r'^([ \t]*)(.*?)mc_runtime_exec \\\n'
source = re.sub(pattern, lambda m: m[1] + m[2] + 'as_service_user \\\n' + m[1] + ' podman exec \\\n', source, flags=re.M)
pattern = r'^([ \t]*)(.*?)mc_lifecycle_(start|stop|cat|running) '
source = re.sub(pattern, lambda m: m[1] + m[2] + 'as_service_user \\\n' + m[1] + ' systemctl --user ' +
('is-active --quiet' if m[3] == 'running' else m[3]) + ' ', source, flags=re.M)
return source