From b8817dfd57829c104a5abf781808a991f02dbc27 Mon Sep 17 00:00:00 2001 From: Shruthi-1MN Date: Tue, 5 Nov 2019 11:42:17 +0530 Subject: [PATCH] E2E test cases for file share --- .travis.yml | 7 - .../fileshare_suit_test.go | 10 +- test/e2e/fileshare_test.go | 812 ++++++++++++++++++ test/e2e/utils/HttpHelper.go | 83 ++ test/e2e/utils/fileshare_helper.go | 173 ++++ test/integration/fileshare_test.go | 789 ----------------- test/integration/utils/DBHelper.go | 121 --- test/integration/utils/HttpHelper.go | 151 ---- test/integration/utils/LogReader.go | 77 -- 9 files changed, 1073 insertions(+), 1150 deletions(-) rename test/{integration => e2e}/fileshare_suit_test.go (89%) create mode 100644 test/e2e/fileshare_test.go create mode 100644 test/e2e/utils/HttpHelper.go create mode 100644 test/e2e/utils/fileshare_helper.go delete mode 100644 test/integration/fileshare_test.go delete mode 100644 test/integration/utils/DBHelper.go delete mode 100644 test/integration/utils/HttpHelper.go delete mode 100644 test/integration/utils/LogReader.go diff --git a/.travis.yml b/.travis.yml index dc3407521..4890e1693 100755 --- a/.travis.yml +++ b/.travis.yml @@ -21,16 +21,9 @@ before_install: - sudo apt-get install -y build-essential gcc - sudo apt-get install -y librados-dev librbd-dev - sudo apt-get install -y lvm2 tgt open-iscsi -<<<<<<< 0feeb98168409d1666fe427663d0ab192adb5e68 - sudo docker pull p1c2u/openapi-spec-validator - -======= - go get -v github.com/onsi/gomega - go get -v github.com/onsi/ginkgo/ginkgo - - go get github.com/modocache/gover - - go get -v -t ./... - - export PATH=$PATH:$HOME/gopath/bin ->>>>>>> end matrix: fast_finish: true diff --git a/test/integration/fileshare_suit_test.go b/test/e2e/fileshare_suit_test.go similarity index 89% rename from test/integration/fileshare_suit_test.go rename to test/e2e/fileshare_suit_test.go index 3a411ace2..60d54c375 100644 --- a/test/integration/fileshare_suit_test.go +++ b/test/e2e/fileshare_suit_test.go @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -// +build integration +// +build e2e -package integration +package e2e import ( "fmt" @@ -27,7 +27,7 @@ import ( //Function to run the Ginkgo Test func TestFileShareIntegration(t *testing.T) { gomega.RegisterFailHandler(ginkgo.Fail) - //var UID string + var _ = ginkgo.BeforeSuite(func() { fmt.Println("Before Suite Execution") @@ -36,5 +36,5 @@ func TestFileShareIntegration(t *testing.T) { ginkgo.By("After Suite Execution....!") }) - ginkgo.RunSpecs(t, "File Share Integration Test Suite") -} \ No newline at end of file + ginkgo.RunSpecs(t, "File Share E2E Test Suite") +} diff --git a/test/e2e/fileshare_test.go b/test/e2e/fileshare_test.go new file mode 100644 index 000000000..fd421b33a --- /dev/null +++ b/test/e2e/fileshare_test.go @@ -0,0 +1,812 @@ +// Copyright 2019 The OpenSDS Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +// +build e2e + +package e2e + +import ( + "testing" + + "github.com/onsi/ginkgo" + "github.com/onsi/gomega" + "github.com/opensds/opensds/test/e2e/utils" +) + +func TestFileShare(t *testing.T) { + gomega.RegisterFailHandler(ginkgo.Fail) + ginkgo.RunSpecs(t, "FileShare Suite") +} + +func clean_resource(name string){ + var fileshare_id,url string + ginkgo.It("TC_FS_IT_32: Delete fileshare by specifying fileshare id", func() { + gomega.Eventually(func() string { + fileshare_id = utils.Get_file_share_Id_by_name(name) + return fileshare_id + }).ShouldNot(gomega.Equal("None")) + url = "file/shares/" + fileshare_id + resp, err := utils.DELETE_method_call(url) + utils.Resp_processing(resp.StatusCode, err) + }) + ginkgo.It("TC_FS_IT_02: Get profile for file share", func() { + gomega.Eventually(func() string { + fileshare_id = utils.Get_file_share_Id_by_name(name) + return fileshare_id + }).Should(gomega.Equal("None")) + url = "file/shares/" + fileshare_id + resp, err := utils.GET_method_call(url) + utils.Resource_Not_found(resp.StatusCode, err) + }) +} + +func wait_for_available(name string){ + var fileshare_id, url string + ginkgo.It("TC_FS_IT_02: Get profile for file share", func() { + gomega.Eventually(func() string { + fileshare_id = utils.Get_file_share_Id_by_name(name) + return fileshare_id + }).ShouldNot(gomega.Equal("None")) + url = "file/shares/" + fileshare_id + resp, err := utils.GET_method_call(url) + utils.Resp_ok(resp.StatusCode, err) + }) +} + +var _ = ginkgo.Describe("FileShare Testing", func() { + + var url, profile_id string //fileshare_id, snap_id, acl_id string + var jsonStr map[string]interface{} + //big_name := "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhyutyuytuytututututututututututututututututututyuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg" + ginkgo.Context("Profile for FileShare Scenarios", func() { + //url = "profiles" + ////ginkgo.It("TC_FS_IT_01: Create profile for file share", func() { + //// jsonStr = map[string]interface{}{"name": "temp_profile", "description": "This is for TC_FS_IT_01", "storageType": "file"} + //// resp, err := utils.POST_method_call(jsonStr, url) + //// utils.Resp_ok(resp.StatusCode, err) + ////}) + //ginkgo.It("TC_FS_IT_02: Get profile for file share", func() { + // profile_id = utils.Get_profile_id_by_name("default_file") + // url = "profiles/" + profile_id + // resp, err := utils.GET_method_call(url) + // utils.Resp_ok(resp.StatusCode, err) + //}) + }) + ginkgo.Context("Create FileShare Scenarios", func() { + url = "file/shares" + ginkgo.It("TC_FS_IT_03: Create fileshare with name 'filesharetest1' and size 2", func() { + jsonStr = map[string]interface{}{"name": "filesharetest45", "description": "This is for TCFSIT03", "size": 2} + resp, err := utils.POST_method_call(jsonStr, url) + utils.Resp_processing(resp.StatusCode, err) + }) + wait_for_available("filesharetest45") + clean_resource("filesharetest45") + ginkgo.It("TC_FS_IT_04: Create fileshare name with empty string", func() { + jsonStr = map[string]interface{}{"name": "", "description": "This is for TCFSIT04", "size": 1} + resp, err := utils.POST_method_call(jsonStr, url) + utils.Not_allowed_operation(resp.StatusCode, err) + }) + //ginkgo.It("TC_FS_IT_05: Create file share name with non utf-8 character codes)", func() { + // jsonStr = map[string]interface{}{"name": "İnanç Esasları", "description": "This is for TCFSIT05", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("İnanç Esasları") + //clean_resource("İnanç Esasları") + //ginkgo.It("TC_FS_IT_06: Create file share name having special characters)", func() { + // jsonStr = map[string]interface{}{"name": "#Share !$!test", "description": "This is for TCFSIT06", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("#Share !$!test") + //clean_resource("#Share !$!test") + //ginkgo.It("TC_FS_IT_07: Create file share name starts with numbers)", func() { + // jsonStr = map[string]interface{}{"name": "23tmp", "description": "This is for TCFSIT07", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("23tmp") + //clean_resource("23tmp") + //ginkgo.It("TC_FS_IT_08: Create file share name length more than 255 characters)", func() { + // jsonStr = map[string]interface{}{"name": big_name, "description": "This is for TCFSIT08", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available(big_name) + //clean_resource(big_name) + //ginkgo.It("TC_FS_IT_09: Create file share description with empty string)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest2", "description": "", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest2") + //clean_resource("filesharetest2") + //ginkgo.It("TC_FS_IT_10: Create file share with description having special characters)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest3", "description": "#FileShare Code!$!test TC_FS_IT_10", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest3") + //clean_resource("filesharetest3") + //ginkgo.It("TC_FS_IT_11: Create file share name length more than 255 characters)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest4", "decription": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhyutyuytuytututututututututututututututututututyuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest4") + //clean_resource("filesharetest4") + //ginkgo.It("TC_FS_IT_12: Create file share without required parameters like fileshare name)", func() { + // jsonStr = map[string]interface{}{"description": "This is for TCFSIT12", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //ginkgo.It("TC_FS_IT_13: Create file share with size with -ve number)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest6", "description": "This is for TCFSIT13", "size": -1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest6") + //clean_resource("filesharetest6") + //ginkgo.It("TC_FS_IT_14: Create file share without required parameters like fileshare size)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest7", "description": "This is for TCFSIT14"} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest7") + //clean_resource("filesharetest7") + //ginkgo.It("TC_FS_IT_15: Create file share with size with +ve number)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest8", "description": "This is for TCFSIT15", "size": 2} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest8") + //clean_resource("filesharetest8") + //ginkgo.It("TC_FS_IT_16: Create file share with size with +ve number)", func() { + // cap := utils.Get_capacity_of_pool() + // free_capacity, err := strconv.Atoi(cap) + // jsonStr = map[string]interface{}{"name": "filesharetest9", "description": "This is for TCFSIT16", "size": free_capacity + 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest9") + //clean_resource("filesharetest9") + //ginkgo.It("TC_FS_IT_17: Create file share with size 0)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest10", "description": "This is for TCFSIT17", "size": 0} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest10") + //clean_resource("filesharetest10") + //ginkgo.It("TC_FS_IT_18: Create file share by specifying fileshare id)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest11", "description": "This is for TCFSIT18", "size": 1, "id": "5ce2fead-d404-47a6-b6b1-e2b069129240"} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest11") + //clean_resource("filesharetest11") + //ginkgo.It("TC_FS_IT_19: Create file share by specifying profile id)", func() { + // profile_id = utils.Get_profile_id_by_name("temp_profile") + // jsonStr = map[string]interface{}{"name": "filesharetest12", "description": "This is for TCFSIT19", "size": 1, "profileId": profile_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest12") + //clean_resource("filesharetest12") + //ginkgo.It("TC_FS_IT_20: Create file share by without specifying profile id)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest13", "description": "This is for TCFSIT20", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest13") + //clean_resource("filesharetest13") + //ginkgo.It("TC_FS_IT_21: Create file share by specifying wrong profile id)", func() { + // profile_id = utils.Get_profile_id_by_name("temp_profile") + // jsonStr = map[string]interface{}{"name": "filesharetest14", "description": "This is for TCFSIT21", "size": 1, "profileId": profile_id + "2"} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest14") + //clean_resource("filesharetest14") + //ginkgo.It("TC_FS_IT_22: Create file share by specifying availability zone)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest15", "description": "This is for TCFSIT22", "size": 1, "availabilityZone": "default"} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + //}) + //wait_for_available("filesharetest15") + //clean_resource("filesharetest15") + //ginkgo.It("TC_FS_IT_23: Create file share by specifying wrong availability zone)", func() { + // jsonStr = map[string]interface{}{"name": "filesharetest16", "description": "This is for TCFSIT23", "size": 1, "availabilityZone": "ndefault"} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + //}) + }) + //ginkgo.Context("Prepare for update fileshare scenarios", func() { + // url = "file/shares" + // //ginkgo.It("Dep_TC_FS_IT_24: Create file share for TC_FS_IT_24)", func() { + // // jsonStr = map[string]interface{}{"name": "testshare1", "description": "This is for DepTCFSIT24", "size": 1} + // // resp, err := utils.POST_method_call(jsonStr, url) + // // utils.Resp_processing(resp.StatusCode, err) + // //}) + // ginkgo.It("Dep_TC_FS_IT_25: Create file share for TC_FS_IT_25)", func() { + // jsonStr = map[string]interface{}{"name": "testshare2", "description": "This is for TCFSIT25", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_26: Create file share for TC_FS_IT_26)", func() { + // jsonStr = map[string]interface{}{"name": "testshare3", "description": "This is for TCFSIT26", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_27: Create file share for TC_FS_IT_27)", func() { + // jsonStr = map[string]interface{}{"name": "testshare4", "description": "This is for TCFSIT27", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // //ginkgo.It("Dep_TC_FS_IT_28: Create file share for TC_FS_IT_28)", func() { + // // jsonStr = map[string]interface{}{"name": "testshare5", "description": "This is for TCFSIT28", "size": 1} + // // resp, err := utils.POST_method_call(jsonStr, url) + // // utils.Resp_processing(resp.StatusCode, err) + // //}) + // //ginkgo.It("Dep_TC_FS_IT_29: Create file share for TC_FS_IT_29)", func() { + // // jsonStr = map[string]interface{}{"name": "testshare6", "description": "This is for TCFSIT29", "size": 1} + // // resp, err := utils.POST_method_call(jsonStr, url) + // // utils.Resp_processing(resp.StatusCode, err) + // //}) + // //ginkgo.It("Dep_TC_FS_IT_30: Create file share for TC_FS_IT_30)", func() { + // // jsonStr = map[string]interface{}{"name": "testshare7", "description": "This is for TCFSIT30", "size": 1} + // // resp, err := utils.POST_method_call(jsonStr, url) + // // utils.Resp_processing(resp.StatusCode, err) + // //}) + // //ginkgo.It("Dep_TC_FS_IT_31: Create file share for TC_FS_IT_31)", func() { + // // jsonStr = map[string]interface{}{"name": "testshare8", "description": "This is for TCFSIT31", "size": 1} + // // resp, err := utils.POST_method_call(jsonStr, url) + // // utils.Resp_processing(resp.StatusCode, err) + // //}) + //}) + //ginkgo.Context("Update FileShare Scenarios", func() { + // + // ginkgo.It("TC_FS_IT_24: Update fileshare with description empty/'' ", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("filesharetest13") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"description": " "} + // fileshare_id = utils.Get_file_share_Id_by_name("filesharetest1") + // url = "file/shares/" + fileshare_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + // + // ginkgo.It("TC_FS_IT_25: Update fileshare with name empty/'' ", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("filesharetest8") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": ""} + // url = "file/shares/" + fileshare_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_26: Update fileshare name within 255 characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("filesharetest2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "testshare3_renamed"} + // url = "file/shares/" + fileshare_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_27: Update fileshare name with special characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("filesharetest1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "#FileShare Code!$!test"} + // url = "file/shares/" + fileshare_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_28: Update fileshare name length greater than 255 characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("testshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhyutyuytuytututututututututututututututututututyuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"} + // url = "file/shares/" + fileshare_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_29: Update fileshare description with special characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("testshare3") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"description": "#FileShare Code!$!test"} + // url = "file/shares/" + fileshare_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_30: Update fileshare description length greater than 255 characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("testshare4") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"description": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhyutyuytuytututututututututututututututututututyuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"} + // url = "file/shares/" + fileshare_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_31: Update fileshare name with wrong resource id", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("testshare8") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "wrong_resource_update", "id": "fb5357a9-40cc-45a0-bdc2-14759e9c7d7a"} + // url = "file/shares/" + fileshare_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Delete FileShare Scenarios", func() { + // ginkgo.It("TC_FS_IT_32: Delete fileshare by specifying fileshare id", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("filesharetest13") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // url = "file/shares/" + fileshare_id + // resp, err := utils.DELETE_method_call(url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_33: Delete fileshare by specifying wrong fileshare id", func() { + // url = "file/shares/" + "fb5357a9-40cc-45a0-bdc2-14759e9c7d7a" + // resp, err := utils.DELETE_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Get FileShare Scenarios", func() { + // ginkgo.It("TC_FS_IT_34: Get fileshare by specifying fileshare id", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("testshare3_renamed") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // url = "file/shares/" + fileshare_id + // resp, err := utils.GET_method_call(url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_35: Get fileshare by specifying wrong fileshare id", func() { + // url = "file/shares/" + "901ce29a-24d6-4d52-be3e-02a1ac5a7b46" + // resp, err := utils.GET_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("List all fileShares", func() { + // ginkgo.It("TC_FS_IT_36: List all file shares", func() { + // url = "file/shares" + // resp, err := utils.GET_method_call(url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Prepare file share for snapshots", func() { + // url = "file/shares" + // ginkgo.It("Dep_TC_FS_IT_38: Create file share for TC_FS_IT_38)", func() { + // jsonStr = map[string]interface{}{"name": "snaptestshare1", "description": "This is for TCFSIT38", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_50: Create file share for TC_FS_IT_50)", func() { + // jsonStr = map[string]interface{}{"name": "snaptestshare2", "description": "This is for TCFSIT50", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Create file shares snapshot scenarios", func() { + // url = "file/snapshots" + // ginkgo.It("TC_FS_IT_38:Create file shares with name, description and fileshareId", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snap1", "description": "This is for TCFSIT38", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_39:Create file share snapshot name with empty string name", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "", "description": "This is for TCFSIT39", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_40:Create file share snapshot name with non utf-8 encoding characters)", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "İnanç Esasları", "description": "This is for TCFSIT40", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_41:Create file share snapshot name having special characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "Snapshot!$! test", "description": "This is for TCFSIT41", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_42:Create file share snapshot name starts with numbers", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "23snap", "description": "This is for TCFSIT42", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_43:Create file share snapshot name length more than 255 characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhyutyuytuytututututututututututututututututututyuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", "description": "This is for TCFSIT43", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_44:Create file share snapshot description with empty string", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snap2", "description": "", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_45:Create file share snapshot with description having special characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snap3", "description": "FileShare Code!$!test2", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_46:Create file share snapshot name length more than 255 characters", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snap4", "description": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhyutyuytuytututututututututututututututututututyuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_47:Create file share snapshot without required parameters like fileshare Id", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snap5", "description": "This is for TCFSIT47"} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_48:Create file share snapshot by specifying the profile id", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // gomega.Eventually(func() string { + // profile_id = utils.Get_profile_id_by_name("temp_profile") + // return profile_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snap5", "description": "This is for TCFSIT48", "fileshareId": fileshare_id, "profileId": profile_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_49:Create file share snapshot by specifying wrong/non-existing profile Id", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snap6", "description": "This is for TCFSIT22", "fileshareId": fileshare_id, "profileId": "5bc5d37e-da03-48be-b8b7-624d6c117cfb"} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Prepare for update file shares snapshot scenarios", func() { + // url = "file/snapshots" + // ginkgo.It("Dep_TC_FS_IT_50:Create file share snapshot with name, description and fileshareId", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snaptest1", "description": "This is for TCFSIT50", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_51:Create file share snapshot with name, description and fileshareId", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snaptest2", "description": "This is for TCFSIT51", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_52:Create file share snapshot with name, description and fileshareId", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snaptest3", "description": "This is for TCFSIT52", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_53:Create file share snapshot with name, description and fileshareId", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snaptest4", "description": "This is for TCFSIT53", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_54:Create file share snapshot with name, description and fileshareId", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snaptest5", "description": "This is for TCFSIT54", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_55:Create file share snapshot with name, description and fileshareId", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snaptest6", "description": "This is for TCFSIT55", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_56:Create file share snapshot with name, description and fileshareId", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("snaptestshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snaptest7", "description": "This is for TCFSIT56", "fileshareId": fileshare_id} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Update FileShare Snapshot Scenarios", func() { + // ginkgo.It("TC_FS_IT_50: Update fileshare snapshot with description empty/'' ", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest1") + // return snap_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"description": " "} + // url = "file/snapshots/" + snap_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + // + // ginkgo.It("TC_FS_IT_51: Update fileshare snapshot with name empty/'' ", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest2") + // return snap_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": " "} + // url = "file/snapshots/" + snap_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_52: Update fileshare snapshot name within 255 characters", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest3") + // return snap_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "snaptest3_renamed"} + // url = "file/snapshots/" + snap_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_53: Update fileshare snapshot name with special characters", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest4") + // return snap_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "#FileShare Snap!$!test"} + // url = "file/snapshots/" + snap_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_54: Update fileshare snapshot name length greater than 255 characters", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest5") + // return snap_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"name": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhyutyuytuytututututututututututututututututututyuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"} + // url = "file/snapshots/" + snap_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_55: Update fileshare snapshot description with special characters", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest6") + // return snap_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"description": "#FileShare Code!$!test"} + // url = "file/snapshots/" + snap_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_56: Update fileshare snapshot description length greater than 255 characters", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest7") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"description": "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhyutyuytuytututututututututututututututututututyuhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg"} + // url = "file/snapshots/" + snap_id + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_57: Update fileshare snapshot name with wrong resource id", func() { + // jsonStr = map[string]interface{}{"name": "wrong_resource_update"} + // url = "file/snapshots/fb5357a9-40cc-45a0-bdc2-14759e9c7d7a" + // resp, err := utils.PUT_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Delete FileShare Snapshot Scenarios", func() { + // ginkgo.It("TC_FS_IT_58: Delete fileshare snapshot by specifying fileshare snapshot id", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest1") + // return snap_id + // }).ShouldNot(gomega.Equal("None")) + // url = "file/snapshots/" + snap_id + // resp, err := utils.DELETE_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_59: Delete fileshare snapshot by specifying wrong fileshare snapshot id", func() { + // url = "file/snapshots/fb5357a9-40cc-45a0-bdc2-14759e9c7d7a" + // resp, err := utils.DELETE_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Get FileShare Snapshot Scenarios", func() { + // ginkgo.It("TC_FS_IT_60: Get fileshare snapshot by specifying fileshare snapshot id", func() { + // gomega.Eventually(func() string { + // snap_id = utils.Get_snapshot_Id_by_name("snaptest3_renamed") + // return snap_id + // }).ShouldNot(gomega.Equal("None")) + // url = "file/snapshots" + snap_id + // resp, err := utils.GET_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_61: Get fileshare snapshot by specifying wrong fileshare snapshot id", func() { + // url = "file/snapshots/901ce29a-24d6-4d52-be3e-02a1ac5a7b46" + // resp, err := utils.GET_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("List all fileshare snapshots", func() { + // ginkgo.It("TC_FS_IT_62: List all fileshare snapshots", func() { + // url = "file/snapshots" + // resp, err := utils.GET_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Prepare for create file share permission set scenarios", func() { + // ginkgo.It("Dep_TC_FS_IT_63: Create file share for TC_FS_IT_63)", func() { + // jsonStr = map[string]interface{}{"name": "acltestshare1", "description": "This is for TCFSIT63", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_64: Create file share for TC_FS_IT_24)", func() { + // jsonStr = map[string]interface{}{"name": "acltestshare2", "description": "This is for TCFSIT24", "size": 1} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("Dep_TC_FS_IT_69:Create the access to a valid IP for TC_FS_IT_69", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("acltestshare2") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"fileshareId": fileshare_id, "description": "file share acl test", "type": "ip", "accessTo": "10.32.104.4", "accessCapability": []string{"Read", "Write"}} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Create file shares acls scenarios", func() { + // url = "file/acls" + // ginkgo.It("TC_FS_IT_63:Create the access to a valid IP", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("acltestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"fileshareId": fileshare_id, "description": "file share acl test", "type": "ip", "accessTo": "10.32.104.2", "accessCapability": []string{"Read", "Write"}} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_64:Create the access to a invalid IP", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("acltestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"fileshareId": fileshare_id, "description": "file share acl test", "type": "ip", "accessTo": "10.32.104", "accessCapability": []string{"Read", "Write"}} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_65:Create the access to a valid IP segment, EX: 10.0.0.0/10", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("acltestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"fileshareId": fileshare_id, "description": "file share acl test", "type": "ip", "accessTo": "10.32.104.8/20", "accessCapability": []string{"Read", "Write"}} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_66:Create the access to a invalid IP segment, EX: 10.0.0.0/10.2", func() { + // gomega.Eventually(func() string { + // fileshare_id = utils.Get_file_share_Id_by_name("acltestshare1") + // return fileshare_id + // }).ShouldNot(gomega.Equal("None")) + // jsonStr = map[string]interface{}{"fileshareId": fileshare_id, "description": "file share acl test", "type": "ip", "accessTo": "10.32.104.8/20.2", "accessCapability": []string{"Read", "Write"}} + // resp, err := utils.POST_method_call(jsonStr, url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Delete FileShare Acl Scenarios", func() { + // ginkgo.It("TC_FS_IT_67: Delete fileshare acl by specifying fileshare acl id", func() { + // gomega.Eventually(func() string { + // acl_id = utils.Get_acl_Id_by_ip("10.32.104.2") + // return acl_id + // }).ShouldNot(gomega.Equal("None")) + // url = "file/acls/" + acl_id + // resp, err := utils.DELETE_method_call(url) + // utils.Resp_processing(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_68: Delete fileshare acl by specifying wrong fileshare acl id", func() { + // url = "file/acls/" + "fb5357a9-40cc-45a0-bdc2-14759e9c7d7a" + // resp, err := utils.DELETE_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("Get FileShare Acl Scenarios", func() { + // ginkgo.It("TC_FS_IT_69: Get fileshare acl by specifying fileshare acl id", func() { + // gomega.Eventually(func() string { + // acl_id = utils.Get_acl_Id_by_ip("10.32.104.4") + // return acl_id + // }).ShouldNot(gomega.Equal("None")) + // url = "file/acls" + acl_id + // resp, err := utils.GET_method_call(url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + // ginkgo.It("TC_FS_IT_70: Get fileshare acl by specifying wrong fileshare acl id", func() { + // url = "file/acls/901ce29a-24d6-4d52-be3e-02a1ac5a7b46" + // resp, err := utils.GET_method_call(url) + // utils.Not_allowed_operation(resp.StatusCode, err) + // }) + //}) + //ginkgo.Context("List all fileshare acls", func() { + // ginkgo.It("TC_FS_IT_71: List all fileshare acls", func() { + // url = "file/acls" + // resp, err := utils.GET_method_call(url) + // utils.Resp_ok(resp.StatusCode, err) + // }) + //}) +}) diff --git a/test/e2e/utils/HttpHelper.go b/test/e2e/utils/HttpHelper.go new file mode 100644 index 000000000..5d68c79b3 --- /dev/null +++ b/test/e2e/utils/HttpHelper.go @@ -0,0 +1,83 @@ +// Copyright 2019 The OpenSDS Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package utils + +import ( + "bytes" + "encoding/json" + "fmt" + "io" + "io/ioutil" + "net/http" + "os" +) + +func readResponseBody(resp *http.Response) { + if resp.StatusCode == http.StatusOK { + bodyBytes, err := ioutil.ReadAll(resp.Body) + if err != nil { + fmt.Printf("reading response body failed: %v", err) + } + bodyString := string(bodyBytes) + fmt.Printf(bodyString) + } +} + + +func ConnectToHTTP(operation, testMgrEndPoint string, payload map[string]interface{}) (*http.Response, error) { + var httpMethod string + + switch operation { + case "PUT": + httpMethod = http.MethodPut + + case "POST": + httpMethod = http.MethodPost + case "DELETE": + httpMethod = http.MethodDelete + + case "GET": + httpMethod = http.MethodGet + default: + + } + + respbytes, err := json.Marshal(payload) + if err != nil { + fmt.Printf("payload marshal failed: %v", err) + } + + req, err := http.NewRequest(httpMethod, testMgrEndPoint, bytes.NewBuffer(respbytes)) + if err != nil { + fmt.Printf("error while getting http request: %v", err) + + } + + client := &http.Client{} + req.Header.Set("Content-Type", "application/json") + resp, err := client.Do(req) + if err != nil { + fmt.Printf("hTTP request is failed :%v", err) + + } + if resp != nil { + fmt.Printf("resp is ... :%v", resp) + io.Copy(os.Stdout, resp.Body) + defer resp.Body.Close() + readResponseBody(resp) + } + + return resp, err +} \ No newline at end of file diff --git a/test/e2e/utils/fileshare_helper.go b/test/e2e/utils/fileshare_helper.go new file mode 100644 index 000000000..8a26efdb3 --- /dev/null +++ b/test/e2e/utils/fileshare_helper.go @@ -0,0 +1,173 @@ +package utils + +import ( + "encoding/json" + "fmt" + "github.com/onsi/gomega" + "io/ioutil" + "log" + "net/http" +) + +func Resp_ok(resp int, err error){ + gomega.Expect(resp).Should(gomega.Equal(200)) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + fmt.Println("Resp. Ok....") +} + +func Resp_processing(resp int, err error){ + gomega.Expect(resp).Should(gomega.Equal(202)) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + fmt.Println("Processing operations....") +} + +func Not_allowed_operation(resp int, err error){ + gomega.Expect(resp).Should(gomega.Equal(400)) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + fmt.Println("Not allowed operation....") +} + +func Resource_Not_found(resp int, err error){ + gomega.Expect(resp).Should(gomega.Equal(404)) + gomega.Expect(err).NotTo(gomega.HaveOccurred()) + fmt.Println("No resource....") +} + +func POST_method_call(jsonStr map[string]interface{}, url string) (*http.Response, error) { + inpurl := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/" + url + resp, err := ConnectToHTTP("POST", inpurl, jsonStr) + return resp, err +} + +func PUT_method_call(jsonStr map[string]interface{}, url string) (*http.Response, error) { + inpurl := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/" + url + resp, err := ConnectToHTTP("PUT", inpurl, jsonStr) + return resp, err +} + +func GET_method_call(url string) (*http.Response, error) { + inpurl := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/" + url + resp, err := ConnectToHTTP("GET", inpurl, nil) + return resp, err +} + +func DELETE_method_call(url string) (*http.Response, error) { + inpurl := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/" + url + resp, err := ConnectToHTTP("DELETE", inpurl, nil) + return resp, err +} + +func Non_read_onclose_get_method_call(url string)([]map[string]interface{}){ + res, err := http.Get("http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/"+url) + if err != nil { + log.Fatalln(err) + } + + defer res.Body.Close() + body, err := ioutil.ReadAll(res.Body) + if err != nil { + log.Fatalln(err) + } + lstmap := []map[string]interface{}{} + if err := json.Unmarshal(body, &lstmap); err != nil { + panic(err) + } + return lstmap +} + +func Get_profile_id_by_name(name string) string { + profileslstmap := Non_read_onclose_get_method_call("profiles") + for _, k := range profileslstmap { + profilename := fmt.Sprintf("%v", k["name"]) + storagetype := fmt.Sprintf("%v", k["storageType"]) + if profilename == name && storagetype == "file" { + id := fmt.Sprintf("%v", k["id"]) + return id + } + } + return "None" +} + +func Get_file_share_Id_by_name(name string) string { + filesharelstmap := Non_read_onclose_get_method_call("file/shares") + for _, k := range filesharelstmap { + filesharename := fmt.Sprintf("%v", k["name"]) + status := fmt.Sprintf("%v", k["status"]) + if name == filesharename && status == "available" { + id := fmt.Sprintf("%v", k["id"]) + return id + } + } + return "None" +} + +func Get_snapshot_Id_by_name(name string) string { + filesharelstmap := Non_read_onclose_get_method_call("file/snapshots") + for _, k := range filesharelstmap { + snapname := fmt.Sprintf("%v", k["name"]) + status := fmt.Sprintf("%v", k["status"]) + if name == snapname && status == "available" { + id := fmt.Sprintf("%v", k["id"]) + return id + } + } + return "None" +} + +func Get_acl_Id_by_ip(name string) string { + filesharelstmap := Non_read_onclose_get_method_call("file/acls") + for _, k := range filesharelstmap { + ipaddr := fmt.Sprintf("%v", k["ip"]) + status := fmt.Sprintf("%v", k["status"]) + if name == ipaddr && status == "available" { + id := fmt.Sprintf("%v", k["id"]) + return id + } + } + return "None" +} + +func Get_all_file_shares()([]map[string]interface{}){ + filesharelstmap := Non_read_onclose_get_method_call("file/shares") + return filesharelstmap +} + + +func Get_capacity_of_pool()string{ + poolslstmap := Non_read_onclose_get_method_call("pools") + for _, k := range poolslstmap { + poolname := fmt.Sprintf("%v", k["name"]) + pool_freecapacity := fmt.Sprintf("%v", k["freeCapacity"]) + if poolname == "opensds-files-default"{ + return pool_freecapacity + } + } + return "None" +} + +//func Validateresponsecode(respcode int, err error) { + // switch respcode{ + // case 200: + // gomega.Expect(respcode).Should(gomega.Equal(200)) + // gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // fmt.Println("Resp. Ok....") + // case 202: + // gomega.Expect(respcode).Should(gomega.Equal(202)) + // gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // fmt.Println("Processing req....") + // case 500: + // gomega.Expect(respcode).Should(gomega.Equal(500)) + // gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // fmt.Println("Internal server error....") + // case 404: + // gomega.Expect(respcode).Should(gomega.Equal(404)) + // gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // fmt.Println("Resource not found....") + // case 400: + // gomega.Expect(respcode).Should(gomega.Equal(400)) + // gomega.Expect(err).NotTo(gomega.HaveOccurred()) + // fmt.Println("Bad req....") + // default: + // fmt.Println("Test case failed") + // } + //} \ No newline at end of file diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go deleted file mode 100644 index 1e6f5f539..000000000 --- a/test/integration/fileshare_test.go +++ /dev/null @@ -1,789 +0,0 @@ -// Copyright 2019 The OpenSDS Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// +build integration - -package integration - -import ( - "encoding/json" - "fmt" - "github.com/onsi/ginkgo" - "github.com/onsi/gomega" - "github.com/opensds/opensds/test/integration/utils" - "io/ioutil" - "log" - "net/http" - "testing" - "time" -) - -func TestFileShare(t *testing.T) { - gomega.RegisterFailHandler(ginkgo.Fail) - ginkgo.RunSpecs(t, "FileShare Suite") -} - -var ( - OPERATION_FAILED = "OPERATION_FAILED" - file_shares = []string{"hjk1", "", "İnanç Esasları", "#FileShare Code!$!test", "123tmp1", "abqwqwqwggg012345678910gggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", - "mno2", "mno3", "mno4", "mno5", "mno6", "mno7", "mno8", "mno9", "mno10", "hjk1", "mno12", "mno13", "mno14", "mno15", "mno16", "mno17",//6-21 - "mno18", "mno19", "mno20", "mno21", "mno22", "$File$Test!1"}//22-27 - file_share_snapshots = []string{"snap1", "snap2", "snap3", "snap4", "snap5", "snap6", "snap7", "snap8", "snap9", "snap10", "snap11", "snap12", "snap13", "snap14", "snap15", "snap16", "snap17", - "snap18", "snap19", "snap20", "snap21", "snap22", "snap23"} -) - -func get_profile_id()string{ - res, err := http.Get("http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/profiles") - if err != nil{ - log.Fatalln(err) - } - - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil{ - log.Fatalln(err) - } - - filesharelstmap := []map[string]interface{}{} - if err := json.Unmarshal(body, &filesharelstmap); err != nil { - panic(err) - } - for _,k := range filesharelstmap{ - profilename := fmt.Sprintf("%v", k["name"]) - fmt.Println("+++++++++++++++++++++++++++++++++++++++",profilename) - storagetype := fmt.Sprintf("%v",k["storageType"]) - if profilename == "mpolicy" && storagetype == "file"{ - id := fmt.Sprintf("%v", k["id"]) - return id - } - } - return "None" -} - -func get_all_file_share_snapshots()[]map[string]interface{}{ - res, err := http.Get("http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots") - if err != nil{ - log.Fatalln(err) - } - - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil{ - log.Fatalln(err) - } - - filesharesnaplstmap := []map[string]interface{}{} - if err := json.Unmarshal(body, &filesharesnaplstmap); err != nil { - panic(err) - } - return filesharesnaplstmap -} - -func get_file_share_snapshots_Id_by_name(name string) string{ - filesharelstmap := get_all_file_share_snapshots() - for _,k := range filesharelstmap{ - filesharename := fmt.Sprintf("%v", k["name"]) - status := fmt.Sprintf("%v", k["status"]) - if name == filesharename && status == "available"{ - id := fmt.Sprintf("%v", k["id"]) - return id - } - } - return "None" -} - -func get_all_file_shares()[]map[string]interface{}{ - res, err := http.Get("http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares") - if err != nil{ - log.Fatalln(err) - } - - defer res.Body.Close() - body, err := ioutil.ReadAll(res.Body) - if err != nil{ - log.Fatalln(err) - } - - filesharelstmap := []map[string]interface{}{} - if err := json.Unmarshal(body, &filesharelstmap); err != nil { - panic(err) - } - return filesharelstmap -} - -func get_file_share_Id_by_name(name string) string{ - filesharelstmap := get_all_file_shares() - for _,k := range filesharelstmap{ - filesharename := fmt.Sprintf("%v", k["name"]) - status := fmt.Sprintf("%v", k["status"]) - if name == filesharename && status == "available"{ - id := fmt.Sprintf("%v", k["id"]) - return id - } - } - return "None" -} - -func hello(done chan bool) { - fmt.Println("hello go routine is going to sleep") - ////gomega.Eventually(get_profile_id(),(80 * time.Second), (time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - //profile_id := get_profile_id() - //fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",profile_id) - //var jsonStr= map[string]interface{}{"name": file_shares[0], "description": "This is just for TCFSIT01", "size": 1,"profileId":profile_id} - //url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - //methodName := "POST" - //resp, err := utils.ConnectToHTTP(methodName, url, jsonStr) - //fmt.Println(resp.Body) - //gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - //gomega.Expect(err).NotTo(gomega.HaveOccurred()) - - var jsonStr= map[string]interface{}{"name": "mpolicy", "description": "This is just to test all file share test cases", "storageType":"file"} - url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/profiles" - methodName := "POST" - resp, err := utils.ConnectToHTTP(methodName, url, jsonStr) - - fmt.Println("End of profile creation============================ ")//, body) - gomega.Expect(resp.StatusCode).Should(gomega.Equal(200)) - gomega.Expect(err).NotTo(gomega.HaveOccurred()) - time.Sleep(60 * time.Second) - fmt.Println("hello go routine awake and going to write to done") - done <- true -} - -var _ = ginkgo.Describe("FileShare Testing", func() { - ginkgo.Context("Create FileShare Scenarios", func() { - - var profile_id string - ginkgo.BeforeEach(func() { - //profile_id = get_profile_id() - //fmt.Println(profile_id) - - }) - - ginkgo.It("TC_FS_IT_01: Create profile for file share", func() { - done := make(chan bool) - fmt.Println("Main going to call hello go goroutine") - go hello(done) - <-done - profile_id = get_profile_id() - fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",profile_id) - fId := "v1beta/file/shares/e93b4c0934da416eb9c8d120c5d04d96/"+profile_id - ret := utils.GetValueByKeyFromDB(fId) - gomega.Expect(ret).ShouldNot(gomega.Equal(OPERATION_FAILED)) - fmt.Println("Main received data") - }) - ginkgo.It("TC_FS_IT_02: Get profile for file share", func() { - //var jsonStr= map[string]interface{}{"name": "policy", "description": "This is just to test all file share test cases", "storageType":"file"} - profile_id = get_profile_id() - fmt.Println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>",profile_id) - url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/profiles/"+profile_id - methodName := "GET" - resp, err := utils.ConnectToHTTP(methodName, url, nil) - fmt.Println(resp.Body) - gomega.Expect(resp.StatusCode).Should(gomega.Equal(200)) - gomega.Expect(err).NotTo(gomega.HaveOccurred()) - }) - //ginkgo.It("TC_FS_IT_01: Create fileshare with name input", func() { - - // - //}) - //ginkgo.It("TC_FS_IT_02: Create fileshare with empty file share name", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[1], "description": "This is just for TCFSIT02", "size": 2} - // url := "http://localhost:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, _ := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - //}) - //ginkgo.It("TC_FS_IT_03: Create file share name with other encoding characters(except utf-8)", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[2], "description": "This is just for TCFSIT03", "size": 2} - // url := "http://localhost:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_04: Create file share name having special characters", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[3], "description": "This is just for TCFSIT04", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, _ := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - //}) - //ginkgo.It("TC_FS_IT_05: Create file share name starts with numbers", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[4], "description": "This is just for TCFSIT05", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_06: Create file share name length more than 255 characters", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[5], "description": "This is just for TCFSIT06", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_08: Create file share description with empty string", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[6], "description": "", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_09: Create file share with description having special characters", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[7], "description": "#FileShare Code!$!test", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_10: Create file share with description with more than 255 characters", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[8], "description": "abqwqwqwggg012345678910ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", - // "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_11: Create file share without required parameters like fileshare name, size", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[9], "description": " "} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_12: Create file share with size with -ve number", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[10], "description": "This is just for TCFSIT12", "size": -2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_13: Create file share with size with +ve number", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[11], "description": "This is just for TCFSIT13", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_14: Create file share with size with more than total capacity", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[12], "description": "This is just for TCFSIT14", "size": 50} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_15: Create file share Size with 0", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[13], "description": "This is just for TCFSIT15", "size": 0} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_16: Create file share by specifying the File Share Id", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[14], "description": "This is just for TCFSIT16", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - ////profile_id := get_profile_id() - ////fmt.Println(profile_id) - //ginkgo.It("TC_FS_IT_17: Create file share by specifying the Profile id", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[15], "description": "This is just for TCFSIT17", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_18: Create file share by without specifying Profile Id", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[16], "description": "This is just for TCFSIT18", "size": 2} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_19: Create file share by specifying wrong profile Id", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[17], "description": "This is just for TCFSIT19", "size": 2, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_20: Create file share by specifying Availability zone name", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[18], "description": "This is just for TCFSIT20", "size": 2, "availabillityZone": "default"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - //ginkgo.It("TC_FS_IT_21: Create file share by specifying wrong Availability zone name", func() { - // var jsonStr2= map[string]interface{}{"name": file_shares[19], "description": "This is just for TCFSIT21", "size": 2, "availabillityZone": "default1"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - }) - //ginkgo.Context("Create FileShare Snapshots Scenarios", func() { - // var fileshareid string - // filesharename := file_shares[15] - // fmt.Println(filesharename) - // ginkgo.BeforeEach(func() { - // fileshareid = get_file_share_Id_by_name(filesharename) - // }) - // ginkgo.It("TC_FS_IT_22: Create fileshare snapshot with name input", func() { - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second), (time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr = map[string]interface{}{"name": file_share_snapshots[0], "description": "This is just for TCFSIT22"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_23: Create fileshare snapshot with empty file share snapshot name", func() { - // filesharename = file_shares[16] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": " ", "description": "This is just for TCFSIT23", "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, _ := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // }) - // ginkgo.It("TC_FS_IT_24: Create file share snapshot name with other encoding characters(except utf-8)", func() { - // filesharename = file_shares[18] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_shares[2], "description": "This is just for TCFSIT24", "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_25: Create file share snapshot name having special characters", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_shares[3], "description": "This is just for TCFSIT25", "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, _ := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - //}) - // ginkgo.It("TC_FS_IT_26: Create file share snapshot name starts with numbers", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_shares[4], "description": "This is just for TCFSIT26", "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_27: Create file share snapshot name length more than 255 characters", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_shares[5], "description": "This is just for TCFSIT27", " "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_28: Create file share snapshot description with empty string", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[6], "description": "This is just for TCFSIT28", "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_29: Create file share snapshot with description having special characters", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[7], "description": "#FileShare Code!$!test", "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_30: Create file share snapshot with description with more than 255 characters", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[8], "description": "abqwqwqwggg012345678910ggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggghhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", - // "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_31: Create file share snapshot without required parameters like fileshare snapshot name", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"description": "This is just for TCFSIT31", "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_32: Create file share snapshot by specifying the File Share snapshot Id", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[14], "description": "This is just for TCFSIT32", "fileshareId":fileshareid, "id":"04f46c79-9498-4d29-a4d3-7996386723cc"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // profile_id := get_profile_id() - // fmt.Println(profile_id) - // ginkgo.It("TC_FS_IT_33: Create file share snapshot by specifying the Profile id", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[15], "description": "This is just for TCFSIT33", "fileshareId":fileshareid, "profileId": profile_id} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_34: Create file share snapshot by without specifying Profile Id", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[16], "description": "This is just for TCFSIT34", "fileshareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_35: Create file share snapshot by specifying wrong profile Id", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[17], "description": "This is just for TCFSIT35", "fileshareId":fileshareid, "profileId": "df40af1a-17b5-48e5-899f-fa098b0bd5da"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_36: Create file share snapshot by specifying Availability zone name", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[18], "description": "This is just for TCFSIT36", "fileshareId":fileshareid, "availabillityZone": "default"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_37: Create file share snapshot by specifying wrong Availability zone name", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"name": file_share_snapshots[19], "description": "This is just for TCFSIT37", "fileshareId":fileshareid, "availabillityZone": "default1"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - //}) - //ginkgo.Context("Create FileShare Access Permission Scenarios", func() { - // ginkgo.It("TC_FS_IT_38: Create file share access permission by providing valid IP", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"type":"ip","accessCapability":[]string{"read", "write"}, "accessTo":"10.32.105.191", "description": "This is just for TCFSIT38", "shareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/acls" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_39: Create file share access permission by providing Invalid IP", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"type":"ip","accessCapability":[]string{"read", "write"}, "accessTo":"10.32.105", "description": "This is just for TCFSIT39", "shareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/acls" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // ginkgo.It("TC_FS_IT_40: Create the access to a valid IP segment, EX: 10.0.0.0/10", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"type":"ip","accessCapability":[]string{"read", "write"}, "accessTo":"10.32.105.10/10", "description": "This is just for TCFSIT40", "shareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/acls" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // ginkgo.It("TC_FS_IT_41: Create the access to a Invalid IP segment, EX: 10.0.0.0/10", func() { - // filesharename = file_shares[11] - // gomega.Eventually(get_file_share_Id_by_name(filesharename),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid = get_file_share_Id_by_name(filesharename) - // var jsonStr2= map[string]interface{}{"type":"ip","accessCapability":[]string{"read", "write"}, "accessTo":"10.32.105.10/10.10", "description": "This is just for TCFSIT41", "shareId":fileshareid} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/acls" - // methodName := "POST" - // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(400)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) -// }) - //}) - //ginkgo.Context("Get FileShare Scenarios", func() { - // ginkgo.It("TC_FS_IT_42: Get file share by specifying FileShareID", func() { - // gomega.Eventually(get_file_share_Id_by_name("hjk1"),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // fileshareid := get_file_share_Id_by_name("hjk1") - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/"+fileshareid - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(200)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // ginkgo.It("TC_FS_IT_43: Get file share by specifying wrong/non-existing FileShareID", func() { - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/"+fileshareid+"1" - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(404)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - }) - //ginkgo.Context("Get FileShare Snapshots Scenarios", func() { - // ginkgo.It("TC_FS_IT_44: Get file share snapshot by specifying SnapID", func() { - // gomega.Eventually(get_file_share_snapshots_Id_by_name("snap1"),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // snapid = get_file_share_snapshots_Id_by_name("snap1") - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots/"+snapid - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(200)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // snapid = get_file_share_snapshots_Id_by_name("snap1") - // ginkgo.It("TC_FS_IT_45: Get file share by specifying wrong/non-existing FileShareID", func() { - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots/"+snapid+"1" - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(404)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - //}) - //ginkgo.Context("Get FileShare Access Permissions Scenarios", func() { - // ginkgo.It("TC_FS_IT_46: Get file share acl by specifying aclID", func() { - // gomega.Eventually(get_file_share_acls_Id_by_name("snap1"),(60 * time.Second)).ShouldNot(gomega.BeEquivalentTo("None")) - // aclid = get_file_share_snapshots_Id_by_name("snap1") - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/acls/"+aclid - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(200)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // aclid = get_file_share_acls_Id_by_name("snap1") - // ginkgo.It("TC_FS_IT_47: Get file share acl by specifying wrong/non-existing aclid", func() { - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/acls/"+aclid+"1" - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(404)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - //}) - //ginkgo.Context("List FileShare Scenarios", func() { - // ginkgo.It("TC_FS_IT_47: List all file shares", func() { - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(200)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - //}) - //ginkgo.Context("List FileShare Snapshot Scenarios", func() { - // ginkgo.It("TC_FS_IT_47: List all file share snapshots", func() { - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots" - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(200)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - //}) - //ginkgo.Context("List FileShare Acccess Permissions Scenarios", func() { - // ginkgo.It("TC_FS_IT_47: List all file share acls", func() { - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/acls" - // methodName := "GET" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(200)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - //}) - //ginkgo.Context("Update FileShare Scenarios", func() { - // //ginkgo.It("TC_FS_IT_22: Update file share name with empty string", func() { - // // var jsonStr2 = map[string]interface{}{"name": file_shares[1], "description": "This is test for case TC_FS_IT_22"} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/add61d3c-5248-4dec-8d0d-9e84fd6fbbb6" - // // methodName := "PUT" - // // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - // //ginkgo.It("TC_FS_IT_23: Update file share name with special character string", func() { - // // var jsonStr2 = map[string]interface{}{"name":file_shares[27], "description": "This is test for case TC_FS_IT_23"} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96 /file/shares/e3885ace-23d4-4a52-a47f-0efc87b82821" - // // methodName := "PUT" - // // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - // //ginkgo.It("TC_FS_IT_24: Update file share name length greater than 255 characters", func() { - // // var jsonStr2 = map[string]interface{}{"name": file_shares[5]+"ffffffgfgfgfgffffffffffgffffffffffffffgfgfggggggggggggggggggggggggggggggggggggggggggggggggggggggggggggg", "description": "This is test for case TC_FS_IT_24"} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/ea5b77d1-9cb1-4ccc-b5a5-7126e1f6fffb" - // // methodName := "PUT" - // // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - // //ginkgo.It("TC_FS_IT_25: Update file share Description with empty string", func() { - // // var jsonStr2 = map[string]interface{}{"description": " "} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" - // // methodName := "PUT" - // // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - // //ginkgo.It("TC_FS_IT_26: Update file share Description with special characters", func() { - // // var jsonStr2 = map[string]interface{}{"description": " "} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" - // // methodName := "PUT" - // // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - // //ginkgo.It("TC_FS_IT_27: Update file share Description length more than 255 characters", func() { - // // var jsonStr2 = map[string]interface{}{"description": " "} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" - // // methodName := "PUT" - // // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - // //ginkgo.It("TC_FS_IT_28: Update file share Description with non utf-8 code characters", func() { - // // var jsonStr2 = map[string]interface{}{"description": " "} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" - // // methodName := "PUT" - // // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - // //ginkgo.It("TC_FS_IT_29: Update file share with wrong File Share Id", func() { - // // var jsonStr2 = map[string]interface{}{"description": " "} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/de3c2b70-ae83-4a90-b5be-c792d22c7930" - // // methodName := "PUT" - // // resp, err := utils.ConnectToHTTP(methodName, url, jsonStr2) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - //}) - //ginkgo.Context("Update FileShare Snapshots Scenarios", func() { - // - //}) - //ginkgo.Context("Update FileShare Access Permissions Scenarios", func() { - // - //}) - //ginkgo.Context("Delete FileShare Access Permissions Scenarios", func() { - // - //}) - //ginkgo.Context("Delete FileShare Snapshots Scenarios", func() { - // filesharelstmap := get_all_file_share_snapshots() - // for _,k := range filesharelstmap{ - // id := fmt.Sprintf("%v", k["id"]) - // ginkgo.It("TC_FS_IT_32: Delete all file shares", func() { - // //var jsonStr2 = map[string]interface{}{"name": file_shares[19], "description": " ", "size": 2, "availabillityZone": "default1"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/snapshots/"+id - // methodName := "DELETE" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - // } - //}) - //ginkgo.Context("Delete FileShare Scenarios", func() { - // fmt.Println(file_shares[11]) - // fileshareid := get_file_share_Id_by_name("xyz11") - // fmt.Println(fileshareid) - // //ginkgo.It("TC_FS_IT_31: Delete file share by specifying FileShare ID", func() { - // // //var jsonStr2 = map[string]interface{}{"name": file_shares[19], "description": " ", "size": 2, "availabillityZone": "default1"} - // // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/"+fileshareid - // // methodName := "DELETE" - // // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // //}) - // ginkgo.It("TC_FS_IT_31: Delete file share by specifying wrong/non existing FileShare ID", func() { - // //var jsonStr2 = map[string]interface{}{"name": file_shares[19], "description": " ", "size": 2, "availabillityZone": "default1"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/"+fileshareid+"2" - // methodName := "DELETE" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(404)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - //}) - - //filesharelstmap := get_all_file_shares() - //for _,k := range filesharelstmap{ - // id := fmt.Sprintf("%v", k["id"]) - // ginkgo.It("TC_FS_IT_32: Delete all file shares", func() { - // //var jsonStr2 = map[string]interface{}{"name": file_shares[19], "description": " ", "size": 2, "availabillityZone": "default1"} - // url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/"+id - // methodName := "DELETE" - // resp, err := utils.ConnectToHTTP(methodName, url, nil) - // gomega.Expect(resp.StatusCode).Should(gomega.Equal(202)) - // gomega.Expect(err).NotTo(gomega.HaveOccurred()) - // }) - //} - //}) -//}) diff --git a/test/integration/utils/DBHelper.go b/test/integration/utils/DBHelper.go deleted file mode 100644 index 433d8eddb..000000000 --- a/test/integration/utils/DBHelper.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright 2019 The OpenSDS Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package utils - -import ( - "context" - "fmt" - "log" - "time" - - "github.com/coreos/etcd/clientv3" -) - -var ( - dialTimeout = 10 * time.Second - requestTimeout = 200 * time.Second -) - -func GetValueByKeyFromDB(key string) string { - ctx, _ := context.WithTimeout(context.Background(), requestTimeout) - cli, err := clientv3.New(clientv3.Config{ - DialTimeout: dialTimeout, - Endpoints: []string{"192.168.20.123:62379"}, - }) - if err != nil { - log.Fatal(err) - // can define the below one in constants file and import - return "OPERATION_FAILED" - } - defer cli.Close() - kv := clientv3.NewKV(cli) - //GetallKeys(ctx, kv, key) - GetValueByKey(ctx, kv, key) - // GetSingleValueDemo(ctx, kv) - // GetMultipleValuesWithPaginationDemo(ctx, kv) - // WatchDemo(ctx, cli, kv) - // LeaseDemo(ctx, cli, kv) - return "Done" -} - -func GetallKeys(ctx context.Context, kv clientv3.KV, key string) string { - opts := []clientv3.OpOption{ - clientv3.WithPrefix(), - clientv3.WithSort(clientv3.SortByKey, clientv3.SortAscend), - clientv3.WithLimit(3), - } - - gr, _ := kv.Get(ctx, "key", opts...) - - fmt.Println("--- First page ---") - for _, item := range gr.Kvs { - fmt.Println(string(item.Key), string(item.Value)) - } - return "Done2" -} - -func GetKeys(ctx context.Context, kv clientv3.KV, key string) string { - fmt.Println("*** GetKeys()") - // Delete all keys - // kv.Delete(ctx, "key", clientv3.WithPrefix()) - gr, err := kv.Get(ctx, "v1beta/file/shares/e93b4c0934da416eb9c8d120c5d04d96") - if err != nil { - log.Fatal(err) - // can define the below one in constants file and import - return "OPERATION_FAILED" - } - - fmt.Println("Value: ", string(gr.Kvs[0].Value), "Revision: ", gr.Header.Revision) - return string(gr.Kvs[0].Value) -} - -func GetValueByKey(ctx context.Context, kv clientv3.KV, key string) string { - fmt.Println("*** GetValueByKey()") - // Delete all keys - // kv.Delete(ctx, "key", clientv3.WithPrefix()) - - // // Insert a key value - // pr, err := kv.Put(ctx, "key", "444") - // if err != nil { - // log.Fatal(err) - // } - - // rev := pr.Header.Revision - - // fmt.Println("Revision:", rev) - - // gr, err := kv.Get(ctx, "v1beta/file/shares/e93b4c0934da416eb9c8d120c5d04d96/f2ab9308-f208-40c6-bb1f-6fbfa8bf14b5") - //gr, err := kv.Get(ctx, "v1beta/file/shares") - // 09b1c6e4-9dac-46cc-bb09-54795a354a79 - //gr, err := kv.Get(ctx, "09b1c6e4-9dac-46cc-bb09-54795a354a79") - - gr, err := kv.Get(ctx, key) - if err != nil { - log.Fatal(err) - // can define the below one in constants file and import - return "OPERATION_FAILED" - } - - fmt.Println("Value: ", string(gr.Kvs[0].Value), "Revision: ", gr.Header.Revision) - return string(gr.Kvs[0].Value) - // // Modify the value of an existing key (create new revision) - // kv.Put(ctx, "key", "555") - - // gr, _ = kv.Get(ctx, "key") - // fmt.Println("Value: ", string(gr.Kvs[0].Value), "Revision: ", gr.Header.Revision) - - // // Get the value of the previous revision - // gr, _ = kv.Get(ctx, "key", clientv3.WithRev(rev)) - // fmt.Println("Value: ", string(gr.Kvs[0].Value), "Revision: ", gr.Header.Revision) -} \ No newline at end of file diff --git a/test/integration/utils/HttpHelper.go b/test/integration/utils/HttpHelper.go deleted file mode 100644 index 942562f27..000000000 --- a/test/integration/utils/HttpHelper.go +++ /dev/null @@ -1,151 +0,0 @@ -// Copyright 2019 The OpenSDS Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package utils - -import ( - "bytes" - "encoding/json" - "fmt" - "io" - "io/ioutil" - "net/http" - "os" -) - -func ConnectToHttpPost(operation, testMgrEndPoint string, payload []byte) { - respbytes, err := json.Marshal(payload) - req, err := http.NewRequest(http.MethodPost, testMgrEndPoint, bytes.NewBuffer(respbytes)) - if err != nil { - // handle error - // common.Failf("Frame HTTP request failed: %v", err) - - fmt.Printf("Error while getting http request: %v", err) - // return false - } - - // client := &http.Client{} - req.Header.Set("Content-Type", "application/json") - // t := time.Now() - resp, err := http.Post(testMgrEndPoint, "application/json", req.Body) - - if err != nil { - // handle error - fmt.Printf("HTTP request is failed :%v", err) - // return false - } - if resp != nil { - // handle error - fmt.Printf("Resp is there :%v", resp.Body) - - defer resp.Body.Close() - - readResponseBody(resp) - } - -} -func ConnectToHttpGet(operation, testMgrEndPoint string) { - - req, err := http.NewRequest(http.MethodGet, testMgrEndPoint, nil) - if err != nil { - // handle error - // common.Failf("Frame HTTP request failed: %v", err) - - fmt.Printf("Error while getting http request: %v", err) - // return false - } - - // client := &http.Client{} - req.Header.Set("Content-Type", "application/json; charset=utf-8") - // t := time.Now() - resp, err := http.Get(testMgrEndPoint) - - if err != nil { - // handle error - fmt.Printf("HTTP request is failed :%v", err) - // return false - } - if resp != nil { - // handle error - //fmt.Printf("Resp is there :%v", resp.Body) - - defer resp.Body.Close() - - readResponseBody(resp) - } -} -func readResponseBody(resp *http.Response) { - if resp.StatusCode == http.StatusOK { - bodyBytes, err := ioutil.ReadAll(resp.Body) - if err != nil { - fmt.Printf("Reading response body failed: %v", err) - } - bodyString := string(bodyBytes) - fmt.Printf(bodyString) - } -} - -//function to handle device addition and deletion. -func ConnectToHTTP(operation, testMgrEndPoint string, payload map[string]interface{}) (*http.Response, error) { - var httpMethod string - // var payload dttype.MembershipUpdate - switch operation { - case "PUT": - httpMethod = http.MethodPut - - case "POST": - httpMethod = http.MethodPost - case "DELETE": - httpMethod = http.MethodDelete - - case "GET": - httpMethod = http.MethodGet - default: - - } - - respbytes, err := json.Marshal(payload) - if err != nil { - fmt.Printf("Payload marshal failed: %v", err) - } - - req, err := http.NewRequest(httpMethod, testMgrEndPoint, bytes.NewBuffer(respbytes)) - if err != nil { - fmt.Printf("Error while getting http request: %v", err) - - } - - client := &http.Client{} - req.Header.Set("Content-Type", "application/json") - // t := time.Now() - resp, err := client.Do(req) - - if err != nil { - // handle error - fmt.Printf("HTTP request is failed :%v", err) - - } - if resp != nil { - // handle error - fmt.Printf("Resp is ... :%v", resp) - fmt.Println("response Status:", resp.Status) - // Print the body to the stdout - io.Copy(os.Stdout, resp.Body) - - defer resp.Body.Close() - - readResponseBody(resp) - } - // common.InfoV6("%s %s %v in %v", req.Method, req.URL, resp.Status, time.Now().Sub(t)) - return resp, err -} \ No newline at end of file diff --git a/test/integration/utils/LogReader.go b/test/integration/utils/LogReader.go deleted file mode 100644 index 3a9bb830b..000000000 --- a/test/integration/utils/LogReader.go +++ /dev/null @@ -1,77 +0,0 @@ -// Copyright 2019 The OpenSDS Authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. -package utils - -import ( - "bufio" - "fmt" - "io/ioutil" - "log" - "os" - "strings" -) - -func ReadFile(fileName string) { - // Open file and create scanner on top of it - file, err := os.Open(fileName) - if err != nil { - log.Fatal(err) - } - scanner := bufio.NewScanner(file) - - // Default scanner is bufio.ScanLines. Lets use ScanWords. - // Could also use a custom function of SplitFunc type - scanner.Split(bufio.ScanWords) - - // Scan for next token. - success := scanner.Scan() - if success == false { - // False on error or EOF. Check error - err = scanner.Err() - if err == nil { - log.Println("Scan completed and reached EOF") - } else { - log.Fatal(err) - } - } - - // Get data from scan with Bytes() or Text() - fmt.Println("First word found:", scanner.Text()) - - // Call scanner.Scan() again to find next token -} -func ReadAndFindTextInFile(fileName string, text string) bool { - found := false - /* ioutil.ReadFile returns []byte, error */ - data, err := ioutil.ReadFile(fileName) - if err != nil { - log.Fatal(err) - } - /* ... omitted error check..and please add ... */ - /* find index of newline */ - file := string(data) - line := 0 - /* func Split(s, sep string) []string */ - temp := strings.Split(file, "\n") - - for _, item := range temp { - fmt.Println("[", line, "]\t", item) - if strings.Contains(item, text) { - fmt.Println("Found given text in line [", line, "]\t") - found = true - } - line++ - } - return found -} \ No newline at end of file