@@ -546,3 +546,270 @@ 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 TestClientDeleteFileShare (t * testing.T ) {
609+ var fileshareID = "d2975ebe-d82c-430f-b28e-f373746a71ca"
610+ body := & model.FileShareSpec {}
611+
612+ if err := c .DeleteFileShare (fileshareID , body ); err != nil {
613+ t .Error ("delete file share in client failed:" , err )
614+ return
615+ }
616+
617+ t .Log ("Delete file share success!" )
618+ }
619+
620+ func TestClientGetFileShare (t * testing.T ) {
621+ var fileshareID = "d2975ebe-d82c-430f-b28e-f373746a71ca"
622+
623+ fileshare , err := c .GetFileShare (fileshareID )
624+ if err != nil {
625+ t .Error ("get file share in client failed:" , err )
626+ return
627+ }
628+
629+ var expected = & SampleFileShares [0 ]
630+ if ! reflect .DeepEqual (fileshare , expected ) {
631+ t .Errorf ("expected %+v, got %+v\n " , expected , fileshare )
632+ }
633+ }
634+
635+ func TestClientListFileShares (t * testing.T ) {
636+ fileshares , err := c .ListFileShares ()
637+ if err != nil {
638+ t .Error ("list fileshares in client failed:" , err )
639+ return
640+ }
641+
642+ var expected []* model.FileShareSpec
643+ for i := range SampleFileShares {
644+ expected = append (expected , & SampleFileShares [i ])
645+ }
646+ if ! reflect .DeepEqual (fileshares , expected ) {
647+ t .Errorf ("expected %+v, got %+v\n " , expected , fileshares )
648+ }
649+ }
650+
651+ func TestClientUpdateFileShare (t * testing.T ) {
652+ var fileshareID = "d2975ebe-d82c-430f-b28e-f373746a71ca"
653+ body := & model.FileShareSpec {
654+ Name : "sample-fileshare-01" ,
655+ Description : "This is first sample fileshare for testing" ,
656+ }
657+
658+ fileshare , err := c .UpdateFileShare (fileshareID , body )
659+ if err != nil {
660+ t .Error ("update fileshare in client failed:" , err )
661+ return
662+ }
663+
664+ var expected = & SampleFileShares [0 ]
665+ if ! reflect .DeepEqual (fileshare , expected ) {
666+ t .Errorf ("expected %+v, got %+v\n " , expected , fileshare )
667+ }
668+ }
669+
670+ func TestClientCreateFileShareAcl (t * testing.T ) {
671+ var body = & model.FileShareAclSpec {
672+ Description : "This is a sample Acl for testing" ,
673+ ProfileId : "3f9c0a04-66ef-11e7-ade2-43158893e017" ,
674+ Type : "ip" ,
675+ AccessCapability : []string {"Read" , "Write" },
676+ AccessTo : "10.32.109.15" ,
677+ FileShareId : "d2975ebe-d82c-430f-b28e-f373746a71ca" ,
678+ }
679+
680+ if _ , err := c .CreateFileShareAcl (body ); err != nil {
681+ t .Error ("create file share acl in client failed:" , err )
682+ return
683+ }
684+
685+ t .Log ("Create file share acl success!" )
686+ }
687+
688+ func TestClientGetFileShareAcl (t * testing.T ) {
689+ var aclID = "d2975ebe-d82c-430f-b28e-f373746a71ca"
690+
691+ acl , err := c .GetFileShareAcl (aclID )
692+ if err != nil {
693+ t .Error ("get file share acl in client failed:" , err )
694+ return
695+ }
696+
697+ var expected = & SampleFileSharesAcl [0 ]
698+ if ! reflect .DeepEqual (acl , expected ) {
699+ t .Errorf ("expected %+v, got %+v\n " , expected , acl )
700+ }
701+ }
702+
703+ func TestClientListFileShareAcl (t * testing.T ) {
704+ acls , err := c .ListFileSharesAcl ()
705+ if err != nil {
706+ t .Error ("list fileshare acls in client failed:" , err )
707+ return
708+ }
709+
710+ var expected []* model.FileShareAclSpec
711+ for i := range SampleFileSharesAcl {
712+ expected = append (expected , & SampleFileSharesAcl [i ])
713+ }
714+ if ! reflect .DeepEqual (acls , expected ) {
715+ t .Errorf ("expected %+v, got %+v\n " , expected , acls )
716+ }
717+ }
718+
719+ func TestClientCreateFileShareSnapshot (t * testing.T ) {
720+ var body = & model.FileShareSnapshotSpec {
721+ Name : "test" ,
722+ Description : "This is a test" ,
723+ FileShareId : "d2975ebe-d82c-430f-b28e-f373746a71ca" ,
724+ }
725+
726+ if _ , err := c .CreateFileShareSnapshot (body ); err != nil {
727+ t .Error ("create file share snapshot in client failed:" , err )
728+ return
729+ }
730+
731+ t .Log ("Create file share snapshot success!" )
732+ }
733+
734+ func TestClientGetFileShareSnapshot (t * testing.T ) {
735+ var snpID = "3769855c-a102-11e7-b772-17b880d2f537"
736+
737+ snp , err := c .GetFileShareSnapshot (snpID )
738+ if err != nil {
739+ t .Error ("get file share snapshot in client failed:" , err )
740+ return
741+ }
742+
743+ var expected = & SampleFileShareSnapshots [0 ]
744+ if ! reflect .DeepEqual (snp , expected ) {
745+ t .Errorf ("expected %+v, got %+v\n " , expected , snp )
746+ }
747+ }
748+
749+ func TestClientListFileShareSnapshots (t * testing.T ) {
750+ snps , err := c .ListFileShareSnapshots ()
751+ if err != nil {
752+ t .Error ("list file share snapshots in client failed:" , err )
753+ return
754+ }
755+
756+ var expected []* model.FileShareSnapshotSpec
757+ for i := range SampleFileShareSnapshots {
758+ expected = append (expected , & SampleFileShareSnapshots [i ])
759+ }
760+ if ! reflect .DeepEqual (snps , expected ) {
761+ t .Errorf ("expected %+v, got %+v\n " , expected , snps )
762+ }
763+ }
764+
765+ func TestClientUpdateFileShareSnapshot (t * testing.T ) {
766+ var snpID = "3769855c-a102-11e7-b772-17b880d2f537"
767+ body := & model.FileShareSnapshotSpec {
768+ Name : "sample-snapshot-01" ,
769+ Description : "This is the first sample snapshot for testing" ,
770+ }
771+
772+ snp , err := c .UpdateFileShareSnapshot (snpID , body )
773+ if err != nil {
774+ t .Error ("update file share snapshot in client failed:" , err )
775+ return
776+ }
777+
778+ var expected = & SampleFileShareSnapshots [0 ]
779+ if ! reflect .DeepEqual (snp , expected ) {
780+ t .Errorf ("expected %+v, got %+v\n " , expected , snp )
781+ }
782+ }
783+
784+ func TestClientDeleteFileShareAcl (t * testing.T ) {
785+ var fileshareaclID = "d2975ebe-d82c-430f-b28e-f373746a71ca"
786+
787+ if err := c .DeleteFileShareAcl (fileshareaclID ); err != nil {
788+ t .Error ("delete file share acl in client failed:" , err )
789+ return
790+ }
791+
792+ t .Log ("Delete file share acl success!" )
793+ }
794+
795+ func TestClientDeleteFileShareSnapshot (t * testing.T ) {
796+ var snapID = "3769855c-a102-11e7-b772-17b880d2f537"
797+
798+ if err := c .DeleteFileShareSnapshot (snapID ); err != nil {
799+ t .Error ("delete file share snapshot in client failed:" , err )
800+ return
801+ }
802+
803+ t .Log ("Delete file share snapshot success!" )
804+ }
805+
806+ func TestClientDeleteFileProfile (t * testing.T ) {
807+ var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
808+
809+ if err := c .DeleteProfile (prfID ); err != nil {
810+ t .Error ("delete profile in client failed:" , err )
811+ return
812+ }
813+
814+ t .Log ("Delete profile success!" )
815+ }
0 commit comments