Skip to content

Commit a601155

Browse files
author
Shruthi-1MN
committed
Add integration test cases of file share
1 parent 3a0f4a2 commit a601155

3 files changed

Lines changed: 122 additions & 5 deletions

File tree

test/integration/client_test.go

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,3 +546,115 @@ 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: "block",
559+
CustomProperties: model.CustomPropertiesSpec{
560+
"diskType": "SAS",
561+
},
562+
}
563+
564+
prf, err := c.CreateProfile(body)
565+
if err != nil {
566+
t.Error("create profile in client failed:", err)
567+
return
568+
}
569+
// If customized properties are not defined, create an empty one.
570+
if prf.CustomProperties == nil {
571+
prf.CustomProperties = model.CustomPropertiesSpec{}
572+
}
573+
574+
var expected = &SampleFileShareProfiles[0]
575+
if !reflect.DeepEqual(prf, expected) {
576+
t.Errorf("expected %+v, got %+v\n", expected, prf)
577+
}
578+
}
579+
580+
//func TestClientGetProfile(t *testing.T) {
581+
// var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
582+
//
583+
// prf, err := c.GetProfile(prfID)
584+
// if err != nil {
585+
// t.Error("get profile in client failed:", err)
586+
// return
587+
// }
588+
//
589+
// var expected = &SampleProfiles[1]
590+
// if !reflect.DeepEqual(prf, expected) {
591+
// t.Errorf("expected %+v, got %+v\n", expected, prf)
592+
// }
593+
//}
594+
//
595+
//func TestClientListProfiles(t *testing.T) {
596+
// prfs, err := c.ListProfiles()
597+
// if err != nil {
598+
// t.Error("list profiles in client failed:", err)
599+
// return
600+
// }
601+
// // If extras are not defined, create an empty one.
602+
// for _, prf := range prfs {
603+
// if prf.CustomProperties == nil {
604+
// prf.CustomProperties = model.CustomPropertiesSpec{}
605+
// }
606+
// }
607+
//
608+
// var expected []*model.ProfileSpec
609+
// for i := range SampleProfiles {
610+
// expected = append(expected, &SampleProfiles[i])
611+
// }
612+
// if !reflect.DeepEqual(prfs, expected) {
613+
// t.Errorf("expected %+v, got %+v\n", expected, prfs)
614+
// }
615+
//}
616+
//
617+
//func TestClientAddCustomProperty(t *testing.T) {
618+
// var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
619+
// var body = &model.CustomPropertiesSpec{
620+
// "diskType": "SAS",
621+
// }
622+
//
623+
// ext, err := c.AddCustomProperty(prfID, body)
624+
// if err != nil {
625+
// t.Error("add profile extra property in client failed:", err)
626+
// return
627+
// }
628+
//
629+
// var expected = &SampleProfiles[0].CustomProperties
630+
// if !reflect.DeepEqual(ext, expected) {
631+
// t.Errorf("expected %+v, got %+v\n", expected, ext)
632+
// }
633+
//}
634+
//
635+
//func TestClientListCustomProperties(t *testing.T) {
636+
// var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
637+
//
638+
// ext, err := c.ListCustomProperties(prfID)
639+
// if err != nil {
640+
// t.Error("list profile customized properties in client failed:", err)
641+
// return
642+
// }
643+
//
644+
// var expected = &SampleProfiles[0].CustomProperties
645+
// if !reflect.DeepEqual(ext, expected) {
646+
// t.Errorf("expected %+v, got %+v\n", expected, ext)
647+
// }
648+
//}
649+
//
650+
//func TestClientRemoveCustomProperty(t *testing.T) {
651+
// var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
652+
// var customKey = "iops"
653+
//
654+
// if err := c.RemoveCustomProperty(prfID, customKey); err != nil {
655+
// t.Error("remove profile customized property in client failed:", err)
656+
// return
657+
// }
658+
//
659+
// t.Log("Remove customized property <iops> success!")
660+
//}

testutils/collection/data.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ var (
2929
BaseModel: &model.BaseModel{
3030
Id: "1106b972-66ef-11e7-b172-db03f3689c9c",
3131
},
32-
Name: "default",
32+
Name: "default_block",
3333
Description: "default policy",
3434
StorageType: "block",
3535
CustomProperties: model.CustomPropertiesSpec{},
@@ -60,7 +60,7 @@ var (
6060
BaseModel: &model.BaseModel{
6161
Id: "1106b972-66ef-11e7-b172-db03f3689c9c",
6262
},
63-
Name: "default",
63+
Name: "default_file",
6464
Description: "default policy",
6565
StorageType: "file",
6666
CustomProperties: model.CustomPropertiesSpec{},
@@ -69,8 +69,8 @@ var (
6969
BaseModel: &model.BaseModel{
7070
Id: "2f9c0a04-66ef-11e7-ade2-43158893e017",
7171
},
72-
Name: "silver",
73-
Description: "silver policy",
72+
Name: "gold",
73+
Description: "gold policy",
7474
StorageType: "file",
7575
CustomProperties: model.CustomPropertiesSpec{
7676
"dataStorage": map[string]interface{}{

testutils/db/fake.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,9 +285,14 @@ func (fc *FakeDbClient) DeletePool(ctx *c.Context, polID string) error {
285285

286286
// CreateProfile
287287
func (fc *FakeDbClient) CreateProfile(ctx *c.Context, prf *model.ProfileSpec) (*model.ProfileSpec, error) {
288-
return &SampleProfiles[0], nil
288+
if prf.StorageType == "file"{
289+
return &SampleFileShareProfiles[1], nil
290+
}else{
291+
return &SampleProfiles[1], nil
292+
}
289293
}
290294

295+
291296
// GetProfile
292297
func (fc *FakeDbClient) GetProfile(ctx *c.Context, prfID string) (*model.ProfileSpec, error) {
293298
for _, profile := range SampleProfiles {

0 commit comments

Comments
 (0)