Io strategies
provide.testkit.chaos.io_strategies
¶
I/O and file system chaos strategies.
Provides Hypothesis strategies for generating file I/O failures, permission issues, disk space problems, and network-related chaos scenarios.
Functions¶
buffer_overflow_patterns
¶
Generate buffer overflow scenarios.
Creates situations where data exceeds buffer capacity.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draw
|
DrawFn
|
Hypothesis draw function |
required |
max_buffer_size
|
int
|
Maximum buffer size in bytes |
1024 * 1024
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing buffer overflow configuration |
Example
Source code in provide/testkit/chaos/io_strategies.py
disk_full_scenarios
¶
Generate disk space exhaustion scenarios.
Simulates running out of disk space during operations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draw
|
DrawFn
|
Hypothesis draw function |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing disk full scenario |
Example
Source code in provide/testkit/chaos/io_strategies.py
file_corruption_patterns
¶
Generate file corruption scenarios.
Simulates various types of file corruption for testing recovery.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draw
|
DrawFn
|
Hypothesis draw function |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing corruption configuration |
Example
Source code in provide/testkit/chaos/io_strategies.py
file_sizes
¶
file_sizes(
draw: DrawFn,
min_size: int = 0,
max_size: int = 10 * 1024 * 1024,
include_huge: bool = False,
) -> int
Generate realistic file size distributions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draw
|
DrawFn
|
Hypothesis draw function |
required |
min_size
|
int
|
Minimum file size in bytes |
0
|
max_size
|
int
|
Maximum file size in bytes |
10 * 1024 * 1024
|
include_huge
|
bool
|
Include very large file sizes (GB range) |
False
|
Returns:
| Type | Description |
|---|---|
int
|
File size in bytes |
Example
Source code in provide/testkit/chaos/io_strategies.py
lock_file_scenarios
¶
Generate file lock conflict scenarios.
Creates situations with competing file locks and stale locks.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draw
|
DrawFn
|
Hypothesis draw function |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing lock scenario configuration |
Example
Source code in provide/testkit/chaos/io_strategies.py
network_error_patterns
¶
Generate network failure patterns.
Creates sequences of network errors and recovery scenarios.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draw
|
DrawFn
|
Hypothesis draw function |
required |
Returns:
| Type | Description |
|---|---|
list[dict[str, Any]]
|
List of network error events |
Example
Source code in provide/testkit/chaos/io_strategies.py
path_traversal_patterns
¶
Generate path traversal attack patterns.
Creates potentially malicious path patterns for security testing.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draw
|
DrawFn
|
Hypothesis draw function |
required |
Returns:
| Type | Description |
|---|---|
str
|
A path string that might contain traversal attempts |
Example
Source code in provide/testkit/chaos/io_strategies.py
permission_patterns
¶
Generate file permission scenarios.
Creates various permission configurations for testing access control.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
draw
|
DrawFn
|
Hypothesis draw function |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary containing permission configuration |