Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure
TypeScript
test(e2e): reintroduce NetworkPolicy-lane negatives scoped to clean windows [R3-H6]
Alfredo Lopez2a2ad46f7990
diff --git a/scripts/e2e/e2e-hcc-mcp-context-readiness.sh b/scripts/e2e/e2e-hcc-mcp-context-readiness.shindex e84616983..b3c04edc1 100755--- a/scripts/e2e/e2e-hcc-mcp-context-readiness.sh+++ b/scripts/e2e/e2e-hcc-mcp-context-readiness.sh@@ -103,6 +103,18 @@ HCC_GATE_FINALIZATION_FAILURE=""HCC_READY_PROBE_DIAGNOSTIC=""BASELINE_POLICY_SNAPSHOT=""+# Clean-window negative markers. Consumed ONLY while the DNS fault injection is+# NOT applied (pre-injection pre-checks, post-restore cleanup): under the+# injection the additive NetworkPolicy lane legitimately fails and schedules+# retries, so these negatives false-fail inside the injected window (removed+# there by 1abcfb1/15997353/e7064a7f). Inventoried in+# scripts/tests/test-hcc-watch-recovery-gate.sh marker_bindings.+NETPOL_INITIAL_FAILED_MARKER='Initial NetworkPolicy background reconciliation failed:'+NETPOL_ADDITIVE_FAILED_MARKER='Initial NetworkPolicy post-certification additive reconciliation failed:'+NETPOL_RETRY_SCHEDULED_MARKER='Scheduling initial NetworkPolicy background convergence retry'+NETPOL_CONTEXT_FAILED_MARKER='NetworkPolicy reconciliation failed for context '+clean_window_checks_run=0+[[ "$MCP_FLEET_SIZE" =~ ^[0-9]+$ ]] && [ "$MCP_FLEET_SIZE" -gt 10 ] &&[ "$MCP_FLEET_SIZE" -le 24 ] || {echo "E2E_HCC_MCP_FLEET_SIZE must be an integer from 11 through 24; got ${MCP_FLEET_SIZE}." >&2@@ -474,6 +486,31 @@ external_egress_policy_absent() {[ -z "$policies" ]}+clean_window_netpol_log_negatives_hold() {+ # Family 1, fail-closed snapshot: read ONE authoritative log snapshot so a+ # kubectl logs failure cannot make the negative assertions pass vacuously.+ local pod=$1 logs+ [ -n "$pod" ] || return 1+ logs="$(kctl logs "pod/${pod}" -n "$HCC_NS" \+ -c host-context-controller 2>/dev/null)" || return 1+ ! grep -Fq "$NETPOL_INITIAL_FAILED_MARKER" <<<"$logs" &&+ ! grep -Fq "$NETPOL_ADDITIVE_FAILED_MARKER" <<<"$logs" &&+ ! grep -Fq "$NETPOL_RETRY_SCHEDULED_MARKER" <<<"$logs" &&+ ! grep -Fq "${NETPOL_CONTEXT_FAILED_MARKER}${CONTEXT_NAME}:" <<<"$logs"+}++clean_window_runtime_and_ready_absent() {+ # Family 3, clean-window form. fixture_runtime_and_ready_absent requires the+ # McpServer object to EXIST (mcpserver_current_ready_absent fails on a missing+ # object); in clean windows the fixture may not exist at all, which is the+ # strongest form of absence. An API error still fails closed.+ fixture_runtime_absent || return 1+ if ! resource_absent mcpserver "$MCP_NAME" "$MCP_NS"; then+ mcpserver_current_ready_absent "$MCP_NAME" || return 1+ fi+ external_egress_policy_absent+}+fixture_runtime_converged_with_protocol() {local protocol=$1 desired availabledesired="$(kctl get deployment "$MCP_NAME" -n "$MCP_NS" \@@ -1018,6 +1055,7 @@ EOFcleanup() {local status=$? cleanup_failed=0 restore_ok=1 fixture_inputs_removed=1 restore_patch+ local clean_window_podtrap - EXITset +e@@ -1088,6 +1126,29 @@ cleanup() {fiwait_until 60 "all HCC MCP readiness suite resources to disappear" \suite_resources_absent >/dev/null 2>&1 || cleanup_failed=1++ # Clean window B: DNS restored and fixture inputs gone. The restored pod is+ # new (scale-0 preceded the restore), so its log is scoped to this window.+ clean_window_pod="$(running_hcc_pod)"+ if [ -n "$clean_window_pod" ] &&+ clean_window_netpol_log_negatives_hold "$clean_window_pod"; then+ clean_window_checks_run=$((clean_window_checks_run + 1))+ else+ fail "post-restore clean-window NetworkPolicy log negatives did not hold"+ cleanup_failed=1+ fi+ if fixture_mcp_runtime_absent; then+ clean_window_checks_run=$((clean_window_checks_run + 1))+ else+ fail "post-restore fixture runtime or external-egress policy survived"+ cleanup_failed=1+ fi+ if clean_window_runtime_and_ready_absent; then+ clean_window_checks_run=$((clean_window_checks_run + 1))+ else+ fail "post-restore McpServer Ready status or external-egress policy survived"+ cleanup_failed=1+ fielsecleanup_failed=1fi@@ -1096,6 +1157,11 @@ cleanup() {cleanup_failed=1fi+ if [ "$status" = 0 ]; then+ [ "${clean_window_checks_run:-0}" -gt 0 ] ||+ die "no clean-window negative checks ran (clean_window_checks_run=0)"+ fi+if [ "$cleanup_failed" -ne 0 ]; thenecho "HCC MCP readiness gate cleanup failed on context ${E2E_KUBECONTEXT}." >&2[ "$restore_ok" = 1 ] || print_repair_instructions@@ -1122,6 +1188,22 @@ acquire_hcc_watch_gate_lock ||die "another disruptive HCC gate owns context ${E2E_KUBECONTEXT}"ok "branch helper, profile, exact HEAD/fingerprint/gate, and exclusive HCC lock verified"+# Clean window A: the DNS fault injection is not applied yet. The branch-deployed+# HCC must show a clean NetworkPolicy lane and zero fixture residue before the+# gate mutates anything.+clean_window_pod="$(running_hcc_pod)" && [ -n "$clean_window_pod" ] ||+ die "no Running HCC pod before fault injection"+clean_window_netpol_log_negatives_hold "$clean_window_pod" ||+ die "pre-injection HCC logs already contain NetworkPolicy-lane failure or retry markers"+clean_window_checks_run=$((clean_window_checks_run + 1))+fixture_mcp_runtime_absent ||+ die "pre-injection fixture runtime or external-egress policy already exists"+clean_window_checks_run=$((clean_window_checks_run + 1))+clean_window_runtime_and_ready_absent ||+ die "pre-injection McpServer Ready status or external-egress policy already exists"+clean_window_checks_run=$((clean_window_checks_run + 1))+ok "all three clean-window negative families hold before DNS fault injection"+ORIGINAL_REPLICAS="$(kctl get deployment "$HCC_DEPLOY" -n "$HCC_NS" \-o jsonpath='{.spec.replicas}')"[ "$ORIGINAL_REPLICAS" = 1 ] ||@@ -1352,6 +1434,9 @@ DNS_BLOCKER_IP="$(kctl get service "$DNS_BLOCKER_NAME" -n "$HCC_NS" \[ -n "$DNS_BLOCKER_IP" ] || die "DNS blocker Service has no ClusterIP"ok "isolated DNS hold proxy is ready and forwards non-fixture UDP/TCP queries to CoreDNS"+[ "${clean_window_checks_run:-0}" -ge 3 ] ||+ die "pre-injection clean-window negatives did not run before the DNS mutation"+HCC_MUTATED=1dns_patch="$(jq -cn --arg nameserver "$DNS_BLOCKER_IP" '{spec:{template:{spec:{diff --git a/scripts/tests/test-hcc-watch-recovery-gate.sh b/scripts/tests/test-hcc-watch-recovery-gate.shindex a2c2e3c90..d25695b98 100755--- a/scripts/tests/test-hcc-watch-recovery-gate.sh+++ b/scripts/tests/test-hcc-watch-recovery-gate.sh@@ -500,6 +500,18 @@ marker_bindings=("$MCP_READINESS_GATE" '[NetPol] Reconciling context \"${CONTEXT_ID}\" — allowed servers: []'"$HCC_NETWORK_POLICY_RECONCILER" 'Reconciling context "${contextId}" — allowed servers: [${allowedServers.join('++ "$MCP_READINESS_GATE" "NETPOL_INITIAL_FAILED_MARKER='Initial NetworkPolicy background reconciliation failed:'"+ "$HCC_K8S_CLIENT" 'Initial NetworkPolicy background reconciliation failed:'++ "$MCP_READINESS_GATE" "NETPOL_ADDITIVE_FAILED_MARKER='Initial NetworkPolicy post-certification additive reconciliation failed:'"+ "$HCC_K8S_CLIENT" 'Initial NetworkPolicy post-certification additive reconciliation failed:'++ "$MCP_READINESS_GATE" "NETPOL_RETRY_SCHEDULED_MARKER='Scheduling initial NetworkPolicy background convergence retry'"+ "$HCC_K8S_CLIENT" 'Scheduling initial ${lane} background convergence retry'++ "$MCP_READINESS_GATE" "NETPOL_CONTEXT_FAILED_MARKER='NetworkPolicy reconciliation failed for context '"+ "$HCC_K8S_CLIENT" 'NetworkPolicy reconciliation failed for context ${context.name}:')marker_drift=""marker_binding_count=0@@ -527,7 +539,7 @@ done# unset. Assert the arity explicitly rather than relying on the pair count to# happen to notice.if [ $((${#marker_bindings[@]} % 4)) -eq 0 ] &&- [ "$marker_binding_count" -eq 31 ] &&+ [ "$marker_binding_count" -eq 35 ] &&[ -z "$marker_drift" ]; thenpass "all ${marker_binding_count} consumed HCC log markers stay bound to their runtime producers"else@@ -621,6 +633,60 @@ if (elsefail "successful ready probe retains a misleading prior diagnostic"fi++# H6 gate-fix mutation (E4): the clean-window NetworkPolicy negative must FAIL+# against an injection-window log (moving it inside the injected window would+# false-fail — the scoping is load-bearing), PASS against a clean log, and fail+# closed when kubectl errors. The gate itself can't run (minikube churn), so+# this statically pins the predicate.+clean_window_netpol_negatives_function="$(+ sed -n '/^clean_window_netpol_log_negatives_hold() {$/,/^}$/p' "$MCP_READINESS_GATE"+)"+clean_window_marker_defs="$(grep -E "^NETPOL_[A-Z_]+_MARKER='" "$MCP_READINESS_GATE")"+run_clean_window_negative_case() (+ local mode=$1+ CONTEXT_NAME=alpha+ HCC_NS=control-plane+ eval "$clean_window_marker_defs"+ case $mode in+ injected)+ kctl() {+ printf '%s\n' \+ '[K8s] Initial NetworkPolicy post-certification additive reconciliation failed: dns timeout' \+ '[K8s] Scheduling initial NetworkPolicy background convergence retry 1 in 5000ms'+ } ;;+ clean) kctl() { printf '%s\n' '[K8s] NetworkPolicy convergence certified'; } ;;+ api-error) kctl() { return 1; } ;;+ esac+ eval "$clean_window_netpol_negatives_function"+ clean_window_netpol_log_negatives_hold hcc-pod+)+if ! run_clean_window_negative_case injected &&+ run_clean_window_negative_case clean &&+ ! run_clean_window_negative_case api-error; then+ pass "clean-window NetworkPolicy negative fails inside the injected window, passes clean, and fails closed"+else+ fail "clean-window NetworkPolicy negative does not distinguish injected-window failures or fails open"+fi++# Static ordering fence: a clean-window negative invocation must exist in the+# MAIN BODY (after `trap cleanup EXIT`) and before the DNS mutation. cleanup()+# is defined earlier in the file than the mutation but runs on EXIT, so a plain+# "first line < mutation line" test would be satisfied by the cleanup-window+# invocation alone; excluding everything at or before the trap line pins the+# pre-injection (window A) invocation specifically.+trap_line="$(grep -n '^trap cleanup EXIT' "$MCP_READINESS_GATE" | head -1 | cut -d: -f1)"+dns_mutation_line="$(grep -n '^HCC_MUTATED=1' "$MCP_READINESS_GATE" | head -1 | cut -d: -f1)"+body_clean_window_negative_line="$(+ grep -n 'clean_window_netpol_log_negatives_hold "' "$MCP_READINESS_GATE" |+ awk -F: -v t="${trap_line:-0}" -v m="${dns_mutation_line:-0}" \+ '$1 > t && $1 < m { print $1; exit }'+)"+if [ -n "$body_clean_window_negative_line" ]; then+ pass "clean-window NetworkPolicy negative runs in the body before the DNS fault injection"+else+ fail "clean-window NetworkPolicy negative is missing from the pre-injection body window"+fiif (NEW_HCC_POD=hcc-podHCC_NS=control-plane