diff --git a/test/integration/client_test.go b/test/integration/client_test.go index eac133b4a..a89340208 100755 --- a/test/integration/client_test.go +++ b/test/integration/client_test.go @@ -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) @@ -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 success!") +//} \ No newline at end of file diff --git a/testutils/collection/data.go b/testutils/collection/data.go index 2af5b9597..f704db58b 100644 --- a/testutils/collection/data.go +++ b/testutils/collection/data.go @@ -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{}, @@ -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{}{ diff --git a/testutils/db/fake.go b/testutils/db/fake.go index fffedaf2c..0fc6d753f 100755 --- a/testutils/db/fake.go +++ b/testutils/db/fake.go @@ -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 {