-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathzboxcli_file_upload_test.go
1100 lines (912 loc) · 39.5 KB
/
zboxcli_file_upload_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package cli_tests
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"os"
"os/exec"
"path"
"path/filepath"
"regexp"
"strconv"
"strings"
"sync"
"testing"
"time"
"github.com/0chain/system_test/tests/tokenomics_tests/utils"
"github.com/0chain/system_test/internal/api/util/test"
"github.com/stretchr/testify/require"
climodel "github.com/0chain/system_test/internal/cli/model"
cliutils "github.com/0chain/system_test/internal/cli/util"
)
func TestUpload(testSetup *testing.T) {
t := test.NewSystemTest(testSetup)
t.SetSmokeTests("Upload File With half Size of the Allocation Should Work")
t.Parallel()
// Success Scenarios
t.Run("Upload File With half Size of the Allocation Should Work", func(t *test.SystemTest) {
allocSize := int64(1 * MB)
fileSize := int64(512 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"parity": 1,
"data": 1,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
})
t.Run("Upload multiple files less than size of the Allocation Should Work", func(t *test.SystemTest) {
allocSize := int64(1 * MB)
fileSize := int64(256 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"parity": 1,
"data": 1,
})
for i := 0; i < 2; i++ {
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
}
})
t.Run("Upload File to Root Directory Should Work", func(t *test.SystemTest) { // todo: slow
const allocSize int64 = 64 * KB * 2
const fileSize int64 = 64 * KB
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
})
t.RunWithTimeout("Upload file concurrently to root directory, should work", 6*time.Minute, func(t *test.SystemTest) { // todo: slow
const allocSize int64 = 64 * KB * 4
const fileSize int64 = 64 * KB
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
const remotePathPrefix = "/"
var fileNames [2]string
var outputList [2][]string
var errorList [2]error
var wg sync.WaitGroup
for i := 0; i < 2; i++ {
wg.Add(1)
go func(currentIndex int) {
defer wg.Done()
fileName := generateRandomTestFileName(t)
err := createFileWithSize(fileName, fileSize)
require.Nil(t, err)
fileNameBase := filepath.Base(fileName)
fileNames[currentIndex] = fileNameBase
op, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": path.Join(remotePathPrefix, fileNameBase),
"localpath": fileName,
}, true)
errorList[currentIndex] = err
outputList[currentIndex] = op
}(i)
}
wg.Wait()
const expectedPattern = "Status completed callback. Type = text/plain. Name = %s"
for i := 0; i < 2; i++ {
require.Nil(t, errorList[i], strings.Join(outputList[i], "\n"))
require.Len(t, outputList[i], 2, strings.Join(outputList[i], "\n"))
require.Equal(t, fmt.Sprintf(expectedPattern, fileNames[i]), outputList[i][1], "Output is not appropriate")
}
})
t.Run("Upload File to a Directory Should Work", func(t *test.SystemTest) {
allocSize := int64(64 * KB * 2)
fileSize := int64(64 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/dir/" + filepath.Base(filename),
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
})
t.RunWithTimeout("Upload File to a Directory without Filename Should Work", 60*time.Second, func(t *test.SystemTest) {
allocSize := int64(64 * KB * 2)
fileSize := int64(64 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/dir/",
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := "Status completed callback. Type = text/plain. Name = " + filepath.Base(filename)
require.Equal(t, expected, output[1])
output, err = listFilesInAllocation(t, configPath, createParams(map[string]interface{}{
"allocation": allocationID,
"remotepath": "/dir/",
"json": "",
}), true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
var listResults []climodel.ListFileResult
err = json.Unmarshal([]byte(output[0]), &listResults)
require.Nil(t, err, "Decoding list results failed\n", strings.Join(output, "\n"))
require.Len(t, listResults, 1)
result := listResults[0]
require.Equal(t, filepath.Base(filename), result.Name)
require.Equal(t, "/dir/"+filepath.Base(filename), result.Path)
require.Equal(t, fileSize, result.ActualSize)
require.Equal(t, "f", result.Type)
require.Equal(t, "", result.EncryptionKey)
})
t.Run("Upload File to Nested Directory Should Work", func(t *test.SystemTest) {
allocSize := int64(64 * KB * 2)
fileSize := int64(64 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/nested/dir/" + filepath.Base(filename),
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
})
t.Run("Upload File with Thumbnail Should Work", func(t *test.SystemTest) {
allocSize := int64(64 * 1024 * 1024)
fileSize := int64(64 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
thumbnail := escapedTestName(t) + "thumbnail.png"
_ = generateThumbnail(t, thumbnail) // nolint
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
"thumbnailpath": thumbnail,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
})
t.RunWithTimeout("Upload tests with Thumbnail with different format", 40*time.Minute, func(t *test.SystemTest) {
t.Skip("Need improvements in performance")
for _, blobber := range blobbersList {
// stake tokens
_, err := stakeTokens(t, configPath, utils.CreateParams(map[string]interface{}{
"blobber_id": blobber.Id,
"tokens": 10,
}), true)
require.Nil(t, err, "Error staking tokens")
}
allocSize := int64(10 * GB)
var fileExtensions = []string{".txt", ".docx", ".pdf", ".jpg", ".png", ".mp3", ".mp4", ".xlsx", ".html", ".json", ".csv", ".xml", ".zip", ".rar", ".gz", ".tar", ".avi", ".mov", ".wav", ".ogg", ".bmp", ".gif", ".svg", ".tiff", ".ico", ".py", ".c", ".java", ".php", ".js", ".css", ".scss", ".yaml", ".sql", ".md", ".go", ".rb", ".cpp", ".h", ".sh", ".bat", ".dll", ".class", ".jar", ".exe", ".psd", ".pptx", ".xls", ".ppt", ".key", ".numbers"}
fileSize := int64(5 * MB) // 5MB
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"data": 3,
"parity": 3,
})
// Upload files
for _, ext := range fileExtensions {
filename := generateRandomTestFileName(t) + ext
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
thumbnail := escapedTestName(t) + "thumbnail.png"
_ = generateThumbnail(t, thumbnail) // nolint
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
"thumbnailpath": thumbnail,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1], "Failed to upload file with extension: "+ext+" output : "+strings.Join(output, "\n"))
}
})
t.Run("Upload Image File Should Work", func(t *test.SystemTest) {
allocSize := int64(64 * 1024 * 1024)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
filename := escapedTestName(t) + "image.png"
//nolint
fileBytes, _ := base64.StdEncoding.DecodeString(`iVBORw0KGgoAAAANSUhEUgAAANgAAADpCAMAAABx2AnXAAAAwFBMVEX///8REiQAAADa2ttlZWWlpaU5OTnIyMiIiIhzc3ODg4OVlZXExMT6+vr39/fOzs7v7+9dXV0rKyvf399GRkbn5+dBQUEREREAABp5eXmxsbFsbGxaWlqfn59gYGC4uLgAABWrq6sAAByXl5dOTk4LCwscHBwvLy88PDwkJCR5eYGUlJpBQUxtbnYAAA8ZGyojJTNiY2sAAB82N0OFhYxSU10uLjxKSlQeHy1+f4ebnaRNUFmLjZNdXWWqq7JoaXKY6lzbAAAMKUlEQVR4nO2dC1u6PhvHETARORlhchA8ZYVa+tM0+2u9/3f17N5AUdG0ELBnn666pgzal+3e4d4GDEOhUCgUCoVCoVAoFAqFQqFQKBQKhUKhUCiUP4pqPrNst2NknY6E0Rw2oJh1Us7FsIotST508IFdY6aarN+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N6kYzjknKpZom60UV1794nVo56byinbBUCgUCoVCoVAoFAqFQqFQKBQK5fJwfxQmZuf/n4Ap/FGosGvjqLB6e+tT8HsdBMIm6Hf0ugljmqu35mz96XVeL4xWk8KVQIS1v8b15rLZbBbqTXb5Wm826yjQ+vz8HH6wLyxbqLPsTGXZyXSQcXpPJsix92XzfeH3p+yi7y/6s37fn3/8x/3HskNtteTU2YDj5tKAmw1SzbF6XMnfMY92uw3fwd961FQCYc1l4Ws4bA6HY5ad/lsW2KH/9jJQ9cWwP1LZ8ac0YUcGF/uPLsdsuJq811/fB81RuzBY/jeoj+qF1ylK/gz9FF7fm+PV9G25mE9Xk+V4OZuu2M+2v6hHhdVRlFV//OUP6s3pv4+X5td03n5h29yiM/fYiVd6eRkZ6qh9JBnJ0576w8/hdP658v3PwXLyOfS/lnNvyPqr4XDR7y/GPuu/fS5Zf7zq+NNFcfhWZP2vdlRYof3pvy/rs1G/8L4aD1eF/uqt/TFcllDx44aS3/f8QWnOvaQqrL5AyubLwYc/XnZmX8uP6XjxMfmcjpbzxbj/tZx8vPn+YPkxHE6m1r/+23LpS7NVv7ktbPjeni39+mjpv4zZr+n7bFZ/qyzqzdX8X3/18jLsz4bsMOWqAxW2QWE2eS0MUNEbtGdtVCgno9mkOa8P6u+jwmA0exvMXtGfl9Fo0pyNXkbtMInrdgwyEGyoWQeLxKrbzTr+rgmGiSrMPLZi9fWfHf4/ex7XDBV2bfwPF18HmekEj6sAAAAASUVORK5CYII=`)
err := os.WriteFile(filename, fileBytes, os.ModePerm) //nolint:gosec
require.Nil(t, err, "failed to generate thumbnail", err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = image/png. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
})
t.RunWithTimeout("Upload Video File Should Work", 2*time.Minute, func(t *test.SystemTest) { //todo: slow
allocSize := int64(400 * 1024 * 1024)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"lock": 9,
})
output, err := cliutils.RunCommand(t, "wget http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4 -O test_video.mp4", 3, 2*time.Second)
require.Nil(t, err, "Failed to download test video file: ", strings.Join(output, "\n"))
output, err = uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": "./test_video.mp4",
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := "Status completed callback. Type = video/mp4. Name = test_video.mp4"
require.Equal(t, expected, output[1])
})
t.RunWithTimeout("Upload Large File Should Work", 6*time.Minute, func(t *test.SystemTest) { // todo: this is slow, see https://0chain.slack.com/archives/G014PQ61WNT/p1669672933550459
allocSize := int64(2 * GB)
fileSize := int64(1 * GB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"lock": 50,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
"chunknumber": 1024, // 64KB * 1024 = 64M
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
})
t.Run("Upload File with Encryption Should Work", func(t *test.SystemTest) {
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": 64 * KB * 2,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, 10)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"localpath": filename,
"remotepath": "/",
"encrypt": "",
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
})
t.Run("Data shards do not require more allocation space", func(t *test.SystemTest) {
allocSize := int64(1 * MB)
fileSize := int64(512 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"parity": 1,
"data": 2,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Greater(t, len(output), 1, "Output length was less than expected")
require.True(t, strings.HasPrefix(output[len(output)-1], "Status completed callback"), "Expected success string to be present")
})
// Failure Scenarios
// FIXME: the CLI could check allocation size before attempting an upload to save wasted time/bandwidth
t.Run("Upload File too large - file size larger than allocation should fail", func(t *test.SystemTest) {
allocSize := int64(1 * MB)
fileSize := int64(2 * MB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"parity": 1,
"data": 1,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, false)
require.NotNil(t, err, strings.Join(output, "\n"))
require.True(t, strings.Contains(strings.Join(output, "\n"), "max_allocation_size"), strings.Join(output, "\n"))
})
t.Run("Upload 100% of the allocation should work", func(t *test.SystemTest) {
allocSize := int64(1 * MB)
fileSize := int64(1 * MB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"parity": 1,
"data": 1,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, false)
require.Nil(t, err, strings.Join(output, "\n"))
require.False(t, strings.Contains(strings.Join(output, "\n"), "Upload failed"), strings.Join(output, "\n"))
})
t.Run("Upload File to Existing File Should Fail", func(t *test.SystemTest) {
allocSize := int64(64 * KB * 2)
fileSize := int64(1024)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
// Upload the file again to same directory
output, err = uploadFileWithoutRetry(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
})
require.NotNil(t, err, strings.Join(output, "\n"))
require.True(t, strings.Contains(strings.Join(output, ""), "Upload failed"), strings.Join(output, "\n"))
})
t.Run("Upload File to Non-Existent Allocation Should Fail", func(t *test.SystemTest) {
fileSize := int64(256)
createWallet(t)
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFileWithoutRetry(t, configPath, map[string]interface{}{
"allocation": "ab12mn34as90",
"remotepath": "/",
"localpath": filename,
})
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
expected := "Error fetching the allocation. allocation_fetch_error: " +
"Error fetching the allocation.internal_error: can't get allocation: error retrieving allocation: ab12mn34as90, error: record not found"
require.Equal(t, expected, output[0])
})
t.Run("Upload File to Other's Allocation Should Fail", func(t *test.SystemTest) {
var otherAllocationID string
allocSize := int64(64 * KB * 2)
fileSize := int64(256)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
filename := generateRandomTestFileName(t)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
t.Run("Get Other Allocation ID", func(t *test.SystemTest) {
otherAllocationID = setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
})
// Upload using allocationID: should work
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := fmt.Sprintf(
"Status completed callback. Type = text/plain. Name = %s",
filepath.Base(filename),
)
require.Equal(t, expected, output[1])
// Upload using otherAllocationID: should not work
output, err = uploadFileWithoutRetry(t, configPath, map[string]interface{}{
"allocation": otherAllocationID,
"remotepath": "/",
"localpath": filename,
})
require.NotNil(t, err, strings.Join(output, "\n"))
require.True(t,
strings.Contains(strings.Join(output, ""), "Upload failed"), strings.Join(output, "\n"))
})
t.Run("Upload Non-Existent File Should Fail", func(t *test.SystemTest) {
allocSize := int64(64 * KB * 2)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
})
filename := "non-existent-file.txt"
output, err := uploadFileWithoutRetry(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": "non-existent-file.txt",
})
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
expected := fmt.Sprintf(
"Upload failed. open %s: no such file or directory",
filename,
)
require.Equal(t, expected, output[0])
})
t.Run("Upload without any Parameter Should Fail", func(t *test.SystemTest) {
createWallet(t)
output, err := uploadFileWithoutRetry(t, configPath, nil)
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Equal(t, "Error: allocation flag is missing", output[0])
})
t.Run("Upload to Allocation without remotepath and authticket Should Fail", func(t *test.SystemTest) {
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": 64 * KB * 2,
})
output, err := uploadFileWithoutRetry(t, configPath, map[string]interface{}{
"allocation": allocationID,
})
require.NotNil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 1)
require.Equal(t, "Error: multiuploadjson or remotepath/localpath flag is missing", output[0])
})
t.Run("Upload File longer than 150 chars should fail", func(t *test.SystemTest) {
allocSize := int64(1 * MB)
fileSize := int64(512 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"parity": 1,
"data": 1,
})
dirPath := strings.TrimSuffix(os.TempDir(), string(os.PathSeparator))
randomFilename := cliutils.RandomAlphaNumericString(151)
filename := fmt.Sprintf("%s%s%s_test.txt", dirPath, string(os.PathSeparator), randomFilename)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, false)
require.NotNil(t, err, "error uploading file")
require.Len(t, output, 1)
require.Contains(t, output[0], "filename is longer than 150 characters")
})
t.Run("Upload File should fail if upload file option is forbidden", func(t *test.SystemTest) {
allocSize := int64(1 * MB)
fileSize := int64(512 * KB)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"forbid_upload": nil,
})
dirPath := strings.TrimSuffix(os.TempDir(), string(os.PathSeparator))
randomFilename := cliutils.RandomAlphaNumericString(101)
filename := fmt.Sprintf("%s%s%s_test.txt", dirPath, string(os.PathSeparator), randomFilename)
err := createFileWithSize(filename, fileSize)
require.Nil(t, err)
output, err := uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": filename,
}, false)
require.NotNil(t, err)
require.Len(t, output, 1)
require.Contains(t, output[0], "this options for this file is not permitted for this allocation")
output, err = listFilesInAllocation(t, configPath, createParams(map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
}), false)
require.Nil(t, err)
require.NotContains(t, output[0], filename)
})
t.RunWithTimeout("Tokens should move from write pool balance to challenge pool acc. to expected upload cost", 10*time.Minute, func(t *test.SystemTest) {
createWallet(t)
allocParam := createParams(map[string]interface{}{
"lock": 0.8,
"size": 10485760,
})
output, err := createNewAllocation(t, configPath, allocParam)
require.Nil(t, err, "Failed to create new allocation", strings.Join(output, "\n"))
require.Len(t, output, 1)
matcher := regexp.MustCompile("Allocation created: ([a-f0-9]{64})")
require.Regexp(t, matcher, output[0], "Allocation creation output did not match expected")
allocationID := strings.Fields(output[0])[2]
// Write pool balance should increment to 1
initialAllocation := getAllocation(t, allocationID)
require.Equal(t, 0.8, intToZCN(initialAllocation.WritePool))
// Get Challenge-Pool info after upload
output, err = challengePoolInfo(t, configPath, allocationID)
require.Nil(t, err, "Could not fetch challenge pool", strings.Join(output, "\n"))
challengePool := climodel.ChallengePoolInfo{}
err = json.Unmarshal([]byte(output[0]), &challengePool)
require.Nil(t, err, "Error unmarshalling challenge pool info", strings.Join(output, "\n"))
filename := generateRandomTestFileName(t)
err = createFileWithSize(filename, 1024*1024*0.5)
require.Nil(t, err, "error while generating file: ", err)
// upload a dummy 5 MB file
uploadWithParam(t, configPath, map[string]interface{}{
"allocation": allocationID,
"localpath": filename,
"remotepath": "/",
})
output, _ = getUploadCostInUnit(t, configPath, allocationID, filename)
expectedUploadCostInZCN, err := strconv.ParseFloat(strings.Fields(output[0])[0], 64)
require.Nil(t, err, "Cost couldn't be parsed to float", strings.Join(output, "\n"))
unit := strings.Fields(output[0])[1]
expectedUploadCostInZCN = unitToZCN(expectedUploadCostInZCN, unit)
cliutils.Wait(t, 30*time.Second)
finalAllocation := getAllocation(t, allocationID)
// Get Challenge-Pool info after upload
output, err = challengePoolInfo(t, configPath, allocationID)
require.Nil(t, err, "Could not fetch challenge pool", strings.Join(output, "\n"))
challengePool = climodel.ChallengePoolInfo{}
err = json.Unmarshal([]byte(output[0]), &challengePool)
require.Nil(t, err, "Error unmarshalling challenge pool info", strings.Join(output, "\n"))
require.Regexp(t, regexp.MustCompile(fmt.Sprintf("([a-f0-9]{64}):challengepool:%s", allocationID)), challengePool.Id)
require.IsType(t, int64(1), challengePool.StartTime)
require.IsType(t, int64(1), challengePool.Expiration)
require.IsType(t, int64(1), challengePool.Balance)
require.False(t, challengePool.Finalized)
totalChangeInWritePool := intToZCN(initialAllocation.WritePool - finalAllocation.WritePool)
require.InEpsilon(t, expectedUploadCostInZCN, totalChangeInWritePool, 0.05, "expected write pool balance to decrease by [%v] but has actually decreased by [%v]", expectedUploadCostInZCN, totalChangeInWritePool)
require.InEpsilon(t, totalChangeInWritePool, intToZCN(challengePool.Balance), 0.05, "expected challenge pool balance to match deducted amount from write pool [%v] but balance was actually [%v]", totalChangeInWritePool, intToZCN(challengePool.Balance))
})
t.RunSequentiallyWithTimeout("stream tests for different formats", 20*time.Minute, func(t *test.SystemTest) {
sampleVideos := [][]string{
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/wtv/sample_960x400_ocean_with_audio.wtv",
"test_wtv_video",
"wtv",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/mts/sample_960x400_ocean_with_audio.mts",
"test_mts_video",
"mts",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/f4v/sample_960x400_ocean_with_audio.f4v",
"test_f4v_video",
"f4v",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/flv/sample_960x400_ocean_with_audio.flv",
"test_flv_video",
"flv",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/3gp/sample_960x400_ocean_with_audio.3gp",
"test_3gp_video",
"3gp",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/m4v/sample_960x400_ocean_with_audio.m4v",
"test_m4v_video",
"m4v",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/mov/sample_960x400_ocean_with_audio.mov",
"test_mov_video",
"mov",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/mp4/sample_960x400_ocean_with_audio.mp4",
"test_mp4_video",
"mp4",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/mjpeg/sample_960x400_ocean_with_audio.mjpeg",
"test_mjpeg_video",
"mjpeg",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/mkv/sample_960x400_ocean_with_audio.mkv",
"test_mkv_video",
"mkv",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/hevc/sample_960x400_ocean_with_audio.hevc",
"test_hevc_video",
"hevc",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/m2ts/sample_960x400_ocean_with_audio.m2ts",
"test_m2ts_video",
"m2ts",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/m2v/sample_960x400_ocean_with_audio.m2v",
"test_m2v_video",
"m2v",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/mpeg/sample_960x400_ocean_with_audio.mpeg",
"test_mpeg_video",
"mpeg",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/mpg/sample_960x400_ocean_with_audio.mpg",
"test_mpg_video",
"mpg",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/mxf/sample_960x400_ocean_with_audio.mxf",
"test_mxf_video",
"mxf",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/ogv/sample_960x400_ocean_with_audio.ogv",
"test_ogv_video",
"ogv",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/rm/sample_960x400_ocean_with_audio.rm",
"test_rm_video",
"rm",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/ts/sample_960x400_ocean_with_audio.ts",
"test_ts_video",
"ts",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/vob/sample_960x400_ocean_with_audio.vob",
"test_vob_video",
"vob",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/asf/sample_960x400_ocean_with_audio.asf",
"test_asf_video",
"asf",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/avi/sample_960x400_ocean_with_audio.avi",
"test_avi_video",
"avi",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/webm/sample_960x400_ocean_with_audio.webm",
"test_webm_video",
"webm",
},
{
"https://stream-upload-system-tests.s3.eu-north-1.amazonaws.com/wmv/sample_960x400_ocean_with_audio.wmv",
"test_wmv_video",
"wmv",
},
}
for _, sampleVideo := range sampleVideos {
videoLink := sampleVideo[0]
videoName := sampleVideo[1]
videoFormat := sampleVideo[2]
t.RunSequentiallyWithTimeout("Upload Video File "+videoFormat+" With Web Streaming Should Work", 2*time.Minute, func(t *test.SystemTest) {
allocSize := int64(400 * 1024 * 1024)
allocationID := setupAllocation(t, configPath, map[string]interface{}{
"size": allocSize,
"lock": 9,
})
downloadVideo := "wget " + videoLink + " -O " + videoName + "." + videoFormat
output, err := cliutils.RunCommand(t, downloadVideo, 3, 2*time.Second)
require.Nil(t, err, "Failed to download test video file: ", strings.Join(output, "\n"))
output, err = uploadFile(t, configPath, map[string]interface{}{
"allocation": allocationID,
"remotepath": "/",
"localpath": "./" + videoName + "." + videoFormat,
"web-streaming": true,
}, true)
require.Nil(t, err, strings.Join(output, "\n"))
require.Len(t, output, 2)
expected := "Status completed callback. Type = video/mp4. Name = " + videoName + ".mp4"
require.Equal(t, expected, output[1])
})
}
})
}
func uploadWithParam(t *test.SystemTest, cliConfigFilename string, param map[string]interface{}) {
uploadWithParamForWallet(t, escapedTestName(t), cliConfigFilename, param)
}
func uploadWithParamForWallet(t *test.SystemTest, wallet, cliConfigFilename string, param map[string]interface{}) {
filename, ok := param["localpath"].(string)
require.True(t, ok)
output, err := uploadFileForWallet(t, wallet, cliConfigFilename, param, true)
require.Nil(t, err, "Upload file failed due to error ", err, strings.Join(output, "\n"))
require.Len(t, output, 2)
aggregatedOutput := strings.Join(output, " ")
require.Contains(t, aggregatedOutput, StatusCompletedCB)
require.Contains(t, aggregatedOutput, filepath.Base(filename))
}
func uploadFile(t *test.SystemTest, cliConfigFilename string, param map[string]interface{}, retry bool) ([]string, error) {
return uploadFileForWallet(t, escapedTestName(t), cliConfigFilename, param, retry)
}
func uploadFileForWallet(t *test.SystemTest, wallet, cliConfigFilename string, param map[string]interface{}, retry bool) ([]string, error) {
t.Logf("Uploading file...")
p := createParams(param)
cmd := fmt.Sprintf(
"./zbox upload %s --silent --wallet %s_wallet.json --configDir ./config --config %s",
p,
wallet,
cliConfigFilename,
)
if retry {
return cliutils.RunCommand(t, cmd, 3, time.Second*40)
} else {
return cliutils.RunCommandWithoutRetry(cmd)
}
}