Skip to content

Commit 6bbbca4

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

3 files changed

Lines changed: 129 additions & 9 deletions

File tree

test/integration/client_test.go

Lines changed: 120 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,15 @@ func init() {
3636

3737
func TestClientCreateProfile(t *testing.T) {
3838
var body = &model.ProfileSpec{
39-
Name: "silver",
40-
Description: "silver policy",
39+
//BaseModel: &model.BaseModel{
40+
// Id: "1106b972-66ef-11e7-b172-db03f3689c9c",
41+
//},
42+
Name: "default",
43+
Description: "default policy",
4144
StorageType: "block",
42-
CustomProperties: model.CustomPropertiesSpec{
43-
"diskType": "SAS",
44-
},
45+
//CustomProperties: model.CustomPropertiesSpec{
46+
// "diskType": "SAS",
47+
//},
4548
}
4649

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

testutils/collection/data.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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[0], nil
290+
}else{
291+
return &SampleProfiles[0], 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)