mirror of
https://github.com/acedanger/shell.git
synced 2025-12-06 10:00:11 -08:00
- Updated setup.sh to check for Nala installation and provide alternative installation methods based on Ubuntu version. - Added error handling for package installation, allowing fallback to apt if Nala fails. - Introduced startup.sh to perform container startup checks, including system info and permissions for logs directory. - Created test-setup.sh to validate bootstrap and setup scripts, including detailed logging of package availability and installation results. - Implemented checks for missing packages and provided recommendations for manual installation. - Enhanced logging for better traceability of actions and errors during setup and testing processes.
84 lines
2.6 KiB
Markdown
84 lines
2.6 KiB
Markdown
# Docker-based Testing Framework Improvements
|
|
|
|
This document outlines the improvements made to the Docker-based testing framework for validating shell scripts and dotfiles across different environments.
|
|
|
|
## Issues Fixed
|
|
|
|
### 1. `local` Keyword Usage Outside Function
|
|
|
|
Fixed a syntax error where the `local` keyword was used outside of a function context:
|
|
|
|
```bash
|
|
# Before (incorrect):
|
|
for pkg in $packages; do
|
|
local actual_pkg=$(get_package_name "$pkg")
|
|
# ...
|
|
done
|
|
|
|
# After (correct):
|
|
for pkg in $packages; do
|
|
actual_pkg=$(get_package_name "$pkg")
|
|
# ...
|
|
done
|
|
```
|
|
|
|
### 2. Log Directory Handling
|
|
|
|
Enhanced log directory handling to ensure proper permissions and fallback mechanisms:
|
|
|
|
- Added better error handling for log directory creation and permissions
|
|
- Added validation to verify write permissions before proceeding
|
|
- Implemented fallback to /tmp if host volume mounting fails
|
|
- Added debugging information when log operations fail
|
|
|
|
### 3. Package Verification
|
|
|
|
Improved package detection, especially for packages like `cowsay` and `lolcat` that are typically installed in `/usr/games/`:
|
|
|
|
- Enhanced `test_package()` function to check in common alternate locations
|
|
- Added specific handling for packages that may be installed with different paths
|
|
- Added detailed debugging output for problematic packages
|
|
|
|
### 4. Docker Container Configuration
|
|
|
|
Improved the Docker container configuration for more reliable testing:
|
|
|
|
- Added proper volume mounting with explicit read/write permissions
|
|
- Added timestamp consistency between host and container
|
|
- Added container type labels to log files for better tracking
|
|
- Enhanced error detection for volume mounting issues
|
|
|
|
## Implementation Details
|
|
|
|
### 1. Enhanced Logging System
|
|
|
|
- Timestamps are now synchronized between host and container
|
|
- Log file names include container type (ubuntu/debian) for clarity
|
|
- Added validation to confirm logs are properly saved to host
|
|
|
|
### 2. Container Environment Setup
|
|
|
|
- Improved `startup.sh` with better diagnostics before running tests
|
|
- Added permissions verification for mounted volumes
|
|
- Added write tests to confirm permissions are correctly set
|
|
|
|
### 3. Test Framework Improvements
|
|
|
|
- Improved error handling for better diagnostics
|
|
- Enhanced reporting for package detection issues
|
|
- Better isolation between test iterations
|
|
|
|
## Running Tests
|
|
|
|
To run tests with the improved framework:
|
|
|
|
```bash
|
|
# Test in Ubuntu container
|
|
./run-docker-tests.sh ubuntu
|
|
|
|
# Test in Debian container
|
|
./run-docker-tests.sh debian
|
|
```
|
|
|
|
The logs will be saved in the `./logs` directory with filenames that include the timestamp and container type.
|