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