forked from vmware/go-vcloud-director
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcatalog_test.go
1240 lines (1009 loc) · 46.6 KB
/
catalog_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
//go:build catalog || functional || ALL
// +build catalog functional ALL
/*
* Copyright 2019 VMware, Inc. All rights reserved. Licensed under the Apache v2 License.
*/
package govcd
import (
"fmt"
"io"
"log"
"os"
"strings"
"time"
"github.com/davecgh/go-spew/spew"
"github.com/vmware/go-vcloud-director/v2/types/v56"
"github.com/vmware/go-vcloud-director/v2/util"
. "gopkg.in/check.v1"
)
// Tests catalog refresh
func (vcd *TestVCD) Test_CatalogRefresh(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
catalogName := vcd.config.VCD.Catalog.Name
if catalogName == "" {
check.Skip("Test_CatalogRefresh: Catalog name not given")
return
}
cat, err := vcd.org.GetCatalogByName(catalogName, false)
if err != nil {
check.Skip("Test_CatalogRefresh: Catalog not found")
return
}
catalogId := cat.Catalog.ID
numItems := len(cat.Catalog.CatalogItems)
dateCreated := cat.Catalog.DateCreated
check.Assert(cat, NotNil)
check.Assert(cat.Catalog.Name, Equals, catalogName)
// Pollute the catalog structure
cat.Catalog.Name = INVALID_NAME
cat.Catalog.ID = invalidEntityId
cat.Catalog.CatalogItems = nil
cat.Catalog.DateCreated = ""
// Get the catalog again from vCD
err = cat.Refresh()
check.Assert(err, IsNil)
check.Assert(cat, NotNil)
check.Assert(cat.Catalog.Name, Equals, catalogName)
check.Assert(cat.Catalog.DateCreated, Equals, dateCreated)
check.Assert(len(cat.Catalog.CatalogItems), Equals, numItems)
check.Assert(cat.Catalog.ID, Equals, catalogId)
}
func (vcd *TestVCD) Test_FindCatalogItem(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
// Fetch Catalog
cat, err := vcd.org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
if err != nil {
check.Skip("Test_FindCatalogItem: Catalog not found. Test can't proceed")
return
}
// Find Catalog Item
if vcd.config.VCD.Catalog.CatalogItem == "" {
check.Skip("Test_FindCatalogItem: Catalog Item not given. Test can't proceed")
}
catalogItem, err := cat.GetCatalogItemByName(vcd.config.VCD.Catalog.CatalogItem, false)
check.Assert(err, IsNil)
check.Assert(catalogItem.CatalogItem.Name, Equals, vcd.config.VCD.Catalog.CatalogItem)
// If given a description in config file then it checks if the descriptions match
// Otherwise it skips the assert
if vcd.config.VCD.Catalog.CatalogItemDescription != "" {
check.Assert(catalogItem.CatalogItem.Description, Equals, vcd.config.VCD.Catalog.CatalogItemDescription)
}
// Test non-existent catalog item
catalogItem, err = cat.GetCatalogItemByName("INVALID", false)
check.Assert(err, NotNil)
check.Assert(catalogItem, IsNil)
}
func (vcd *TestVCD) Test_FindVAppTemplate(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
// Prepare test
cat, err := vcd.org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
if err != nil {
check.Skip(fmt.Sprintf("%s: Catalog not found. Test can't proceed", check.TestName()))
return
}
if vcd.config.VCD.Catalog.CatalogItem == "" {
check.Skip(fmt.Sprintf("%s: Catalog Item not given. Test can't proceed", check.TestName()))
}
// Test cases
vAppTemplate, err := cat.GetVAppTemplateByName(vcd.config.VCD.Catalog.CatalogItem)
check.Assert(err, IsNil)
check.Assert(vAppTemplate.VAppTemplate.Name, Equals, vcd.config.VCD.Catalog.CatalogItem)
if vcd.config.VCD.Catalog.CatalogItemDescription != "" {
check.Assert(vAppTemplate.VAppTemplate.Description, Equals, vcd.config.VCD.Catalog.CatalogItemDescription)
}
vAppTemplate, err = cat.GetVAppTemplateById(vAppTemplate.VAppTemplate.ID)
check.Assert(err, IsNil)
check.Assert(vAppTemplate.VAppTemplate.Name, Equals, vcd.config.VCD.Catalog.CatalogItem)
if vcd.config.VCD.Catalog.CatalogItemDescription != "" {
check.Assert(vAppTemplate.VAppTemplate.Description, Equals, vcd.config.VCD.Catalog.CatalogItemDescription)
}
vAppTemplate, err = cat.GetVAppTemplateByNameOrId(vAppTemplate.VAppTemplate.ID, false)
check.Assert(err, IsNil)
check.Assert(vAppTemplate.VAppTemplate.Name, Equals, vcd.config.VCD.Catalog.CatalogItem)
if vcd.config.VCD.Catalog.CatalogItemDescription != "" {
check.Assert(vAppTemplate.VAppTemplate.Description, Equals, vcd.config.VCD.Catalog.CatalogItemDescription)
}
vAppTemplate, err = cat.GetVAppTemplateByNameOrId(vcd.config.VCD.Catalog.CatalogItem, false)
check.Assert(err, IsNil)
check.Assert(vAppTemplate.VAppTemplate.Name, Equals, vcd.config.VCD.Catalog.CatalogItem)
if vcd.config.VCD.Catalog.CatalogItemDescription != "" {
check.Assert(vAppTemplate.VAppTemplate.Description, Equals, vcd.config.VCD.Catalog.CatalogItemDescription)
}
// Test non-existent vApp Template
vAppTemplate, err = cat.GetVAppTemplateByName("INVALID")
check.Assert(err, NotNil)
check.Assert(vAppTemplate, IsNil)
}
// Creates a Catalog, updates the description, and checks the changes against the
// newly updated catalog. Then deletes the catalog
func (vcd *TestVCD) Test_UpdateCatalog(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
org, err := vcd.client.GetAdminOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
check.Assert(org, NotNil)
catalog, _ := org.GetAdminCatalogByName(TestUpdateCatalog, false)
if catalog != nil {
err = catalog.Delete(true, true)
check.Assert(err, IsNil)
}
adminCatalog, err := org.CreateCatalog(TestUpdateCatalog, TestUpdateCatalog)
check.Assert(err, IsNil)
// After a successful creation, the entity is added to the cleanup list.
// If something fails after this point, the entity will be removed
AddToCleanupList(TestUpdateCatalog, "catalog", vcd.config.VCD.Org, "Test_UpdateCatalog")
check.Assert(adminCatalog.AdminCatalog.Name, Equals, TestUpdateCatalog)
adminCatalog.AdminCatalog.Description = TestCreateCatalogDesc
err = adminCatalog.Update()
check.Assert(err, IsNil)
check.Assert(adminCatalog.AdminCatalog.Description, Equals, TestCreateCatalogDesc)
err = adminCatalog.Delete(true, true)
check.Assert(err, IsNil)
}
// Creates a Catalog, and then deletes the catalog, and checks if
// the catalog still exists. If it does the assertion fails.
func (vcd *TestVCD) Test_DeleteCatalog(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
org, err := vcd.client.GetAdminOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
check.Assert(org, NotNil)
oldCatalog, _ := org.GetAdminCatalogByName(TestDeleteCatalog, false)
if oldCatalog != nil {
err = oldCatalog.Delete(true, true)
check.Assert(err, IsNil)
}
adminCatalog, err := org.CreateCatalog(TestDeleteCatalog, TestDeleteCatalog)
check.Assert(err, IsNil)
// After a successful creation, the entity is added to the cleanup list.
// If something fails after this point, the entity will be removed
AddToCleanupList(TestDeleteCatalog, "catalog", vcd.config.VCD.Org, check.TestName())
check.Assert(adminCatalog.AdminCatalog.Name, Equals, TestDeleteCatalog)
checkUploadOvf(vcd, check, vcd.config.OVA.OvaPath, TestDeleteCatalog, TestUploadOvf+"_"+check.TestName(), false)
err = adminCatalog.Delete(false, false)
check.Assert(err, NotNil)
// Catalog is not empty. An attempt to delete without recursion will fail
check.Assert(strings.Contains(err.Error(), "You must remove"), Equals, true)
err = adminCatalog.Delete(true, true)
check.Assert(err, IsNil)
doesCatalogExist(check, org)
}
func doesCatalogExist(check *C, org *AdminOrg) {
var err error
var catalog *AdminCatalog
for i := 0; i < 30; i++ {
catalog, err = org.GetAdminCatalogByName(TestDeleteCatalog, true)
if catalog == nil {
break
} else {
time.Sleep(time.Second)
}
}
check.Assert(err, NotNil)
}
// Tests System function UploadOvf by creating catalog and
// checking if provided standard ova file uploaded.
func (vcd *TestVCD) Test_UploadOvf(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenOvaPathMissing(vcd.config.OVA.OvaPath, check)
checkUploadOvf(vcd, check, vcd.config.OVA.OvaPath, vcd.config.VCD.Catalog.Name, TestUploadOvf, true)
}
// Tests System function UploadOvf by creating catalog and
// checking if provided chunked ova file uploaded.
func (vcd *TestVCD) Test_UploadOvf_chunked(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenOvaPathMissing(vcd.config.OVA.OvaChunkedPath, check)
checkUploadOvf(vcd, check, vcd.config.OVA.OvaChunkedPath, vcd.config.VCD.Catalog.Name, TestUploadOvf+"2", true)
}
// Tests System function UploadOvf by creating catalog and
// checking UploadTask.GetUploadProgress returns values of progress.
func (vcd *TestVCD) Test_UploadOvf_progress_works(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenOvaPathMissing(vcd.config.OVA.OvaPath, check)
itemName := TestUploadOvf + "3"
catalog, org := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
uploadTask, err := catalog.UploadOvf(vcd.config.OVA.OvaPath, itemName, "upload from test", 1024)
check.Assert(err, IsNil)
for {
if value := uploadTask.GetUploadProgress(); value == "100.00" {
break
} else {
check.Assert(value, Not(Equals), "")
}
}
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, true)
check.Assert(err, IsNil)
verifyCatalogItemUploaded(check, catalog, itemName)
// Delete testing catalog item
deleteCatalogItem(check, catalog, itemName)
}
// Tests System function UploadOvf by creating catalog and
// checking UploadTask.ShowUploadProgress writes values of progress to stdin.
func (vcd *TestVCD) Test_UploadOvf_ShowUploadProgress_works(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenOvaPathMissing(vcd.config.OVA.OvaPath, check)
itemName := TestUploadOvf + "4"
catalog, org := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
//execute
uploadTask, err := catalog.UploadOvf(vcd.config.OVA.OvaPath, itemName, "upload from test", 1024)
check.Assert(err, IsNil)
//take control of stdout
oldStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
err = uploadTask.ShowUploadProgress()
check.Assert(err, IsNil)
err = w.Close()
check.Assert(err, IsNil)
//read stdin
result, _ := io.ReadAll(r)
os.Stdout = oldStdout
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
check.Assert(string(result), Matches, "(?s).*Upload progress 100.00%.*")
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, true)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)
verifyCatalogItemUploaded(check, catalog, itemName)
// Delete testing catalog item
deleteCatalogItem(check, catalog, itemName)
}
// Tests System function UploadOvf by creating catalog, creating catalog item
// and expecting specific error then trying to create same catalog item. As vCD returns cryptic error for such case.
func (vcd *TestVCD) Test_UploadOvf_error_withSameItem(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenOvaPathMissing(vcd.config.OVA.OvaPath, check)
itemName := TestUploadOvf + "5"
catalog, _ := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
//add item
uploadTask, err2 := catalog.UploadOvf(vcd.config.OVA.OvaPath, itemName, "upload from test", 1024)
check.Assert(err2, IsNil)
err2 = uploadTask.WaitTaskCompletion()
check.Assert(err2, IsNil)
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
catalog, _ = findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
_, err3 := catalog.UploadOvf(vcd.config.OVA.OvaPath, itemName, "upload from test", 1024)
check.Assert(err3.Error(), Matches, ".*already exists. Upload with different name.*")
// Delete testing catalog item
deleteCatalogItem(check, catalog, itemName)
}
// Tests System function UploadOvf by creating catalog, uploading file and verifying
// that extracted files were deleted.s
func (vcd *TestVCD) Test_UploadOvf_cleaned_extracted_files(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenOvaPathMissing(vcd.config.OVA.OvaPath, check)
itemName := TestUploadOvf + "6"
//check existing count of folders
oldFolderCount := countFolders()
catalog, _ := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
uploadTask, err := catalog.UploadOvf(vcd.config.OVA.OvaPath, itemName, "upload from test", 1024)
check.Assert(err, IsNil)
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvf")
check.Assert(oldFolderCount, Equals, countFolders())
// Delete testing catalog item
deleteCatalogItem(check, catalog, itemName)
}
// Tests System function UploadOvf by creating catalog and
// checking if provided standard ovf file uploaded.
func (vcd *TestVCD) Test_UploadOvfFile(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenOvaPathMissing(vcd.config.OVA.OvfPath, check)
checkUploadOvf(vcd, check, vcd.config.OVA.OvfPath, vcd.config.VCD.Catalog.Name, TestUploadOvf+"7", true)
}
// Tests System function UploadOvf by creating catalog and
// checking that ova file without vmdk size specified can be uploaded.
func (vcd *TestVCD) Test_UploadOvf_withoutVMDKSize(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenOvaPathMissing(vcd.config.OVA.OvaWithoutSizePath, check)
checkUploadOvf(vcd, check, vcd.config.OVA.OvaWithoutSizePath, vcd.config.VCD.Catalog.Name, TestUploadOvf+"8", true)
}
func countFolders() int {
files, err := os.ReadDir(os.TempDir())
if err != nil {
log.Fatal(err)
}
count := 0
for _, f := range files {
if strings.Contains(f.Name(), util.TmpDirPrefix+".*") {
count++
}
}
return count
}
func checkUploadOvf(vcd *TestVCD, check *C, ovaFileName, catalogName, itemName string, deleteItemAtTheEnd bool) {
catalog, org := findCatalog(vcd, check, catalogName)
uploadTask, err := catalog.UploadOvf(ovaFileName, itemName, "upload from test", 1024)
check.Assert(err, IsNil)
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+catalogName, "checkUploadOvf")
catalog, err = org.GetCatalogByName(catalogName, false)
check.Assert(err, IsNil)
verifyCatalogItemUploaded(check, catalog, itemName)
// Delete testing catalog item
if deleteItemAtTheEnd {
deleteCatalogItem(check, catalog, itemName)
}
}
func verifyCatalogItemUploaded(check *C, catalog *Catalog, itemName string) {
entityFound := false
for _, catalogItems := range catalog.Catalog.CatalogItems {
for _, catalogItem := range catalogItems.CatalogItem {
if catalogItem.Name == itemName {
entityFound = true
}
}
}
check.Assert(entityFound, Equals, true)
}
func findCatalog(vcd *TestVCD, check *C, catalogName string) (*Catalog, *AdminOrg) {
org := getOrg(vcd, check)
catalog, err := org.GetCatalogByName(catalogName, false)
check.Assert(err, IsNil)
return catalog, org
}
func getOrg(vcd *TestVCD, check *C) *AdminOrg {
// Fetching organization
org, err := vcd.client.GetAdminOrgByName(vcd.org.Org.Name)
check.Assert(err, IsNil)
check.Assert(org, NotNil)
return org
}
func skipWhenOvaPathMissing(ovaPath string, check *C) {
if ovaPath == "" {
check.Skip("Skipping test because no OVA/OVF path given")
}
}
func deleteCatalogItem(check *C, catalog *Catalog, itemName string) {
catalogItem, err := catalog.GetCatalogItemByName(itemName, true)
check.Assert(err, IsNil)
check.Assert(catalogItem, NotNil)
err = catalogItem.Delete()
check.Assert(err, IsNil)
}
// Tests System function UploadMediaImage by checking if provided standard iso file uploaded.
func (vcd *TestVCD) Test_CatalogUploadMediaImage(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenMediaPathMissing(vcd, check)
catalog, org := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
uploadTask, err := catalog.UploadMediaImage(TestCatalogUploadMedia, "upload from test", vcd.config.Media.MediaPath, 1024)
check.Assert(err, IsNil)
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(TestCatalogUploadMedia, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage")
//verifyMediaImageUploaded(vcd.vdc.client, check, TestUploadMedia)
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)
verifyCatalogItemUploaded(check, catalog, TestCatalogUploadMedia)
// Delete testing catalog item
deleteCatalogItem(check, catalog, TestCatalogUploadMedia)
}
// Tests System function UploadMediaImage by checking UploadTask.GetUploadProgress returns values of progress.
func (vcd *TestVCD) Test_CatalogUploadMediaImage_progress_works(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenMediaPathMissing(vcd, check)
itemName := TestCatalogUploadMedia + "2"
catalog, org := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
uploadTask, err := catalog.UploadMediaImage(itemName, "upload from test", vcd.config.Media.MediaPath, 1024)
check.Assert(err, IsNil)
for {
if value := uploadTask.GetUploadProgress(); value == "100.00" {
break
} else {
check.Assert(value, Not(Equals), "")
}
}
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_progress_works")
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)
verifyCatalogItemUploaded(check, catalog, itemName)
// Delete testing catalog item
deleteCatalogItem(check, catalog, itemName)
}
// Tests System function UploadMediaImage by checking UploadTask.ShowUploadProgress writes values of progress to stdin.
func (vcd *TestVCD) Test_CatalogUploadMediaImage_ShowUploadProgress_works(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenMediaPathMissing(vcd, check)
itemName := TestCatalogUploadMedia + "3"
catalog, org := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
uploadTask, err := catalog.UploadMediaImage(itemName, "upload from test", vcd.config.Media.MediaPath, 1024)
check.Assert(err, IsNil)
//take control of stdout
oldStdout := os.Stdout
r, w, _ := os.Pipe()
os.Stdout = w
err = uploadTask.ShowUploadProgress()
check.Assert(err, IsNil)
err = w.Close()
check.Assert(err, IsNil)
//read stdin
result, _ := io.ReadAll(r)
os.Stdout = oldStdout
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_ShowUploadProgress_works")
check.Assert(string(result), Matches, "(?s).*Upload progress 100.00%.*")
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)
verifyCatalogItemUploaded(check, catalog, itemName)
// Delete testing catalog item
deleteCatalogItem(check, catalog, itemName)
}
// Tests System function UploadMediaImage by creating media item and expecting specific error
// then trying to create same media item. As vCD returns cryptic error for such case.
func (vcd *TestVCD) Test_CatalogUploadMediaImage_error_withSameItem(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenMediaPathMissing(vcd, check)
itemName := TestCatalogUploadMedia + "4"
catalog, _ := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
uploadTask, err := catalog.UploadMediaImage(itemName, "upload from test", vcd.config.Media.MediaPath, 1024)
check.Assert(err, IsNil)
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogUploadMediaImage_error_withSameItem")
// Delete testing catalog item
deleteCatalogItem(check, catalog, itemName)
}
// Tests System function Delete by creating media item and
// deleting it after.
func (vcd *TestVCD) Test_CatalogDeleteMediaRecord(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
skipWhenMediaPathMissing(vcd, check)
itemName := TestCatalogUploadMedia + "5"
catalog, org := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
uploadTask, err := catalog.UploadMediaImage(itemName, "upload from test", vcd.config.Media.MediaPath, 1024)
check.Assert(err, IsNil)
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "mediaCatalogImage", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_CatalogDeleteMediaImage")
mediaRecord, err := catalog.QueryMedia(itemName)
check.Assert(err, IsNil)
check.Assert(mediaRecord.MediaRecord.Name, Equals, itemName)
task, err := mediaRecord.Delete()
check.Assert(err, IsNil)
err = task.WaitTaskCompletion()
check.Assert(err, IsNil)
mediaRecord, err = catalog.QueryMedia(itemName)
check.Assert(IsNotFound(err), Equals, true)
check.Assert(mediaRecord, IsNil)
//addition check
// check through existing catalogItems
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)
entityFound := false
for _, catalogItems := range catalog.Catalog.CatalogItems {
for _, catalogItem := range catalogItems.CatalogItem {
if catalogItem.Name == TestDeleteCatalogItem {
entityFound = true
}
}
}
check.Assert(entityFound, Equals, false)
}
func init() {
testingTags["catalog"] = "catalog_test.go"
}
// Tests CatalogItem retrieval by name, by ID, and by a combination of name and ID
func (vcd *TestVCD) Test_CatalogGetItem(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
if vcd.config.VCD.Org == "" {
check.Skip("Test_CatalogGetItem: Org name not given")
return
}
if vcd.config.VCD.Catalog.Name == "" {
check.Skip("Test_CatalogGetItem: Catalog name not given")
return
}
org, err := vcd.client.GetOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
check.Assert(org, NotNil)
catalog, err := org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)
getByName := func(name string, refresh bool) (genericEntity, error) {
return catalog.GetCatalogItemByName(name, refresh)
}
getById := func(id string, refresh bool) (genericEntity, error) { return catalog.GetCatalogItemById(id, refresh) }
getByNameOrId := func(id string, refresh bool) (genericEntity, error) {
return catalog.GetCatalogItemByNameOrId(id, refresh)
}
var def = getterTestDefinition{
parentType: "Catalog",
parentName: vcd.config.VCD.Catalog.Name,
entityType: "CatalogItem",
entityName: vcd.config.VCD.Catalog.CatalogItem,
getByName: getByName,
getById: getById,
getByNameOrId: getByNameOrId,
}
vcd.testFinderGetGenericEntity(def, check)
}
// TestGetVappTemplateByHref tests that we can find a vApp template using
// the HREF from the Entity section of a known Catalog Item
func (vcd *TestVCD) TestGetVappTemplateByHref(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
if vcd.config.VCD.Org == "" {
check.Skip("Test_CatalogGetItem: Org name not given")
return
}
if vcd.config.VCD.Catalog.Name == "" {
check.Skip("Test_CatalogGetItem: Catalog name not given")
return
}
if vcd.config.VCD.Catalog.CatalogItem == "" {
check.Skip("Test_CatalogGetItem: Catalog item name not given")
return
}
org, err := vcd.client.GetOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
check.Assert(org, NotNil)
catalog, err := org.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(catalog, NotNil)
catalogItem, err := catalog.GetCatalogItemByName(vcd.config.VCD.Catalog.CatalogItem, false)
check.Assert(err, IsNil)
check.Assert(catalogItem, NotNil)
check.Assert(catalogItem.CatalogItem.Entity, NotNil)
vappTemplate, err := catalog.GetVappTemplateByHref(catalogItem.CatalogItem.Entity.HREF)
check.Assert(err, IsNil)
check.Assert(vappTemplate, NotNil)
check.Assert(vappTemplate.VAppTemplate.ID, Not(Equals), catalogItem.CatalogItem.ID)
check.Assert(vappTemplate.VAppTemplate.Type, Equals, types.MimeVAppTemplate)
check.Assert(vappTemplate.VAppTemplate.Name, Equals, catalogItem.CatalogItem.Name)
}
// Test_GetCatalogByNameSharedCatalog creates a separate Org and VDC just to create Catalog and share it with main Org
// One should be able to find shared catalogs from different Organizations
func (vcd *TestVCD) Test_GetCatalogByNameSharedCatalog(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
newOrg1, vdc, sharedCatalog := createSharedCatalogInNewOrg(vcd, check, check.TestName())
// Try to find the catalog inside Org which owns it - newOrg1
catalogByName, err := newOrg1.GetCatalogByName(sharedCatalog.Catalog.Name, true)
check.Assert(err, IsNil)
check.Assert(catalogByName.Catalog.Name, Equals, sharedCatalog.Catalog.Name)
// Try to find the catalog in another Org with which this catalog is shared (vcd.Org)
sharedCatalogByName, err := vcd.org.GetCatalogByName(sharedCatalog.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(sharedCatalogByName.Catalog.Name, Equals, sharedCatalog.Catalog.Name)
cleanupCatalogOrgVdc(check, sharedCatalog, vdc, vcd, newOrg1)
}
// Test_GetCatalogByIdSharedCatalog creates a separate Org and VDC just to create Catalog and share it with main Org
// One should be able to find shared catalogs from different Organizations
func (vcd *TestVCD) Test_GetCatalogByIdSharedCatalog(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
newOrg1, vdc, sharedCatalog := createSharedCatalogInNewOrg(vcd, check, check.TestName())
// Try to find the sharedCatalog inside Org which owns it - newOrg1
catalogById, err := newOrg1.GetCatalogById(sharedCatalog.Catalog.ID, true)
check.Assert(err, IsNil)
check.Assert(catalogById.Catalog.Name, Equals, sharedCatalog.Catalog.Name)
// Try to find the sharedCatalog in another Org with which this sharedCatalog is shared (vcd.Org)
sharedCatalogById, err := vcd.org.GetCatalogById(sharedCatalog.Catalog.ID, false)
check.Assert(err, IsNil)
check.Assert(sharedCatalogById.Catalog.Name, Equals, sharedCatalog.Catalog.Name)
cleanupCatalogOrgVdc(check, sharedCatalog, vdc, vcd, newOrg1)
}
// Test_GetCatalogByNamePrefersLocal tests that local catalog (in the same Org) is prioritised against shared catalogs
// in other Orgs. It does so by creating another Org with shared Catalog named just like the one in testing catalog
func (vcd *TestVCD) Test_GetCatalogByNamePrefersLocal(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
// Create a catalog in new org with exactly the same name as in vcd.Org
newOrg1, vdc, sharedCatalog := createSharedCatalogInNewOrg(vcd, check, vcd.config.VCD.Catalog.Name)
// Make sure that the Owner Org HREF is the local one for vcd.Org catalog named vcd.config.VCD.Catalog.Name
catalogByNameInTestOrg, err := vcd.org.GetCatalogByName(vcd.config.VCD.Catalog.Name, true)
check.Assert(err, IsNil)
check.Assert(catalogByNameInTestOrg.parent.orgName(), Equals, vcd.org.Org.Name)
// Make sure that the Owner Org HREF is the local one for vcd.Org catalog named vcd.config.VCD.Catalog.Name
catalogByNameInNewOrg, err := newOrg1.GetCatalogByName(vcd.config.VCD.Catalog.Name, true)
check.Assert(err, IsNil)
check.Assert(catalogByNameInNewOrg.parent.orgName(), Equals, newOrg1.Org.Name)
cleanupCatalogOrgVdc(check, sharedCatalog, vdc, vcd, newOrg1)
}
// Test_GetCatalogByNameSharedCatalogOrgUser additionally tests GetOrgByName and GetOrgById using a custom created Org
// Admin user. It tests the following cases:
// * System user must be able to retrieve any catalog - shared or unshared from another Org
// * Org Admin user must be able to retrieve catalog in his own Org
// * Org Admin user must be able to retrieve shared catalog from another Org
// * Org admin user must not be able to retrieve unshared catalog from another Org
func (vcd *TestVCD) Test_GetCatalogByXSharedCatalogOrgUser(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
newOrg1, vdc, sharedCatalog := createSharedCatalogInNewOrg(vcd, check, check.TestName())
// Create one more additional catalog which is not shared
unsharedCatalog, err := newOrg1.CreateCatalog("unshared-catalog", check.TestName())
check.Assert(err, IsNil)
AddToCleanupList(unsharedCatalog.Catalog.Name, "catalog", newOrg1.Org.Name, check.TestName())
// Try to find the catalog inside Org which owns it - newOrg1
catalogByName, err := newOrg1.GetCatalogByName(sharedCatalog.Catalog.Name, true)
check.Assert(err, IsNil)
check.Assert(catalogByName.Catalog.Name, Equals, sharedCatalog.Catalog.Name)
// Try to find the catalog in another Org with which this catalog is shared (vcd.Org)
sharedCatalogByName, err := vcd.org.GetCatalogByName(sharedCatalog.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(sharedCatalogByName.Catalog.Name, Equals, sharedCatalog.Catalog.Name)
// Try to find unshared catalog from another Org with System user
systemUnsharedCatalogByName, err := vcd.org.GetCatalogByName(unsharedCatalog.Catalog.Name, true)
check.Assert(err, IsNil)
check.Assert(systemUnsharedCatalogByName.Catalog.ID, Equals, unsharedCatalog.Catalog.ID)
// Create an Org Admin user and test that it can find catalog as well
adminOrg, err := vcd.client.GetAdminOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
orgAdminClient, err := newOrgUserConnection(adminOrg, "test-user", "CHANGE-ME", vcd.config.Provider.Url, true)
check.Assert(err, IsNil)
orgAsOrgUser, err := orgAdminClient.GetOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
// Find a catalog in the same Org using Org Admin user
orgAdminCatalogByNameSameOrg, err := orgAsOrgUser.GetCatalogByName(vcd.config.VCD.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(orgAdminCatalogByNameSameOrg.Catalog.Name, Equals, vcd.config.VCD.Catalog.Name)
orgAdminCatalogByIdSameOrg, err := orgAsOrgUser.GetCatalogById(orgAdminCatalogByNameSameOrg.Catalog.ID, false)
check.Assert(err, IsNil)
check.Assert(orgAdminCatalogByIdSameOrg.Catalog.Name, Equals, orgAdminCatalogByNameSameOrg.Catalog.Name)
check.Assert(orgAdminCatalogByIdSameOrg.Catalog.ID, Equals, orgAdminCatalogByNameSameOrg.Catalog.ID)
// Find a shared catalog from another Org using Org Admin user
orgAdminCatalogByName, err := orgAsOrgUser.GetCatalogByName(sharedCatalog.Catalog.Name, false)
check.Assert(err, IsNil)
check.Assert(orgAdminCatalogByName.Catalog.Name, Equals, sharedCatalog.Catalog.Name)
check.Assert(orgAdminCatalogByName.Catalog.ID, Equals, sharedCatalog.Catalog.ID)
orgAdminCatalogById, err := orgAsOrgUser.GetCatalogById(sharedCatalog.Catalog.ID, false)
check.Assert(err, IsNil)
check.Assert(orgAdminCatalogById.Catalog.Name, Equals, sharedCatalog.Catalog.Name)
check.Assert(orgAdminCatalogById.Catalog.ID, Equals, sharedCatalog.Catalog.ID)
// Try to find unshared catalog from another Org with Org admin user and expect an ErrorEntityNotFound
_, err = orgAsOrgUser.GetCatalogByName(unsharedCatalog.Catalog.Name, true)
check.Assert(ContainsNotFound(err), Equals, true)
_, err = orgAsOrgUser.GetCatalogById(unsharedCatalog.Catalog.ID, true)
check.Assert(ContainsNotFound(err), Equals, true)
// Cleanup
err = unsharedCatalog.Delete(true, true)
check.Assert(err, IsNil)
cleanupCatalogOrgVdc(check, sharedCatalog, vdc, vcd, newOrg1)
}
func createSharedCatalogInNewOrg(vcd *TestVCD, check *C, newCatalogName string) (*Org, *Vdc, Catalog) {
newOrgName1 := spawnTestOrg(vcd, check, "org")
newOrg1, err := vcd.client.GetOrgByName(newOrgName1)
check.Assert(err, IsNil)
// Spawn a VDC inside newly created Org so that there is storage to create new catalog
vdc := spawnTestVdc(vcd, check, newOrgName1)
catalog, err := newOrg1.CreateCatalog(newCatalogName, "Catalog for testing")
check.Assert(err, IsNil)
AddToCleanupList(newCatalogName, "catalog", newOrgName1, check.TestName())
// Share new Catalog in newOrgName1 with default test Org vcd.Org
readOnly := "ReadOnly"
accessControl := &types.ControlAccessParams{
IsSharedToEveryone: false,
EveryoneAccessLevel: &readOnly,
AccessSettings: &types.AccessSettingList{
AccessSetting: []*types.AccessSetting{&types.AccessSetting{
Subject: &types.LocalSubject{
HREF: vcd.org.Org.HREF,
Name: vcd.org.Org.Name,
Type: types.MimeOrg,
},
AccessLevel: "ReadOnly",
}},
},
}
err = catalog.SetAccessControl(accessControl, false)
check.Assert(err, IsNil)
return newOrg1, vdc, catalog
}
func cleanupCatalogOrgVdc(check *C, sharedCatalog Catalog, vdc *Vdc, vcd *TestVCD, newOrg1 *Org) {
// Cleanup catalog, vdc and org
err := sharedCatalog.Delete(true, true)
check.Assert(err, IsNil)
err = vdc.DeleteWait(true, true)
check.Assert(err, IsNil)
adminOrg, err := vcd.client.GetAdminOrgByName(newOrg1.Org.Name)
check.Assert(err, IsNil)
err = adminOrg.Delete(true, true)
check.Assert(err, IsNil)
}
// Creates a Catalog. Publishes catalog to external Org and then deletes the catalog.
func (vcd *TestVCD) Test_PublishToExternalOrganizations(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
// test with AdminCatalog
catalogName := check.TestName()
catalogDescription := check.TestName() + " description"
adminOrg, err := vcd.client.GetAdminOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
check.Assert(adminOrg, NotNil)
// TODO - remove once VCD is fixed.
// Every Org update causes catalog publishing to be removed and therefore this test fails.
// Turning publishing on right before test to be sure it is tested and passes.
// VCD 10.2.0 <-> 10.3.3 have a bug that even though catalog publishing is enabled adminOrg.
fmt.Println("Overcomming VCD 10.2.0 <-> 10.3.3 bug - explicitly setting catalog sharing")
adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanPublishCatalogs = true
adminOrg.AdminOrg.OrgSettings.OrgGeneralSettings.CanPublishExternally = true
updatedAdminOrg, err := adminOrg.Update()
check.Assert(err, IsNil)
check.Assert(updatedAdminOrg, NotNil)
adminCatalog, err := adminOrg.CreateCatalog(catalogName, catalogDescription)
check.Assert(err, IsNil)
check.Assert(adminCatalog.AdminCatalog.Name, Equals, catalogName)
check.Assert(adminCatalog.AdminCatalog.Description, Equals, catalogDescription)
AddToCleanupList(catalogName, "catalog", vcd.config.VCD.Org, check.TestName())
err = adminCatalog.PublishToExternalOrganizations(types.PublishExternalCatalogParams{
IsPublishedExternally: takeBoolPointer(true),
IsCachedEnabled: takeBoolPointer(true),
Password: "secretOrNot",
PreserveIdentityInfoFlag: takeBoolPointer(true),
})
check.Assert(err, IsNil)
check.Assert(*adminCatalog.AdminCatalog.PublishExternalCatalogParams.IsPublishedExternally, Equals, true)
check.Assert(*adminCatalog.AdminCatalog.PublishExternalCatalogParams.PreserveIdentityInfoFlag, Equals, true)
check.Assert(*adminCatalog.AdminCatalog.PublishExternalCatalogParams.IsCachedEnabled, Equals, true)
check.Assert(adminCatalog.AdminCatalog.PublishExternalCatalogParams.Password, Equals, "******")
err = adminCatalog.Delete(true, true)
check.Assert(err, IsNil)
// test with Catalog
org, err := vcd.client.GetOrgByName(vcd.config.VCD.Org)
check.Assert(err, IsNil)
check.Assert(org, NotNil)
catalog, err := org.CreateCatalog(catalogName, catalogDescription)
check.Assert(err, IsNil)
check.Assert(catalog.Catalog.Name, Equals, catalogName)
check.Assert(catalog.Catalog.Description, Equals, catalogDescription)
AddToCleanupList(catalogName, "catalog", vcd.config.VCD.Org, check.TestName())
err = catalog.PublishToExternalOrganizations(types.PublishExternalCatalogParams{
IsPublishedExternally: takeBoolPointer(true),
IsCachedEnabled: takeBoolPointer(true),
Password: "secretOrNot",
PreserveIdentityInfoFlag: takeBoolPointer(true),
})
check.Assert(err, IsNil)
check.Assert(*catalog.Catalog.PublishExternalCatalogParams.IsPublishedExternally, Equals, true)
check.Assert(*catalog.Catalog.PublishExternalCatalogParams.PreserveIdentityInfoFlag, Equals, true)
check.Assert(*catalog.Catalog.PublishExternalCatalogParams.IsCachedEnabled, Equals, true)
check.Assert(catalog.Catalog.PublishExternalCatalogParams.Password, Equals, "******")
err = catalog.PublishToExternalOrganizations(types.PublishExternalCatalogParams{
IsPublishedExternally: takeBoolPointer(true),
IsCachedEnabled: takeBoolPointer(false),
Password: "secretOrNot2",
PreserveIdentityInfoFlag: takeBoolPointer(false),
})
check.Assert(err, IsNil)
check.Assert(*catalog.Catalog.PublishExternalCatalogParams.IsPublishedExternally, Equals, true)
check.Assert(*catalog.Catalog.PublishExternalCatalogParams.PreserveIdentityInfoFlag, Equals, false)
check.Assert(*catalog.Catalog.PublishExternalCatalogParams.IsCachedEnabled, Equals, false)
check.Assert(catalog.Catalog.PublishExternalCatalogParams.Password, Equals, "******")
err = catalog.Delete(true, true)
check.Assert(err, IsNil)
}
// Tests System function UploadOvfByLink and verifies that
// Task.GetTaskProgress returns values of progress.
func (vcd *TestVCD) Test_UploadOvfByLink_progress_works(check *C) {
fmt.Printf("Running: %s\n", check.TestName())
if vcd.config.OVA.OvfUrl == "" {
check.Skip("Skipping test because no OVF URL given")
}
itemName := TestUploadOvf + "URL"
catalog, org := findCatalog(vcd, check, vcd.config.VCD.Catalog.Name)
uploadTask, err := catalog.UploadOvfByLink(vcd.config.OVA.OvfUrl, itemName, "upload from test")
check.Assert(err, IsNil)
check.Assert(uploadTask, NotNil)
for {
if value, err := uploadTask.GetTaskProgress(); value == "100" || err != nil {
check.Assert(err, IsNil)
break
} else {
check.Assert(value, Not(Equals), "")
}
}
err = uploadTask.WaitTaskCompletion()
check.Assert(err, IsNil)
AddToCleanupList(itemName, "catalogItem", vcd.org.Org.Name+"|"+vcd.config.VCD.Catalog.Name, "Test_UploadOvfByLink_progress_works")
catalog, err = org.GetCatalogByName(vcd.config.VCD.Catalog.Name, true)
check.Assert(err, IsNil)
verifyCatalogItemUploaded(check, catalog, itemName)
// Delete testing catalog item