From fceb268f08a6d82fc3bbbf0f91af883e9090fa12 Mon Sep 17 00:00:00 2001 From: "Satya.G" Date: Fri, 2 Aug 2019 13:05:09 -0700 Subject: [PATCH 01/11] test checkin --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 08189acda..d62bad239 100755 --- a/Makefile +++ b/Makefile @@ -9,7 +9,7 @@ # 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 +# See the License for the specific language governing permissions and # limitations under the License. BASE_DIR := $(shell pwd) From 674bd8fa25c04fd703a18bca4e70c895c53eaea4 Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 11:55:41 +0530 Subject: [PATCH 02/11] IntegrationTest framework files --- test/integration/fileshare_test.go | 45 ++++++++ test/integration/utils/DBHelper.go | 87 +++++++++++++++ test/integration/utils/HttpHelper.go | 151 +++++++++++++++++++++++++++ test/integration/utils/LogReader.go | 77 ++++++++++++++ 4 files changed, 360 insertions(+) create mode 100644 test/integration/fileshare_test.go create mode 100644 test/integration/utils/DBHelper.go create mode 100644 test/integration/utils/HttpHelper.go create mode 100644 test/integration/utils/LogReader.go diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go new file mode 100644 index 000000000..0b74d05e4 --- /dev/null +++ b/test/integration/fileshare_test.go @@ -0,0 +1,45 @@ +// 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 integration + +import ( + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" + utils "github.com/opensds/opensds/test/integration/utils" +) + +func TestFileShare(t *testing.T) { + RegisterFailHandler(Fail) + RunSpecs(t, "FileShare Suite") +} + +var _ = Describe("FileShare Testing", func() { + + Context("create FileShare", func() { + // var jsonStr = []byte(`{"name":"share2", "description":"This is just for test2", "size": 2}`) + payLoad := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "GET" + + utils.ConnectToHttpGet(methodName, payLoad) + // It("fileshare get", func() { + // payLoad := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + // methodName := "PUT" + // utils.ConnectToHttp(methodName, payLoad, jsonStr) + // }) + // It("has 0 units", func() {}) + // Specify("the total amount is 0.00", func() {}) + }) +}) diff --git a/test/integration/utils/DBHelper.go b/test/integration/utils/DBHelper.go new file mode 100644 index 000000000..e690a7ceb --- /dev/null +++ b/test/integration/utils/DBHelper.go @@ -0,0 +1,87 @@ +// 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) + return GetValueByKey(ctx, kv, key) + // GetSingleValueDemo(ctx, kv) + // GetMultipleValuesWithPaginationDemo(ctx, kv) + // WatchDemo(ctx, cli, kv) + // LeaseDemo(ctx, cli, kv) + // return ctx, kv +} +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") + // 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) +} diff --git a/test/integration/utils/HttpHelper.go b/test/integration/utils/HttpHelper.go new file mode 100644 index 000000000..d82104003 --- /dev/null +++ b/test/integration/utils/HttpHelper.go @@ -0,0 +1,151 @@ +// 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.Errorf("Error while getting http request", 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.Errorf("Error while getting http request", 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.Errorf("", 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.Errorf("Payload marshal failed", err) + } + + req, err := http.NewRequest(httpMethod, testMgrEndPoint, bytes.NewBuffer(respbytes)) + if err != nil { + fmt.Errorf("Error while getting http request", 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 +} diff --git a/test/integration/utils/LogReader.go b/test/integration/utils/LogReader.go new file mode 100644 index 000000000..4c2640716 --- /dev/null +++ b/test/integration/utils/LogReader.go @@ -0,0 +1,77 @@ +// 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 +} From 6875f20468f010855c2fa64dfe2a1651f549da69 Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 14:24:05 +0530 Subject: [PATCH 03/11] Integration test dependencies --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 2ae7230d8..047c8f90c 100755 --- a/.travis.yml +++ b/.travis.yml @@ -25,6 +25,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 + - go get github.com/onsi/gomega + - go get github.com/onsi/ginkgo/ginkgo + - go get github.com/modocache/gover matrix: fast_finish: true From 19d3ed003845dc5137e65463e6362a2d97246a1e Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 14:55:39 +0530 Subject: [PATCH 04/11] Integration test files for file share --- test/integration/fileshare_suit_test.go | 39 +++++++++++++ test/integration/fileshare_test.go | 73 ++++++++++++++++++++----- 2 files changed, 99 insertions(+), 13 deletions(-) create mode 100644 test/integration/fileshare_suit_test.go diff --git a/test/integration/fileshare_suit_test.go b/test/integration/fileshare_suit_test.go new file mode 100644 index 000000000..8f44ae0ae --- /dev/null +++ b/test/integration/fileshare_suit_test.go @@ -0,0 +1,39 @@ +// 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 ( + "fmt" + "testing" + + . "github.com/onsi/ginkgo" + . "github.com/onsi/gomega" +) + +//Function to run the Ginkgo Test +func TestFileShareIntegration(t *testing.T) { + RegisterFailHandler(Fail) + //var UID string + var _ = BeforeSuite(func() { + fmt.Println("Before Suite Execution") + + }) + AfterSuite(func() { + By("After Suite Execution....!") + }) + + RunSpecs(t, "File Share Integration Test Suite") +} diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go index 0b74d05e4..df7174ae2 100644 --- a/test/integration/fileshare_test.go +++ b/test/integration/fileshare_test.go @@ -11,34 +11,81 @@ // 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 ( + "opensds/opensds/test/integration/utils" "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - utils "github.com/opensds/opensds/test/integration/utils" ) func TestFileShare(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "FileShare Suite") -} +}osdslet.ubuntu-123.root.log.WARNING.20190819-120511.96186 +var ( + OPERATION_FAILED = "OPERATION_FAILED" +) var _ = Describe("FileShare Testing", func() { - Context("create FileShare", func() { - // var jsonStr = []byte(`{"name":"share2", "description":"This is just for test2", "size": 2}`) - payLoad := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - methodName := "GET" - - utils.ConnectToHttpGet(methodName, payLoad) - // It("fileshare get", func() { - // payLoad := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" - // methodName := "PUT" - // utils.ConnectToHttp(methodName, payLoad, jsonStr) - // }) + Context("create FileShare ", func() { + + BeforeEach(func() { + + }) + AfterEach(func() { + }) + It("TC_FS_IT_01: Create fileshare with name input ", func() { + var jsonStr = map[string]interface{}{"name": "share2223", "description": "This is just for test222", "size": 2} + + // var jsonStr1 = []byte(`{"name":"share22234", "description":"This is just for test222", "size": 2}`) + + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + resp, err := utils.ConnectToHTTP(methodName, url, jsonStr) + + Expect(resp.StatusCode).Should(Equal(202)) + Expect(err).NotTo(HaveOccurred()) + + }) + It("TC_FS_IT_02: Create fileshare with duplicate name input ", func() { + var jsonStr2 = map[string]interface{}{"name": "sharexxx", "description": "This is just for testxxx", "size": 2} + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "POST" + utils.ConnectToHTTP(methodName, url, jsonStr2) + }) + // It("has 0 units", func() {}) + // Specify("the total amount is 0.00", func() {}) + }) + Context("Get FileShare ", func() { + // var jsonStr1 = []byte(`{"name":"share2223", "description":"This is just for test222", "size": 2}`) + // var jsonStr = map[string]interface{}{"name": "share2223", "description": "This is just for test222", "size": 2} + BeforeEach(func() { + }) + AfterEach(func() { + }) + It("TC_FS_IT_03: fileshare GET all ", func() { + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "GET" + utils.ConnectToHTTP(methodName, url, nil) + }) + It("TC_FS_IT_04: fileshare GET of specific Id", func() { + fId := "v1beta/file/shares/e93b4c0934da416eb9c8d120c5d04d96/f2ab9308-f208-40c6-bb1f-6fbfa8bf14b5" + url := "http://127.0.0.1.123:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/f2ab9308-f208-40c6-bb1f-6fbfa8bf14b5" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + methodName := "GET" + utils.ConnectToHTTP(methodName, url, nil) + // ctx, kv := utils.ConnectToDB() + ret := utils.GetValueByKeyFromDB(fId) + Expect(ret).ShouldNot(Equal(OPERATION_FAILED)) + textFound := utils.ReadAndFindTextInFile("C:/go/src/opensds/opensds/test/integration/utils/output.json", "17c60641-63c9-4f7f-992a-c0dcd9abd502") + Expect(textFound).To(BeTrue(), "Text found in the log file") + + }) // It("has 0 units", func() {}) // Specify("the total amount is 0.00", func() {}) }) From 3e2a3a373a7ce5d473eab1df72e1186919faa42f Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 15:28:42 +0530 Subject: [PATCH 05/11] IntegrationTest framework files --- test/integration/fileshare_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go index df7174ae2..9eea9eb9a 100644 --- a/test/integration/fileshare_test.go +++ b/test/integration/fileshare_test.go @@ -16,7 +16,7 @@ package integration import ( - "opensds/opensds/test/integration/utils" + "utils" "testing" . "github.com/onsi/ginkgo" From f396f3ba51220cc9876d89ad0fea20eefb564c8c Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 16:03:05 +0530 Subject: [PATCH 06/11] IntegrationTest framework files --- test/integration/fileshare_test.go | 5 +++-- test/integration/utils/HttpHelper.go | 10 +++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go index 9eea9eb9a..dc6e9c648 100644 --- a/test/integration/fileshare_test.go +++ b/test/integration/fileshare_test.go @@ -16,17 +16,18 @@ package integration import ( - "utils" + "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "githube.com/opensds/opensds/test/integration/utils" ) func TestFileShare(t *testing.T) { RegisterFailHandler(Fail) RunSpecs(t, "FileShare Suite") -}osdslet.ubuntu-123.root.log.WARNING.20190819-120511.96186 +} var ( OPERATION_FAILED = "OPERATION_FAILED" diff --git a/test/integration/utils/HttpHelper.go b/test/integration/utils/HttpHelper.go index d82104003..259a1a54b 100644 --- a/test/integration/utils/HttpHelper.go +++ b/test/integration/utils/HttpHelper.go @@ -30,7 +30,7 @@ func ConnectToHttpPost(operation, testMgrEndPoint string, payload []byte) { // handle error // common.Failf("Frame HTTP request failed: %v", err) - fmt.Errorf("Error while getting http request", err) + fmt.Printf("Error while getting http request", err) // return false } @@ -61,7 +61,7 @@ func ConnectToHttpGet(operation, testMgrEndPoint string) { // handle error // common.Failf("Frame HTTP request failed: %v", err) - fmt.Errorf("Error while getting http request", err) + fmt.Printf("Error while getting http request", err) // return false } @@ -88,7 +88,7 @@ func readResponseBody(resp *http.Response) { if resp.StatusCode == http.StatusOK { bodyBytes, err := ioutil.ReadAll(resp.Body) if err != nil { - fmt.Errorf("", err) + fmt.Printf("Reading response body failed", err) } bodyString := string(bodyBytes) fmt.Printf(bodyString) @@ -116,12 +116,12 @@ func ConnectToHTTP(operation, testMgrEndPoint string, payload map[string]interfa respbytes, err := json.Marshal(payload) if err != nil { - fmt.Errorf("Payload marshal failed", err) + fmt.Printf("Payload marshal failed", err) } req, err := http.NewRequest(httpMethod, testMgrEndPoint, bytes.NewBuffer(respbytes)) if err != nil { - fmt.Errorf("Error while getting http request", err) + fmt.Printf("Error while getting http request", err) } From 36f24a324f3ea15be9438f1125e4c29e6bde6444 Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 16:30:41 +0530 Subject: [PATCH 07/11] IntegrationTest framework files --- test/integration/fileshare_test.go | 4 ++-- test/integration/utils/HttpHelper.go | 10 +++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go index dc6e9c648..1be5f65ce 100644 --- a/test/integration/fileshare_test.go +++ b/test/integration/fileshare_test.go @@ -16,12 +16,12 @@ package integration import ( - + "testing" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - "githube.com/opensds/opensds/test/integration/utils" + . "github.com/opensds/opensds/test/integration/utils" ) func TestFileShare(t *testing.T) { diff --git a/test/integration/utils/HttpHelper.go b/test/integration/utils/HttpHelper.go index 259a1a54b..f6db11c3d 100644 --- a/test/integration/utils/HttpHelper.go +++ b/test/integration/utils/HttpHelper.go @@ -30,7 +30,7 @@ func ConnectToHttpPost(operation, testMgrEndPoint string, payload []byte) { // handle error // common.Failf("Frame HTTP request failed: %v", err) - fmt.Printf("Error while getting http request", err) + fmt.Printf("Error while getting http request: %v", err) // return false } @@ -61,7 +61,7 @@ func ConnectToHttpGet(operation, testMgrEndPoint string) { // handle error // common.Failf("Frame HTTP request failed: %v", err) - fmt.Printf("Error while getting http request", err) + fmt.Printf("Error while getting http request: %v", err) // return false } @@ -88,7 +88,7 @@ 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", err) + fmt.Printf("Reading response body failed: %v", err) } bodyString := string(bodyBytes) fmt.Printf(bodyString) @@ -116,12 +116,12 @@ func ConnectToHTTP(operation, testMgrEndPoint string, payload map[string]interfa respbytes, err := json.Marshal(payload) if err != nil { - fmt.Printf("Payload marshal failed", err) + 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", err) + fmt.Printf("Error while getting http request: %v", err) } From 3ee80fb49878d2a8bf74d698f9311c361851c43b Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 16:49:23 +0530 Subject: [PATCH 08/11] IntegrationTest framework files --- test/integration/fileshare_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go index 1be5f65ce..9ef9827f9 100644 --- a/test/integration/fileshare_test.go +++ b/test/integration/fileshare_test.go @@ -21,7 +21,7 @@ import ( . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" - . "github.com/opensds/opensds/test/integration/utils" + utils "github.com/opensds/opensds/test/integration/utils" ) func TestFileShare(t *testing.T) { From 3c3bfe1bc8c2035b1941696959c42a9729424927 Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 17:07:06 +0530 Subject: [PATCH 09/11] IntegrationTest framework files --- test/integration/fileshare_suit_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/fileshare_suit_test.go b/test/integration/fileshare_suit_test.go index 8f44ae0ae..bf061581f 100644 --- a/test/integration/fileshare_suit_test.go +++ b/test/integration/fileshare_suit_test.go @@ -13,6 +13,7 @@ // limitations under the License. // +build integration + package integration import ( From e50dab8b548149c6635b2cf3716ba9067ebea202 Mon Sep 17 00:00:00 2001 From: SatyaG Date: Fri, 30 Aug 2019 17:19:11 +0530 Subject: [PATCH 10/11] IntegrationTest framework files --- test/integration/fileshare_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go index 9ef9827f9..308118841 100644 --- a/test/integration/fileshare_test.go +++ b/test/integration/fileshare_test.go @@ -13,6 +13,7 @@ // limitations under the License. // +build integration + package integration import ( From 7a2c8fe6e563cc13469254a118acdef59234b698 Mon Sep 17 00:00:00 2001 From: SatyaG Date: Tue, 3 Sep 2019 15:51:01 +0530 Subject: [PATCH 11/11] IntegrationTest framework files --- test/integration/fileshare_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/integration/fileshare_test.go b/test/integration/fileshare_test.go index 308118841..cbd6138cb 100644 --- a/test/integration/fileshare_test.go +++ b/test/integration/fileshare_test.go @@ -78,7 +78,7 @@ var _ = Describe("FileShare Testing", func() { }) It("TC_FS_IT_04: fileshare GET of specific Id", func() { fId := "v1beta/file/shares/e93b4c0934da416eb9c8d120c5d04d96/f2ab9308-f208-40c6-bb1f-6fbfa8bf14b5" - url := "http://127.0.0.1.123:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/f2ab9308-f208-40c6-bb1f-6fbfa8bf14b5" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" + url := "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares/f2ab9308-f208-40c6-bb1f-6fbfa8bf14b5" //curl -X POST -H "Content-Type: application/json" -d '{"name":"share1", "description":"This is just for test", "size": 1}' -url "http://127.0.0.1:50040/v1beta/e93b4c0934da416eb9c8d120c5d04d96/file/shares" methodName := "GET" utils.ConnectToHTTP(methodName, url, nil) // ctx, kv := utils.ConnectToDB()