-
Notifications
You must be signed in to change notification settings - Fork 308
Integration test framework files for hotpot #999
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
satya-gorli
wants to merge
12
commits into
sodafoundation:master
Choose a base branch
from
satya-gorli:IntegrationTest
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 11 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
fceb268
test checkin
satya-gorli a268032
Merge branch 'master' of https://github.com/satya-gorli/opensds into …
satya-gorli 674bd8f
IntegrationTest framework files
satya-gorli 6875f20
Integration test dependencies
satya-gorli 19d3ed0
Integration test files for file share
satya-gorli 3e2a3a3
IntegrationTest framework files
satya-gorli f396f3b
IntegrationTest framework files
satya-gorli 36f24a3
IntegrationTest framework files
satya-gorli 3ee80fb
IntegrationTest framework files
satya-gorli 3c3bfe1
IntegrationTest framework files
satya-gorli e50dab8
IntegrationTest framework files
satya-gorli 7a2c8fe
IntegrationTest framework files
satya-gorli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| // 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") | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| // 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 ( | ||
|
|
||
| "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 ( | ||
| OPERATION_FAILED = "OPERATION_FAILED" | ||
| ) | ||
| var _ = Describe("FileShare Testing", func() { | ||
|
|
||
| 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() {}) | ||
| }) | ||
| }) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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.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 | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which function writing this log file? Those entries should be written to this log file somewhere, where is that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this path is just for testing ... In actual testcase, what we want to find in log, need to give the log file path and text to find