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