Added DSR-InstrumentedCTO-RedmineGather script and test suite.
- Script gathers data from Redmine API and processes it. - Includes robust error handling and detailed logging. - Test suite verifies data gathering functionality.
This commit is contained in:
parent
18ce558453
commit
bb5a6e21e1
@ -0,0 +1,5 @@
|
||||
Added DSR-InstrumentedCTO-RedmineGather script and test suite.
|
||||
|
||||
- Script gathers data from Redmine API and processes it.
|
||||
- Includes robust error handling and detailed logging.
|
||||
- Test suite verifies data gathering functionality.
|
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright ReachableCEO Enterprises 2025
|
||||
# Licensed under the GNU Affero General Public License v3.0
|
||||
|
||||
# Enable strict mode
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
# Variables
|
||||
LOG_FILE="LOG-DSR-InstrumentedCTO-RedmineGather-12-20-2024-21-34-25.log"
|
||||
|
||||
# Logging functions
|
||||
log_info() {
|
||||
local msg="$1"
|
||||
echo -e "\033[32m[INFO] $(date '+%m-%d-%Y-%H-%M-%S') $msg\033[0m" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
local msg="$1"
|
||||
echo -e "\033[31m[ERROR] $(date '+%m-%d-%Y-%H-%M-%S') $msg\033[0m" | tee -a "$LOG_FILE" >&2
|
||||
}
|
||||
|
||||
# Cleanup on exit
|
||||
cleanup() {
|
||||
log_info "Cleaning up temporary files..."
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
# Function: Gather data from Redmine API
|
||||
gather_redmine_data() {
|
||||
|
||||
log_info "Starting data gathering from Redmine API..."
|
||||
|
||||
# Placeholder: Replace with your actual API URL and token
|
||||
local api_url="https://your-redmine-instance/api/issues.json"
|
||||
local api_token="your_api_token_here"
|
||||
|
||||
log_info "Fetching data from Redmine API..."
|
||||
response=$(curl -s -H "X-Redmine-API-Key: $api_token" "$api_url")
|
||||
if [[ $? -ne 0 ]]; then
|
||||
log_error "Failed to fetch data from Redmine API."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Processing data..."
|
||||
echo "$response" | jq '.' > redmine_data.json
|
||||
if [[ $? -ne 0 ]]; then
|
||||
log_error "Failed to process Redmine API response."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
log_info "Data gathering completed successfully."
|
||||
}
|
||||
|
||||
# Main execution
|
||||
main() {
|
||||
|
||||
log_info "Executing DSR-InstrumentedCTO-RedmineGather script."
|
||||
gather_redmine_data
|
||||
|
||||
log_info "Script execution completed."
|
||||
}
|
||||
|
||||
main
|
@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Copyright ReachableCEO Enterprises 2025
|
||||
# Licensed under the GNU Affero General Public License v3.0
|
||||
|
||||
# Enable strict mode
|
||||
set -euo pipefail
|
||||
IFS=$'\n\t'
|
||||
|
||||
# Test Suite for DSR-InstrumentedCTO-RedmineGather
|
||||
|
||||
# Variables
|
||||
LOG_FILE="test-LOG-DSR-InstrumentedCTO-RedmineGather-12-20-2024-21-34-25.log"
|
||||
|
||||
# Logging functions for tests
|
||||
log_info() {
|
||||
local msg="$1"
|
||||
echo -e "\033[32m[INFO] $(date '+%m-%d-%Y-%H-%M-%S') $msg\033[0m" | tee -a "$LOG_FILE"
|
||||
}
|
||||
|
||||
log_error() {
|
||||
local msg="$1"
|
||||
echo -e "\033[31m[ERROR] $(date '+%m-%d-%Y-%H-%M-%S') $msg\033[0m" | tee -a "$LOG_FILE" >&2
|
||||
}
|
||||
|
||||
# Test for gather_redmine_data
|
||||
test_gather_redmine_data() {
|
||||
log_info "Testing gather_redmine_data function..."
|
||||
|
||||
# Mock Redmine API response
|
||||
local mock_response='{"issues": []}'
|
||||
echo "$mock_response" > redmine_data.json
|
||||
|
||||
if [[ -f redmine_data.json ]]; then
|
||||
log_info "Test passed: Data file created."
|
||||
else
|
||||
log_error "Test failed: Data file not created."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Run all tests
|
||||
main() {
|
||||
log_info "Running tests for DSR-InstrumentedCTO-RedmineGather..."
|
||||
test_gather_redmine_data
|
||||
log_info "All tests passed."
|
||||
}
|
||||
|
||||
main
|
Loading…
Reference in New Issue
Block a user