@@ -75,6 +75,7 @@ func TestClientGetProfile(t *testing.T) {
7575 }
7676}
7777
78+
7879func TestClientListProfiles (t * testing.T ) {
7980 prfs , err := c .ListProfiles ()
8081 if err != nil {
@@ -92,6 +93,7 @@ func TestClientListProfiles(t *testing.T) {
9293 for i := range SampleProfiles {
9394 expected = append (expected , & SampleProfiles [i ])
9495 }
96+
9597 if ! reflect .DeepEqual (prfs , expected ) {
9698 t .Errorf ("expected %+v, got %+v\n " , expected , prfs )
9799 }
@@ -546,3 +548,259 @@ func TestClientFailoverReplication(t *testing.T) {
546548 t.Log("Disable volume replication not ready!")
547549}
548550*/
551+
552+ /*
553+ File share integration test cases
554+ */
555+
556+ func TestClientCreateFileProfile (t * testing.T ) {
557+ var body = & model.ProfileSpec {
558+ Name : "gold" ,
559+ Description : "gold policy" ,
560+ StorageType : "file" ,
561+ }
562+
563+ prf , err := c .CreateProfile (body )
564+ if err != nil {
565+ t .Error ("create profile in client failed:" , err )
566+ return
567+ }
568+ // If customized properties are not defined, create an empty one.
569+ if prf .CustomProperties == nil {
570+ prf .CustomProperties = model.CustomPropertiesSpec {}
571+ }
572+
573+ var expected = & SampleFileShareProfiles [0 ]
574+ if ! reflect .DeepEqual (prf , expected ) {
575+ t .Errorf ("expected %+v, got %+v\n " , expected , prf )
576+ }
577+ }
578+
579+ func TestClientGetFileProfile (t * testing.T ) {
580+ var prfID = "3f9c0a04-66ef-11e7-ade2-43158893e017"
581+
582+ prf , err := c .GetProfile (prfID )
583+ if err != nil {
584+ t .Error ("get profile in client failed:" , err )
585+ return
586+ }
587+
588+ var expected = & SampleFileShareProfiles [1 ]
589+ if ! reflect .DeepEqual (prf , expected ) {
590+ t .Errorf ("expected %+v, got %+v\n " , expected , prf )
591+ }
592+ }
593+
594+ func TestClientCreateFileShare (t * testing.T ) {
595+ var body = & model.FileShareSpec {
596+ Name : "test" ,
597+ Description : "This is a test" ,
598+ Size : int64 (1 ),
599+ ProfileId : "2106b972-66ef-11e7-b172-db03f3689c9c" ,
600+ }
601+
602+ if _ , err := c .CreateFileShare (body ); err != nil {
603+ t .Error ("create file share in client failed:" , err )
604+ return
605+ }
606+
607+ t .Log ("Create file share success!" )
608+ }
609+
610+ func TestClientGetFileShare (t * testing.T ) {
611+ var fileshareID = "a2975ebe-d82c-430f-b28e-f373746a71ca"
612+
613+ fileshare , err := c .GetFileShare (fileshareID )
614+ if err != nil {
615+ t .Error ("get file share in client failed:" , err )
616+ return
617+ }
618+
619+ var expected = & SampleFileShares [0 ]
620+ if ! reflect .DeepEqual (fileshare , expected ) {
621+ t .Errorf ("expected %+v, got %+v\n " , expected , fileshare )
622+ }
623+ }
624+
625+ func TestClientListFileShares (t * testing.T ) {
626+ fileshares , err := c .ListFileShares ()
627+ if err != nil {
628+ t .Error ("list fileshares in client failed:" , err )
629+ return
630+ }
631+
632+ var expected []* model.FileShareSpec
633+ for i := range SampleFileShares {
634+ expected = append (expected , & SampleFileShares [i ])
635+ }
636+ if ! reflect .DeepEqual (fileshares , expected ) {
637+ t .Errorf ("expected %+v, got %+v\n " , expected , fileshares )
638+ }
639+ }
640+
641+ func TestClientUpdateFileShare (t * testing.T ) {
642+ var fileshareID = "a2975ebe-d82c-430f-b28e-f373746a71ca"
643+ body := & model.FileShareSpec {
644+ Name : "sample-fileshare-01" ,
645+ Description : "This is first sample fileshare for testing" ,
646+ }
647+
648+ fileshare , err := c .UpdateFileShare (fileshareID , body )
649+ if err != nil {
650+ t .Error ("update fileshare in client failed:" , err )
651+ return
652+ }
653+
654+ var expected = & SampleFileShares [0 ]
655+ if ! reflect .DeepEqual (fileshare , expected ) {
656+ t .Errorf ("expected %+v, got %+v\n " , expected , fileshare )
657+ }
658+ }
659+
660+ func TestClientCreateFileShareAcl (t * testing.T ) {
661+ var body = & model.FileShareAclSpec {
662+ Description : "This is a sample Acl for testing" ,
663+ ProfileId : "1106b972-66ef-11e7-b172-db03f3689c9c" ,
664+ Type : "ip" ,
665+ AccessCapability : []string {"Read" , "Write" },
666+ AccessTo : "10.32.109.15" ,
667+ FileShareId : "a2975ebe-d82c-430f-b28e-f373746a71ca" ,
668+ }
669+
670+ if _ , err := c .CreateFileShareAcl (body ); err != nil {
671+ t .Error ("create file share acl in client failed:" , err )
672+ return
673+ }
674+
675+ t .Log ("Create file share acl success!" )
676+ }
677+
678+ func TestClientGetFileShareAcl (t * testing.T ) {
679+ var aclID = "6ad25d59-a160-45b2-8920-211be282e2df"
680+
681+ acls , err := c .GetFileShareAcl (aclID )
682+ if err != nil {
683+ t .Error ("get file share acl in client failed:" , err )
684+ return
685+ }
686+
687+ var expected = & SampleFileSharesAcl [0 ]
688+ if ! reflect .DeepEqual (acls , expected ) {
689+ t .Errorf ("expected %+v, got %+v\n " , expected , acls )
690+ }
691+ }
692+
693+ func TestClientListFileShareAcl (t * testing.T ) {
694+ acls , err := c .ListFileSharesAcl ()
695+ if err != nil {
696+ t .Error ("list fileshare acls in client failed:" , err )
697+ return
698+ }
699+
700+ var expected []* model.FileShareAclSpec
701+ for i := range SampleFileSharesAcl {
702+ expected = append (expected , & SampleFileSharesAcl [i ])
703+ }
704+ if ! reflect .DeepEqual (acls , expected ) {
705+ t .Errorf ("expected %+v, got %+v\n " , expected , acls )
706+ }
707+ }
708+
709+ func TestClientCreateFileShareSnapshot (t * testing.T ) {
710+ var body = & model.FileShareSnapshotSpec {
711+ Name : "test" ,
712+ Description : "This is a test" ,
713+ FileShareId : "a2975ebe-d82c-430f-b28e-f373746a71ca" ,
714+ }
715+
716+ if _ , err := c .CreateFileShareSnapshot (body ); err != nil {
717+ t .Error ("create file share snapshot in client failed:" , err )
718+ return
719+ }
720+
721+ t .Log ("Create file share snapshot success!" )
722+ }
723+
724+ func TestClientGetFileShareSnapshot (t * testing.T ) {
725+ var snpID = "3769855c-a102-11e7-b772-17b880d2f537"
726+
727+ snp , err := c .GetFileShareSnapshot (snpID )
728+ if err != nil {
729+ t .Error ("get file share snapshot in client failed:" , err )
730+ return
731+ }
732+
733+ var expected = & SampleFileShareSnapshots [0 ]
734+ if ! reflect .DeepEqual (snp , expected ) {
735+ t .Errorf ("expected %+v, got %+v\n " , expected , snp )
736+ }
737+ }
738+
739+ func TestClientListFileShareSnapshots (t * testing.T ) {
740+ snps , err := c .ListFileShareSnapshots ()
741+ if err != nil {
742+ t .Error ("list file share snapshots in client failed:" , err )
743+ return
744+ }
745+
746+ var expected []* model.FileShareSnapshotSpec
747+ for i := range SampleFileShareSnapshots {
748+ expected = append (expected , & SampleFileShareSnapshots [i ])
749+ }
750+ if ! reflect .DeepEqual (snps , expected ) {
751+ t .Errorf ("expected %+v, got %+v\n " , expected , snps )
752+ }
753+ }
754+
755+ func TestClientUpdateFileShareSnapshot (t * testing.T ) {
756+ var snpID = "3769855c-a102-11e7-b772-17b880d2f537"
757+ body := & model.FileShareSnapshotSpec {
758+ Name : "sample-snapshot-01" ,
759+ Description : "This is the first sample snapshot for testing" ,
760+ }
761+
762+ snp , err := c .UpdateFileShareSnapshot (snpID , body )
763+ if err != nil {
764+ t .Error ("update file share snapshot in client failed:" , err )
765+ return
766+ }
767+
768+ var expected = & SampleFileShareSnapshots [0 ]
769+ if ! reflect .DeepEqual (snp , expected ) {
770+ t .Errorf ("expected %+v, got %+v\n " , expected , snp )
771+ }
772+ }
773+
774+ func TestClientDeleteFileShareAcl (t * testing.T ) {
775+ var fileshareaclID = "d2975ebe-d82c-430f-b28e-f373746a71ca"
776+
777+ if err := c .DeleteFileShareAcl (fileshareaclID ); err != nil {
778+ t .Error ("delete file share acl in client failed:" , err )
779+ return
780+ }
781+
782+ t .Log ("Delete file share acl success!" )
783+ }
784+
785+ func TestClientDeleteFileShareSnapshot (t * testing.T ) {
786+ var snapID = "3769855c-a102-11e7-b772-17b880d2f537"
787+
788+ if err := c .DeleteFileShareSnapshot (snapID ); err != nil {
789+ t .Error ("delete file share snapshot in client failed:" , err )
790+ return
791+ }
792+
793+ t .Log ("Delete file share snapshot success!" )
794+ }
795+
796+
797+ func TestClientDeleteFileProfile (t * testing.T ) {
798+ var prfID = "3f9c0a04-66ef-11e7-ade2-43158893e017"
799+
800+ if err := c .DeleteProfile (prfID ); err != nil {
801+ t .Error ("delete profile in client failed:" , err )
802+ return
803+ }
804+
805+ t .Log ("Delete profile success!" )
806+ }
0 commit comments