Add comprehensive PSMinIO test scripts

 COMPREHENSIVE TEST SUITE:

� TEST SCRIPTS CREATED:
  • Test-PSMinIOComprehensive.ps1 - Automated full test suite
  • Test-PSMinIOIndividual.ps1 - Individual commands for manual testing
  • Both scripts use proper PowerShell practices (no Write-Host)
  • Configured for Grace Solution S3 instance testing

� TEST COVERAGE:
  • Connection establishment and authentication
  • Bucket operations (list, create, exists check)
  • Single file upload/download operations
  • Multipart upload/download operations
  • Object listing and metadata retrieval
  • Presigned URL generation
  • File integrity verification
  • Comprehensive error handling

� TEST FEATURES:
  • Creates test files of varying sizes (small, medium, large)
  • Tests both single-part and multipart operations
  • Verifies downloaded file integrity
  • Provides detailed test results and metrics
  • Includes cleanup instructions
  • Uses Write-Verbose and Write-Output (no Write-Host)

� USAGE:
  Comprehensive: .\scripts\Test-PSMinIOComprehensive.ps1 -Verbose
  Individual: Copy commands from Test-PSMinIOIndividual.ps1

Ready for comprehensive PSMinIO functionality testing!
This commit is contained in:
PSMinIO Developer
2025-07-14 17:21:43 -04:00
parent 7a251456f0
commit b1adfa6328
2 changed files with 309 additions and 0 deletions
+186
View File
@@ -0,0 +1,186 @@
# PSMinIO Comprehensive Test Script
# Tests all major functionality against Grace Solution S3 instance
param(
[string]$TestDirectory = "C:\Temp\PSMinIOTest",
[string]$TestBucket = "psminiotest-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
)
# Test configuration
$S3Url = "https://api.s3.gracesolution.info"
$AccessKey = "T34Wg85SAwezUa3sk3m4"
$SecretKey = "PxEmnbQoQJTJsDocSEV6mSSscDpJMiJCayPv93xe"
Write-Verbose "=== PSMinIO Comprehensive Test Suite ==="
Write-Verbose "S3 Endpoint: $S3Url"
Write-Verbose "Test Bucket: $TestBucket"
Write-Verbose "Test Directory: $TestDirectory"
# Create test directory and files
Write-Verbose "Setting up test environment..."
if (Test-Path $TestDirectory) {
Remove-Item $TestDirectory -Recurse -Force
}
New-Item -ItemType Directory -Path $TestDirectory -Force | Out-Null
# Create test files of various sizes
$SmallFile = Join-Path $TestDirectory "small-test.txt"
$MediumFile = Join-Path $TestDirectory "medium-test.txt"
$LargeFile = Join-Path $TestDirectory "large-test.txt"
"This is a small test file for PSMinIO testing." | Out-File $SmallFile -Encoding UTF8
1..1000 | ForEach-Object { "Line $_ - Medium test file content for PSMinIO testing with more data." } | Out-File $MediumFile -Encoding UTF8
1..10000 | ForEach-Object { "Line $_ - Large test file content for PSMinIO multipart testing with substantial data to trigger chunked operations." } | Out-File $LargeFile -Encoding UTF8
$testFiles = Get-ChildItem $TestDirectory
Write-Verbose "Created test files: $($testFiles.Count) files, Total size: $([math]::Round(($testFiles | Measure-Object Length -Sum).Sum / 1KB, 2)) KB"
$testResults = @()
try {
# Test 1: Connection
Write-Verbose "Testing connection..."
$connection = Connect-MinIO -Url $S3Url -AccessKey $AccessKey -SecretKey $SecretKey -Verbose
$testResults += [PSCustomObject]@{
Test = "Connection"
Status = "Success"
Details = "Connected to $S3Url"
Result = $connection
}
# Test 2: List existing buckets
Write-Verbose "Testing bucket listing..."
$buckets = Get-MinIOBucket -Verbose
$testResults += [PSCustomObject]@{
Test = "List Buckets"
Status = "Success"
Details = "Found $($buckets.Count) existing buckets"
Result = $buckets
}
# Test 3: Create test bucket
Write-Verbose "Testing bucket creation..."
$newBucket = New-MinIOBucket -BucketName $TestBucket -Verbose
$testResults += [PSCustomObject]@{
Test = "Create Bucket"
Status = "Success"
Details = "Created bucket: $($newBucket.Name)"
Result = $newBucket
}
# Test 4: Verify bucket exists
Write-Verbose "Testing bucket existence check..."
$bucketExists = Test-MinIOBucketExists -BucketName $TestBucket -Verbose
$testResults += [PSCustomObject]@{
Test = "Bucket Exists"
Status = "Success"
Details = "Bucket exists: $bucketExists"
Result = $bucketExists
}
# Test 5: Upload small file (single part)
Write-Verbose "Testing single file upload..."
$uploadResult = New-MinIOObject -BucketName $TestBucket -Files (Get-Item $SmallFile) -Verbose
$testResults += [PSCustomObject]@{
Test = "Single File Upload"
Status = "Success"
Details = "Uploaded small file: $($uploadResult.Count) objects"
Result = $uploadResult
}
# Test 6: Upload medium file (single part)
Write-Verbose "Testing medium file upload..."
$uploadResult2 = New-MinIOObject -BucketName $TestBucket -Files (Get-Item $MediumFile) -Verbose
$testResults += [PSCustomObject]@{
Test = "Medium File Upload"
Status = "Success"
Details = "Uploaded medium file: $($uploadResult2.Count) objects"
Result = $uploadResult2
}
# Test 7: Upload large file (multipart)
Write-Verbose "Testing multipart upload..."
$multipartResult = New-MinIOObjectMultipart -BucketName $TestBucket -Files (Get-Item $LargeFile) -Verbose
$testResults += [PSCustomObject]@{
Test = "Multipart Upload"
Status = "Success"
Details = "Multipart upload completed: $($multipartResult.Count) objects"
Result = $multipartResult
}
# Test 8: List objects in bucket
Write-Verbose "Testing object listing..."
$objects = Get-MinIOObject -BucketName $TestBucket -Verbose
$testResults += [PSCustomObject]@{
Test = "List Objects"
Status = "Success"
Details = "Found $($objects.Count) objects in bucket"
Result = $objects
}
# Test 9: Download small file
Write-Verbose "Testing single file download..."
$downloadPath = Join-Path $TestDirectory "downloaded-small.txt"
$downloadResult = Get-MinIOObjectContent -BucketName $TestBucket -ObjectKey "small-test.txt" -FilePath (New-Object System.IO.FileInfo $downloadPath) -Verbose
$testResults += [PSCustomObject]@{
Test = "Single File Download"
Status = "Success"
Details = "Downloaded file: $($downloadResult.FilePath)"
Result = $downloadResult
}
# Test 10: Download large file (multipart)
Write-Verbose "Testing multipart download..."
$downloadPath2 = Join-Path $TestDirectory "downloaded-large.txt"
$multipartDownload = Get-MinIOObjectContentMultipart -BucketName $TestBucket -ObjectKey "large-test.txt" -FilePath (New-Object System.IO.FileInfo $downloadPath2) -Verbose
$testResults += [PSCustomObject]@{
Test = "Multipart Download"
Status = "Success"
Details = "Multipart download completed: $($multipartDownload.FilePath)"
Result = $multipartDownload
}
# Test 11: Generate presigned URL
Write-Verbose "Testing presigned URL generation..."
$presignedUrl = Get-MinIOPresignedUrl -BucketName $TestBucket -ObjectKey "small-test.txt" -Expiration (New-TimeSpan -Hours 1) -Verbose
$testResults += [PSCustomObject]@{
Test = "Presigned URL"
Status = "Success"
Details = "Generated presigned URL"
Result = $presignedUrl
}
} catch {
$testResults += [PSCustomObject]@{
Test = "ERROR"
Status = "Failed"
Details = $_.Exception.Message
Result = $_.ScriptStackTrace
}
} finally {
# Cleanup
Write-Verbose "Cleaning up test resources..."
try {
# Remove local test directory
if (Test-Path $TestDirectory) {
Remove-Item $TestDirectory -Recurse -Force
Write-Verbose "Removed local test directory"
}
} catch {
Write-Warning "Cleanup warning: $($_.Exception.Message)"
}
}
# Output test results
Write-Output "PSMinIO Comprehensive Test Results:"
Write-Output "=================================="
$testResults | Format-Table Test, Status, Details -AutoSize
Write-Output ""
Write-Output "Test bucket '$TestBucket' left for manual cleanup"
Write-Output "Total tests: $($testResults.Count)"
Write-Output "Successful: $(($testResults | Where-Object Status -eq 'Success').Count)"
Write-Output "Failed: $(($testResults | Where-Object Status -eq 'Failed').Count)"
# Return results for further processing
return $testResults
+123
View File
@@ -0,0 +1,123 @@
# PSMinIO Individual Test Commands
# Copy and paste these commands one by one to test functionality
# Test Configuration
$S3Url = "https://api.s3.gracesolution.info"
$AccessKey = "T34Wg85SAwezUa3sk3m4"
$SecretKey = "PxEmnbQoQJTJsDocSEV6mSSscDpJMiJCayPv93xe"
$TestBucket = "psminiotest-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
Write-Output "Test Configuration:"
Write-Output "S3 Endpoint: $S3Url"
Write-Output "Test Bucket: $TestBucket"
Write-Output ""
# ===== STEP 1: IMPORT MODULE =====
Write-Output "1. Import PSMinIO Module:"
Import-Module ".\Module\PSMinIO\PSMinIO.psd1" -Force -Verbose
# ===== STEP 2: CONNECT TO S3 =====
Write-Output "`n2. Connect to S3:"
$connection = Connect-MinIO -Url $S3Url -AccessKey $AccessKey -SecretKey $SecretKey -Verbose
$connection
# ===== STEP 3: LIST EXISTING BUCKETS =====
Write-Output "`n3. List existing buckets:"
$buckets = Get-MinIOBucket -Verbose
$buckets | Format-Table Name, CreationDate, Region -AutoSize
# ===== STEP 4: CREATE TEST BUCKET =====
Write-Output "`n4. Create test bucket:"
$newBucket = New-MinIOBucket -BucketName $TestBucket -Verbose
$newBucket
# ===== STEP 5: VERIFY BUCKET EXISTS =====
Write-Output "`n5. Verify bucket exists:"
$bucketExists = Test-MinIOBucketExists -BucketName $TestBucket -Verbose
Write-Output "Bucket exists: $bucketExists"
# ===== STEP 6: CREATE TEST FILES =====
Write-Output "`n6. Create test files:"
$TestDirectory = "C:\Temp\PSMinIOTest"
if (Test-Path $TestDirectory) { Remove-Item $TestDirectory -Recurse -Force }
New-Item -ItemType Directory -Path $TestDirectory -Force | Out-Null
# Small file (< 1KB)
$SmallFile = Join-Path $TestDirectory "small-test.txt"
"This is a small test file for PSMinIO testing." | Out-File $SmallFile -Encoding UTF8
# Medium file (~50KB)
$MediumFile = Join-Path $TestDirectory "medium-test.txt"
1..1000 | ForEach-Object { "Line $_ - Medium test file content for PSMinIO testing with more data." } | Out-File $MediumFile -Encoding UTF8
# Large file (~500KB)
$LargeFile = Join-Path $TestDirectory "large-test.txt"
1..10000 | ForEach-Object { "Line $_ - Large test file content for PSMinIO multipart testing with substantial data to trigger chunked operations." } | Out-File $LargeFile -Encoding UTF8
Get-ChildItem $TestDirectory | Select-Object Name, @{Name="Size(KB)";Expression={[math]::Round($_.Length/1KB,2)}}
# ===== STEP 7: UPLOAD SMALL FILE (SINGLE PART) =====
Write-Output "`n7. Upload small file (single part):"
$uploadResult1 = New-MinIOObject -BucketName $TestBucket -Files (Get-Item $SmallFile) -Verbose
$uploadResult1
# ===== STEP 8: UPLOAD MEDIUM FILE (SINGLE PART) =====
Write-Output "`n8. Upload medium file (single part):"
$uploadResult2 = New-MinIOObject -BucketName $TestBucket -Files (Get-Item $MediumFile) -Verbose
$uploadResult2
# ===== STEP 9: UPLOAD LARGE FILE (MULTIPART) =====
Write-Output "`n9. Upload large file (multipart):"
$multipartResult = New-MinIOObjectMultipart -BucketName $TestBucket -Files (Get-Item $LargeFile) -Verbose
$multipartResult
# ===== STEP 10: LIST OBJECTS IN BUCKET =====
Write-Output "`n10. List objects in bucket:"
$objects = Get-MinIOObject -BucketName $TestBucket -Verbose
$objects | Format-Table Key, @{Name="Size(KB)";Expression={[math]::Round($_.Size/1KB,2)}}, LastModified -AutoSize
# ===== STEP 11: DOWNLOAD SMALL FILE =====
Write-Output "`n11. Download small file:"
$downloadPath1 = Join-Path $TestDirectory "downloaded-small.txt"
$downloadResult1 = Get-MinIOObjectContent -BucketName $TestBucket -ObjectKey "small-test.txt" -FilePath (New-Object System.IO.FileInfo $downloadPath1) -Verbose
$downloadResult1
# ===== STEP 12: DOWNLOAD LARGE FILE (MULTIPART) =====
Write-Output "`n12. Download large file (multipart):"
$downloadPath2 = Join-Path $TestDirectory "downloaded-large.txt"
$multipartDownload = Get-MinIOObjectContentMultipart -BucketName $TestBucket -ObjectKey "large-test.txt" -FilePath (New-Object System.IO.FileInfo $downloadPath2) -Verbose
$multipartDownload
# ===== STEP 13: GENERATE PRESIGNED URL =====
Write-Output "`n13. Generate presigned URL:"
$presignedUrl = Get-MinIOPresignedUrl -BucketName $TestBucket -ObjectKey "small-test.txt" -Expiration (New-TimeSpan -Hours 1) -Verbose
$presignedUrl
# ===== STEP 14: VERIFY DOWNLOADED FILES =====
Write-Output "`n14. Verify downloaded files:"
Write-Output "Original files:"
Get-ChildItem $TestDirectory -Filter "*test.txt" | Select-Object Name, @{Name="Size(KB)";Expression={[math]::Round($_.Length/1KB,2)}}
Write-Output "`nDownloaded files:"
Get-ChildItem $TestDirectory -Filter "downloaded-*" | Select-Object Name, @{Name="Size(KB)";Expression={[math]::Round($_.Length/1KB,2)}}
# ===== STEP 15: COMPARE FILE CONTENTS =====
Write-Output "`n15. Compare file contents:"
$originalSmall = Get-Content $SmallFile
$downloadedSmall = Get-Content $downloadPath1
Write-Output "Small file content match: $(($originalSmall -join '') -eq ($downloadedSmall -join ''))"
$originalLarge = Get-Content $LargeFile
$downloadedLarge = Get-Content $downloadPath2
Write-Output "Large file content match: $(($originalLarge -join '') -eq ($downloadedLarge -join ''))"
# ===== CLEANUP INSTRUCTIONS =====
Write-Output "`n16. Cleanup (manual):"
Write-Output "Test bucket created: $TestBucket"
Write-Output "Local test directory: $TestDirectory"
Write-Output ""
Write-Output "To clean up:"
Write-Output "1. Remove local directory: Remove-Item '$TestDirectory' -Recurse -Force"
Write-Output "2. Remove S3 bucket objects and bucket manually from S3 console"
Write-Output ""
Write-Output "=== ALL TESTS COMPLETED ==="