Skip to content

Commit

Permalink
Add integration test cases of file share
Browse files Browse the repository at this point in the history
  • Loading branch information
Shruthi-1MN committed Oct 25, 2019
1 parent 3a0f4a2 commit 6bbbca4
Show file tree
Hide file tree
Showing 3 changed files with 129 additions and 9 deletions.
125 changes: 120 additions & 5 deletions test/integration/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,15 @@ func init() {

func TestClientCreateProfile(t *testing.T) {
var body = &model.ProfileSpec{
Name: "silver",
Description: "silver policy",
//BaseModel: &model.BaseModel{
// Id: "1106b972-66ef-11e7-b172-db03f3689c9c",
//},
Name: "default",
Description: "default policy",
StorageType: "block",
CustomProperties: model.CustomPropertiesSpec{
"diskType": "SAS",
},
//CustomProperties: model.CustomPropertiesSpec{
// "diskType": "SAS",
//},
}

prf, err := c.CreateProfile(body)
Expand Down Expand Up @@ -546,3 +549,115 @@ func TestClientFailoverReplication(t *testing.T) {
t.Log("Disable volume replication not ready!")
}
*/

/*
File share integration test cases
*/

func TestClientCreateFileProfile(t *testing.T) {
var body = &model.ProfileSpec{
Name: "gold",
Description: "gold policy",
StorageType: "block",
CustomProperties: model.CustomPropertiesSpec{
"diskType": "SAS",
},
}

prf, err := c.CreateProfile(body)
if err != nil {
t.Error("create profile in client failed:", err)
return
}
// If customized properties are not defined, create an empty one.
if prf.CustomProperties == nil {
prf.CustomProperties = model.CustomPropertiesSpec{}
}

var expected = &SampleFileShareProfiles[0]
if !reflect.DeepEqual(prf, expected) {
t.Errorf("expected %+v, got %+v\n", expected, prf)
}
}

//func TestClientGetProfile(t *testing.T) {
// var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
//
// prf, err := c.GetProfile(prfID)
// if err != nil {
// t.Error("get profile in client failed:", err)
// return
// }
//
// var expected = &SampleProfiles[1]
// if !reflect.DeepEqual(prf, expected) {
// t.Errorf("expected %+v, got %+v\n", expected, prf)
// }
//}
//
//func TestClientListProfiles(t *testing.T) {
// prfs, err := c.ListProfiles()
// if err != nil {
// t.Error("list profiles in client failed:", err)
// return
// }
// // If extras are not defined, create an empty one.
// for _, prf := range prfs {
// if prf.CustomProperties == nil {
// prf.CustomProperties = model.CustomPropertiesSpec{}
// }
// }
//
// var expected []*model.ProfileSpec
// for i := range SampleProfiles {
// expected = append(expected, &SampleProfiles[i])
// }
// if !reflect.DeepEqual(prfs, expected) {
// t.Errorf("expected %+v, got %+v\n", expected, prfs)
// }
//}
//
//func TestClientAddCustomProperty(t *testing.T) {
// var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
// var body = &model.CustomPropertiesSpec{
// "diskType": "SAS",
// }
//
// ext, err := c.AddCustomProperty(prfID, body)
// if err != nil {
// t.Error("add profile extra property in client failed:", err)
// return
// }
//
// var expected = &SampleProfiles[0].CustomProperties
// if !reflect.DeepEqual(ext, expected) {
// t.Errorf("expected %+v, got %+v\n", expected, ext)
// }
//}
//
//func TestClientListCustomProperties(t *testing.T) {
// var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
//
// ext, err := c.ListCustomProperties(prfID)
// if err != nil {
// t.Error("list profile customized properties in client failed:", err)
// return
// }
//
// var expected = &SampleProfiles[0].CustomProperties
// if !reflect.DeepEqual(ext, expected) {
// t.Errorf("expected %+v, got %+v\n", expected, ext)
// }
//}
//
//func TestClientRemoveCustomProperty(t *testing.T) {
// var prfID = "2f9c0a04-66ef-11e7-ade2-43158893e017"
// var customKey = "iops"
//
// if err := c.RemoveCustomProperty(prfID, customKey); err != nil {
// t.Error("remove profile customized property in client failed:", err)
// return
// }
//
// t.Log("Remove customized property <iops> success!")
//}
6 changes: 3 additions & 3 deletions testutils/collection/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ var (
BaseModel: &model.BaseModel{
Id: "1106b972-66ef-11e7-b172-db03f3689c9c",
},
Name: "default",
Name: "default_file",
Description: "default policy",
StorageType: "file",
CustomProperties: model.CustomPropertiesSpec{},
Expand All @@ -69,8 +69,8 @@ var (
BaseModel: &model.BaseModel{
Id: "2f9c0a04-66ef-11e7-ade2-43158893e017",
},
Name: "silver",
Description: "silver policy",
Name: "gold",
Description: "gold policy",
StorageType: "file",
CustomProperties: model.CustomPropertiesSpec{
"dataStorage": map[string]interface{}{
Expand Down
7 changes: 6 additions & 1 deletion testutils/db/fake.go
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,14 @@ func (fc *FakeDbClient) DeletePool(ctx *c.Context, polID string) error {

// CreateProfile
func (fc *FakeDbClient) CreateProfile(ctx *c.Context, prf *model.ProfileSpec) (*model.ProfileSpec, error) {
return &SampleProfiles[0], nil
if prf.StorageType == "file"{
return &SampleFileShareProfiles[0], nil
}else{
return &SampleProfiles[0], nil
}
}


// GetProfile
func (fc *FakeDbClient) GetProfile(ctx *c.Context, prfID string) (*model.ProfileSpec, error) {
for _, profile := range SampleProfiles {
Expand Down

0 comments on commit 6bbbca4

Please sign in to comment.