main.go
 1  package main
 2  
 3  import (
 4  	"context"
 5  	"fmt"
 6  	"os"
 7  
 8  	"keepSync/internal/providers"
 9  )
10  
11  func main() {
12  	fmt.Println("๐Ÿงช Testing Enhanced Chunking Strategy")
13  
14  	// Test different file sizes to verify chunking behavior
15  	testCases := []struct {
16  		name     string
17  		size     int
18  		expected string
19  	}{
20  		{"Small file (50KB)", 50 * 1024, "100KB chunks"},
21  		{"Medium file (500KB)", 500 * 1024, "100KB chunks"},
22  		{"Large file (2MB)", 2 * 1024 * 1024, "1MB chunks"},
23  		{"Very large file (10MB)", 10 * 1024 * 1024, "5MB chunks"},
24  	}
25  
26  	for _, tc := range testCases {
27  		fmt.Printf("\n๐Ÿ“ฆ Testing %s (%d bytes) - Expected: %s\n", tc.name, tc.size, tc.expected)
28  
29  		// Create test file
30  		testFile := fmt.Sprintf("/tmp/test-chunking-%d.txt", tc.size)
31  		content := make([]byte, tc.size)
32  		for i := range content {
33  			content[i] = byte(i % 256)
34  		}
35  
36  		if err := os.WriteFile(testFile, content, 0644); err != nil {
37  			fmt.Printf("โŒ Failed to create test file: %v\n", err)
38  			continue
39  		}
40  		defer os.Remove(testFile)
41  
42  		// Create quantum S3 provider with real credentials from environment
43  		config := providers.QuantumS3Config{
44  			Bucket:         "storage-a01",
45  			Region:         "us-east-1",
46  			AccessKey:      os.Getenv("AWS_ACCESS_KEY_ID"),
47  			SecretKey:      os.Getenv("AWS_SECRET_ACCESS_KEY"),
48  			Endpoint:       os.Getenv("AWS_ENDPOINT_URL"),
49  			EnableChunking: true,
50  			ChunkSizeMB:    5, // 5MB default
51  		}
52  
53  		provider, err := providers.NewQuantumS3Provider(config)
54  		if err != nil {
55  			fmt.Printf("โŒ Failed to create provider: %v\n", err)
56  			continue
57  		}
58  		defer provider.Close()
59  
60  		// Test upload (this will show chunking behavior in logs)
61  		remotePath := fmt.Sprintf("test-chunking-%d.txt", tc.size)
62  		fmt.Printf("๐Ÿ”„ Uploading %s...\n", testFile)
63  
64  		err = provider.Upload(context.Background(), testFile, remotePath)
65  		if err != nil {
66  			fmt.Printf("โŒ Upload failed: %v\n", err)
67  		} else {
68  			fmt.Printf("โœ… Upload completed successfully\n")
69  		}
70  	}
71  
72  	fmt.Println("\n๐ŸŽ‰ Enhanced chunking strategy test completed!")
73  }