simulateDownloadChunks simulates the probe + chunked base64 results for a download.
(mgr *sessions.Manager, sessID string, taskID uint32, originalData []byte, plan sessions.TransferPlan, filePath string)
| 69 | |
| 70 | // simulateDownloadChunks simulates the probe + chunked base64 results for a download. |
| 71 | func simulateDownloadChunks(mgr *sessions.Manager, sessID string, taskID uint32, originalData []byte, plan sessions.TransferPlan, filePath string) { |
| 72 | chunks := sessions.GenerateDownloadChunks(filePath, plan) |
| 73 | go func() { |
| 74 | time.Sleep(100 * time.Millisecond) |
| 75 | // Probe result. |
| 76 | mgr.PublishResult(sessID, &sessions.CommandResult{ |
| 77 | CommandID: "probe", TaskID: taskID, SessionID: sessID, |
| 78 | Output: fmt.Sprintf("%d\n", len(originalData)), Timestamp: time.Now(), |
| 79 | }) |
| 80 | // Each chunk returns base64. |
| 81 | for _, chunk := range chunks { |
| 82 | time.Sleep(30 * time.Millisecond) |
| 83 | end := chunk.Offset + chunk.Size |
| 84 | if end > len(originalData) { |
| 85 | end = len(originalData) |
| 86 | } |
| 87 | b64 := base64.StdEncoding.EncodeToString(originalData[chunk.Offset:end]) |
| 88 | mgr.PublishResult(sessID, &sessions.CommandResult{ |
| 89 | CommandID: "chunk", TaskID: taskID, SessionID: sessID, |
| 90 | Output: b64, Timestamp: time.Now(), |
| 91 | }) |
| 92 | } |
| 93 | }() |
| 94 | } |
| 95 | |
| 96 | // =================================================================== |
| 97 | // gRPC E2E: Chunked Upload 50KB |
no test coverage detected