@re-shell/cli
Version:
Full-stack development platform uniting microservices and microfrontends. Build complete applications with .NET (ASP.NET Core Web API, Minimal API), Java (Spring Boot, Quarkus, Micronaut, Vert.x), Rust (Actix-Web, Warp, Rocket, Axum), Python (FastAPI, Dja
219 lines (218 loc) • 6.09 kB
TypeScript
import { EventEmitter } from 'events';
export interface ErrorScenarioConfig {
scenarios: ErrorScenario[];
retryAttempts?: number;
timeout?: number;
parallel?: boolean;
generateReport?: boolean;
captureStdout?: boolean;
captureStderr?: boolean;
validateRecovery?: boolean;
cleanupAfterEach?: boolean;
}
export interface ErrorScenario {
name: string;
description?: string;
category: 'filesystem' | 'network' | 'permission' | 'memory' | 'process' | 'dependency' | 'custom';
trigger: ErrorTrigger;
expectedError?: ExpectedError;
recovery?: RecoveryAction[];
validation?: ValidationCheck[];
prerequisites?: string[];
cleanup?: string[];
timeout?: number;
skip?: boolean;
}
export interface ErrorTrigger {
type: 'command' | 'file' | 'network' | 'process' | 'memory' | 'signal' | 'custom';
action: string;
args?: any;
delay?: number;
condition?: string;
}
export interface ExpectedError {
type: 'exception' | 'exit_code' | 'timeout' | 'signal' | 'output';
pattern?: string | RegExp;
code?: number;
signal?: string;
message?: string;
severity?: 'low' | 'medium' | 'high' | 'critical';
}
export interface RecoveryAction {
type: 'retry' | 'fallback' | 'cleanup' | 'restart' | 'custom';
action: string;
args?: any;
timeout?: number;
condition?: string;
maxAttempts?: number;
}
export interface ValidationCheck {
type: 'file' | 'process' | 'state' | 'output' | 'custom';
target: string;
condition: 'exists' | 'running' | 'contains' | 'equals' | 'custom';
value?: any;
timeout?: number;
}
export interface ErrorTestResult {
scenario: string;
success: boolean;
error?: CapturedError;
recovery?: RecoveryResult;
validation?: ValidationResult[];
duration: number;
attempts: number;
logs: LogEntry[];
artifacts: string[];
timestamp: Date;
}
export interface CapturedError {
type: string;
message: string;
code?: number;
signal?: string;
stack?: string;
stdout?: string;
stderr?: string;
matched: boolean;
}
export interface RecoveryResult {
attempted: boolean;
successful: boolean;
actions: RecoveryActionResult[];
duration: number;
finalState: 'recovered' | 'failed' | 'partial';
}
export interface RecoveryActionResult {
action: string;
success: boolean;
duration: number;
error?: string;
output?: string;
}
export interface ValidationResult {
check: string;
success: boolean;
actual?: any;
expected?: any;
error?: string;
}
export interface LogEntry {
timestamp: Date;
level: 'debug' | 'info' | 'warn' | 'error';
message: string;
context?: any;
}
export interface ErrorTestReport {
summary: ErrorTestSummary;
results: ErrorTestResult[];
analysis: ErrorAnalysis;
recommendations: string[];
patterns: ErrorPattern[];
timestamp: Date;
}
export interface ErrorTestSummary {
totalScenarios: number;
passed: number;
failed: number;
recovered: number;
unrecovered: number;
categories: Map<string, number>;
severity: Map<string, number>;
duration: number;
}
export interface ErrorAnalysis {
resilience: ResilienceMetrics;
hotspots: ErrorHotspot[];
trends: ErrorTrend[];
gaps: RecoveryGap[];
}
export interface ResilienceMetrics {
errorRate: number;
recoveryRate: number;
averageRecoveryTime: number;
criticalFailures: number;
partialRecoveries: number;
}
export interface ErrorHotspot {
category: string;
count: number;
severity: 'low' | 'medium' | 'high' | 'critical';
description: string;
impact: string;
suggestion: string;
}
export interface ErrorTrend {
category: string;
direction: 'increasing' | 'decreasing' | 'stable';
rate: number;
period: string;
}
export interface RecoveryGap {
scenario: string;
issue: string;
impact: 'low' | 'medium' | 'high';
recommendation: string;
}
export interface ErrorPattern {
name: string;
pattern: RegExp;
category: string;
frequency: number;
examples: string[];
solution?: string;
}
export declare class ErrorScenarioTesting extends EventEmitter {
private config;
private results;
private workDir;
private logs;
constructor(config: ErrorScenarioConfig);
run(): Promise<ErrorTestReport>;
private setup;
private runSequential;
private runParallel;
private runScenario;
private runPrerequisites;
private triggerError;
private triggerCommandError;
private triggerFileError;
private triggerNetworkError;
private triggerProcessError;
private triggerMemoryError;
private triggerSignalError;
private triggerCustomError;
private validateExpectedError;
private attemptRecovery;
private executeRecoveryAction;
private retryAction;
private fallbackAction;
private cleanupAction;
private restartAction;
private customRecoveryAction;
private runValidation;
private executeValidationCheck;
private validateFile;
private validateProcess;
private validateState;
private validateOutput;
private validateCustom;
private executeCommand;
private cleanupScenario;
private cleanup;
private generateReport;
private generateSummary;
private analyzeResults;
private calculateResilience;
private identifyHotspots;
private analyzeTrends;
private identifyGaps;
private generateRecommendations;
private identifyPatterns;
private saveReport;
private formatSummary;
private log;
private wait;
}
export declare function createErrorScenario(name: string, category: ErrorScenario['category'], trigger: ErrorTrigger, options?: Partial<ErrorScenario>): ErrorScenario;
export declare function createErrorTrigger(type: ErrorTrigger['type'], action: string, args?: any): ErrorTrigger;
export declare function runErrorScenarios(scenarios: ErrorScenario[], config?: Partial<ErrorScenarioConfig>): Promise<ErrorTestReport>;