Test File Upload #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test File Upload | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| test_scenario: | |
| description: 'Test scenario to run' | |
| required: true | |
| default: 'single-file' | |
| type: choice | |
| options: | |
| - single-file | |
| - multiple-files | |
| - directory | |
| - wildcard-patterns | |
| - large-files | |
| - large-multipart-test | |
| bucket: | |
| description: 'OBS bucket name for testing' | |
| required: false | |
| type: string | |
| region: | |
| description: 'OBS region' | |
| required: false | |
| default: 'cn-north-4' | |
| type: string | |
| env: | |
| OBS_BUCKET: ${{ inputs.bucket || secrets.OBS_BUCKET }} | |
| OBS_ACCESS_KEY: ${{ secrets.OBS_ACCESS_KEY }} | |
| OBS_SECRET_KEY: ${{ secrets.OBS_SECRET_KEY }} | |
| OBS_REGION: ${{ inputs.region || 'cn-north-4' }} | |
| jobs: | |
| test-upload: | |
| runs-on: ubuntu-latest | |
| name: Test Upload - ${{ inputs.test_scenario }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Setup test environment | |
| run: | | |
| # Make script executable and run it | |
| chmod +x generate-test-files.sh | |
| ./generate-test-files.sh | |
| - name: Create large test file (>1GB) for multipart upload testing | |
| if: inputs.test_scenario == 'large-files' || inputs.test_scenario == 'large-multipart-test' | |
| run: | | |
| echo "π₯ Creating large test file (>1GB) for multipart upload testing..." | |
| # Create a 1.2GB test file using dd with /dev/zero for speed | |
| # This will trigger the multipart upload functionality | |
| dd if=/dev/zero of=test-files/large-multipart-test.bin bs=1M count=1200 status=progress | |
| # Verify file size | |
| FILE_SIZE=$(stat -c%s test-files/large-multipart-test.bin) | |
| FILE_SIZE_MB=$((FILE_SIZE / 1024 / 1024)) | |
| echo "β Created large test file: ${FILE_SIZE_MB}MB (${FILE_SIZE} bytes)" | |
| # This should be larger than 1GB threshold (1073741824 bytes) | |
| if [ $FILE_SIZE -gt 1073741824 ]; then | |
| echo "π― File size exceeds 1GB threshold - will trigger multipart upload" | |
| else | |
| echo "β οΈ File size is below 1GB threshold - multipart upload may not be triggered" | |
| fi | |
| # List all test files for verification | |
| echo "π All test files created:" | |
| ls -lh test-files/ | |
| - name: Test Single File Upload | |
| id: upload_single | |
| if: inputs.test_scenario == 'single-file' | |
| uses: ./ | |
| with: | |
| access_key: ${{ env.OBS_ACCESS_KEY }} | |
| secret_key: ${{ env.OBS_SECRET_KEY }} | |
| region: ${{ env.OBS_REGION }} | |
| bucket: ${{ env.OBS_BUCKET }} | |
| operation: upload | |
| local_path: test-files/simple.txt | |
| obs_path: test-uploads/single/ | |
| progress: true | |
| dry_run: false | |
| - name: Test Multiple Files Upload | |
| id: upload_multiple | |
| if: inputs.test_scenario == 'multiple-files' | |
| uses: ./ | |
| with: | |
| access_key: ${{ env.OBS_ACCESS_KEY }} | |
| secret_key: ${{ env.OBS_SECRET_KEY }} | |
| region: ${{ env.OBS_REGION }} | |
| bucket: ${{ env.OBS_BUCKET }} | |
| operation: upload | |
| local_path: test-files/documents/doc1.txt,test-files/documents/doc2.txt,test-files/images/image1.jpg | |
| obs_path: test-uploads/multiple/ | |
| progress: true | |
| concurrency: 3 | |
| - name: Test Directory Upload | |
| id: upload_directory | |
| if: inputs.test_scenario == 'directory' | |
| uses: ./ | |
| with: | |
| access_key: ${{ env.OBS_ACCESS_KEY }} | |
| secret_key: ${{ env.OBS_SECRET_KEY }} | |
| region: ${{ env.OBS_REGION }} | |
| bucket: ${{ env.OBS_BUCKET }} | |
| operation: upload | |
| local_path: test-files/ | |
| obs_path: test-uploads/directory/ | |
| preserve_structure: true | |
| progress: true | |
| concurrency: 5 | |
| - name: Test Wildcard Patterns Upload | |
| id: upload_wildcard | |
| if: inputs.test_scenario == 'wildcard-patterns' | |
| uses: ./ | |
| with: | |
| access_key: ${{ env.OBS_ACCESS_KEY }} | |
| secret_key: ${{ env.OBS_SECRET_KEY }} | |
| region: ${{ env.OBS_REGION }} | |
| bucket: ${{ env.OBS_BUCKET }} | |
| operation: upload | |
| local_path: test-files/**/*.txt | |
| obs_path: test-uploads/wildcard/ | |
| exclude: "*.bin,*large*" | |
| preserve_structure: true | |
| progress: true | |
| - name: Test Large Files Upload | |
| id: upload_large | |
| if: inputs.test_scenario == 'large-files' | |
| uses: ./ | |
| with: | |
| access_key: ${{ env.OBS_ACCESS_KEY }} | |
| secret_key: ${{ env.OBS_SECRET_KEY }} | |
| region: ${{ env.OBS_REGION }} | |
| bucket: ${{ env.OBS_BUCKET }} | |
| operation: upload | |
| local_path: test-files/large-file.bin | |
| obs_path: test-uploads/large/ | |
| progress: true | |
| checksum_validation: true | |
| storage_class: STANDARD | |
| retry_count: 5 | |
| - name: Test Large Multipart Upload (>1GB) | |
| id: upload_multipart | |
| if: inputs.test_scenario == 'large-files' || inputs.test_scenario == 'large-multipart-test' | |
| uses: ./ | |
| with: | |
| access_key: ${{ env.OBS_ACCESS_KEY }} | |
| secret_key: ${{ env.OBS_SECRET_KEY }} | |
| region: ${{ env.OBS_REGION }} | |
| bucket: ${{ env.OBS_BUCKET }} | |
| operation: upload | |
| local_path: test-files/large-multipart-test.bin | |
| obs_path: test-uploads/multipart/ | |
| progress: true | |
| checksum_validation: true | |
| storage_class: STANDARD | |
| retry_count: 3 | |
| timeout: 1800000 # 30 minutes timeout for large uploads | |
| - name: Display Upload URLs and Outputs | |
| if: always() | |
| run: | | |
| echo "## π Upload URLs and Action Outputs" | |
| echo "" | |
| # Single File Upload Results | |
| if [ "${{ inputs.test_scenario }}" = "single-file" ]; then | |
| echo "### π Single File Upload Results" | |
| echo "**Files processed:** ${{ steps.upload_single.outputs.files_processed || '0' }}" | |
| echo "**Bytes transferred:** ${{ steps.upload_single.outputs.bytes_transferred || '0' }}" | |
| echo "**Success count:** ${{ steps.upload_single.outputs.success_count || '0' }}" | |
| echo "**Error count:** ${{ steps.upload_single.outputs.error_count || '0' }}" | |
| echo "**First upload URL:** ${{ steps.upload_single.outputs.first_upload_url || 'Not available' }}" | |
| echo "**All upload URLs:** ${{ steps.upload_single.outputs.upload_urls || '[]' }}" | |
| echo "" | |
| fi | |
| # Multiple Files Upload Results | |
| if [ "${{ inputs.test_scenario }}" = "multiple-files" ]; then | |
| echo "### π Multiple Files Upload Results" | |
| echo "**Files processed:** ${{ steps.upload_multiple.outputs.files_processed || '0' }}" | |
| echo "**Bytes transferred:** ${{ steps.upload_multiple.outputs.bytes_transferred || '0' }}" | |
| echo "**Success count:** ${{ steps.upload_multiple.outputs.success_count || '0' }}" | |
| echo "**Error count:** ${{ steps.upload_multiple.outputs.error_count || '0' }}" | |
| echo "**First upload URL:** ${{ steps.upload_multiple.outputs.first_upload_url || 'Not available' }}" | |
| echo "**All upload URLs:** ${{ steps.upload_multiple.outputs.upload_urls || '[]' }}" | |
| echo "" | |
| fi | |
| # Directory Upload Results | |
| if [ "${{ inputs.test_scenario }}" = "directory" ]; then | |
| echo "### π Directory Upload Results" | |
| echo "**Files processed:** ${{ steps.upload_directory.outputs.files_processed || '0' }}" | |
| echo "**Bytes transferred:** ${{ steps.upload_directory.outputs.bytes_transferred || '0' }}" | |
| echo "**Success count:** ${{ steps.upload_directory.outputs.success_count || '0' }}" | |
| echo "**Error count:** ${{ steps.upload_directory.outputs.error_count || '0' }}" | |
| echo "**First upload URL:** ${{ steps.upload_directory.outputs.first_upload_url || 'Not available' }}" | |
| echo "**All upload URLs:** ${{ steps.upload_directory.outputs.upload_urls || '[]' }}" | |
| echo "" | |
| fi | |
| # Wildcard Patterns Upload Results | |
| if [ "${{ inputs.test_scenario }}" = "wildcard-patterns" ]; then | |
| echo "### π― Wildcard Patterns Upload Results" | |
| echo "**Files processed:** ${{ steps.upload_wildcard.outputs.files_processed || '0' }}" | |
| echo "**Bytes transferred:** ${{ steps.upload_wildcard.outputs.bytes_transferred || '0' }}" | |
| echo "**Success count:** ${{ steps.upload_wildcard.outputs.success_count || '0' }}" | |
| echo "**Error count:** ${{ steps.upload_wildcard.outputs.error_count || '0' }}" | |
| echo "**First upload URL:** ${{ steps.upload_wildcard.outputs.first_upload_url || 'Not available' }}" | |
| echo "**All upload URLs:** ${{ steps.upload_wildcard.outputs.upload_urls || '[]' }}" | |
| echo "" | |
| fi | |
| # Large Files Upload Results | |
| if [ "${{ inputs.test_scenario }}" = "large-files" ]; then | |
| echo "### π Large Files Upload Results" | |
| echo "**Files processed:** ${{ steps.upload_large.outputs.files_processed || '0' }}" | |
| echo "**Bytes transferred:** ${{ steps.upload_large.outputs.bytes_transferred || '0' }}" | |
| echo "**Success count:** ${{ steps.upload_large.outputs.success_count || '0' }}" | |
| echo "**Error count:** ${{ steps.upload_large.outputs.error_count || '0' }}" | |
| echo "**First upload URL:** ${{ steps.upload_large.outputs.first_upload_url || 'Not available' }}" | |
| echo "**All upload URLs:** ${{ steps.upload_large.outputs.upload_urls || '[]' }}" | |
| echo "" | |
| echo "### π¦ Multipart Upload Results" | |
| echo "**Files processed:** ${{ steps.upload_multipart.outputs.files_processed || '0' }}" | |
| echo "**Bytes transferred:** ${{ steps.upload_multipart.outputs.bytes_transferred || '0' }}" | |
| echo "**Success count:** ${{ steps.upload_multipart.outputs.success_count || '0' }}" | |
| echo "**Error count:** ${{ steps.upload_multipart.outputs.error_count || '0' }}" | |
| echo "**First upload URL:** ${{ steps.upload_multipart.outputs.first_upload_url || 'Not available' }}" | |
| echo "**All upload URLs:** ${{ steps.upload_multipart.outputs.upload_urls || '[]' }}" | |
| echo "" | |
| fi | |
| # Large Multipart Test Results | |
| if [ "${{ inputs.test_scenario }}" = "large-multipart-test" ]; then | |
| echo "### π¦ Large Multipart Upload Test Results" | |
| echo "**Files processed:** ${{ steps.upload_multipart.outputs.files_processed || '0' }}" | |
| echo "**Bytes transferred:** ${{ steps.upload_multipart.outputs.bytes_transferred || '0' }}" | |
| echo "**Success count:** ${{ steps.upload_multipart.outputs.success_count || '0' }}" | |
| echo "**Error count:** ${{ steps.upload_multipart.outputs.error_count || '0' }}" | |
| echo "**First upload URL:** ${{ steps.upload_multipart.outputs.first_upload_url || 'Not available' }}" | |
| echo "**All upload URLs:** ${{ steps.upload_multipart.outputs.upload_urls || '[]' }}" | |
| echo "" | |
| fi | |
| echo "---" | |
| echo "" | |
| echo "### π How to Use These URLs" | |
| echo "- **Direct URLs** (for public files): Can be accessed directly in browser" | |
| echo "- **Signed URLs** (for private files): Valid for 1 hour, provide temporary access" | |
| echo "- **JSON Array**: Contains all upload URLs in JSON format for parsing" | |
| echo "- **First URL**: Convenience output for single file uploads" | |
| echo "" | |
| - name: Verify Upload Results | |
| run: | | |
| echo "## π― Upload Test Results Summary" | |
| echo "Upload test completed for scenario: ${{ inputs.test_scenario }}" | |
| echo "" | |
| if [ "${{ inputs.test_scenario }}" = "large-files" ] || [ "${{ inputs.test_scenario }}" = "large-multipart-test" ]; then | |
| echo "### π Large File Upload Test" | |
| echo "- β 1.2GB test file created and uploaded" | |
| echo "- π§ Multipart upload should have been triggered automatically" | |
| echo "- π Check logs above for multipart upload messages:" | |
| echo " - Look for: 'π¦ Large file detected (1200MB), using multipart upload'" | |
| echo " - Look for: 'π¦ Multipart upload initialized'" | |
| echo " - Look for: 'π¦ Part X uploaded'" | |
| echo " - Look for: 'β Large file uploaded successfully'" | |
| echo "" | |
| echo "### π What to Verify in OBS:" | |
| echo "- File should be uploaded to: test-uploads/multipart/large-multipart-test.bin" | |
| echo "- File size should be exactly 1,258,291,200 bytes (1.2GB)" | |
| echo "- No 403 Forbidden errors should occur" | |
| fi | |
| echo "Check the action outputs and OBS bucket for uploaded files" | |
| - name: Cleanup Test Files | |
| if: always() | |
| run: | | |
| echo "π§Ή Cleaning up test files..." | |
| # Show space usage before cleanup | |
| echo "Disk usage before cleanup:" | |
| df -h | |
| # Remove test files | |
| rm -rf test-files/ | |
| echo "β Test files cleaned up" | |
| # Show space usage after cleanup | |
| echo "Disk usage after cleanup:" | |
| df -h |