github.com/jingruilea/kubeedge@v1.2.0-beta.0.0.20200410162146-4bb8902b3879/edge/test/integration/docs/README.md (about) 1 # Integration test Framework features and it's use cases 2 3 - [Background](#Background) 4 - [Integration test framework features](#Integration-test-framework-features) 5 - [Folder Structure](#Folder-structure-of-Integration-tests) 6 - [Sample Testcase](#Sample-Testcase) 7 - [Configurations](#Configurations) 8 - [Run Tests](#Run-Tests) 9 - [Test Logs](#Integration-test-logs) 10 - [Test Report](#Test-Report) 11 - [References](#References) 12 13 ## Background 14 Kubeedge integration tests are designed based on the **Gomega** and **Ginkgo** framework. 15 Framework provides an environment for the automation test scripts to be executed. With the use of framework, users can efficiently work with the automation test scripts, including development, execution, logging and reporting. 16 17 ## Integration test framework features 18 - A comprehensive test runner 19 - Built-in support for testing asynchronicity 20 - Modular and easy to customize. 21 - Easy Integration of test features, priorities, test cases. 22 - Logging and Reporting. 23 - Scalable to add more features. 24 25 ## Folder structure of Integration tests 26 27 <img src="./integration_folder_structure.png"> 28 29 - **appdeployment:** appdeployment folder consists of tests related to application deployment on kubeedge node. 30 - **device:** device folder consists of tests related to Device which are binded on kubeedge node. 31 - **docs:** docs related to integration tests 32 - **scripts:** scripts folder consists of compile, run, and CI scripts to run local env or travis-CI env 33 - **utils:** utils will have all the common functions declared in it which will be used by other test modules. 34 35 ## Sample Testcase 36 37 ```bash 38 It("TC_TEST_EBUS_7: change the device status to unknown from eventbus", func() { 39 var message DeviceUpdate 40 message.State = "unknown" 41 body, err := json.Marshal(message) 42 if err != nil { 43 common.Failf("Marshal failed %v", err) 44 } 45 if Token_client = Client.Publish(dtcommon.DeviceETPrefix+DeviceID+dtcommon.DeviceETStateUpdateSuffix, 0, false, body); Token_client.Wait() && Token_client.Error() != nil { 46 common.Failf("client.Publish() Error is %s", Token_client.Error()) 47 }else { 48 common.InfoV6("client.Publish Success !!") 49 } 50 Expect(Token_client.Error()).NotTo(HaveOccurred()) 51 Eventually(func() string { 52 deviceState := GetDeviceStateFromDB(DeviceID) 53 common.InfoV2("DeviceID= %s, DeviceState= %s", DeviceID, deviceState) 54 return deviceState 55 }, "60s", "2s").Should(Equal("unknown"), "Device state is not unknown within specified time") 56 Client.Disconnect(1) 57 }) 58 ``` 59 ## Configurations 60 ##### Modify the test configurations accordingly in the below mentioned file 61 ```bash 62 PATH: $GOPATH/src/github.com/kubeedge/kubeedge/edge/test/integration/scripts/fast_test.sh 63 cat >config.json<<END 64 { 65 "mqttEndpoint":"tcp://$MQTT_SERVER:1884", 66 "testManager": "http://127.0.0.1:12345", 67 "edgedEndpoint": "http://127.0.0.1:10255", 68 "image_url": ["nginx:latest", "redis:latest"] 69 } 70 71 mqttEndpoint : Specify mqttEndpoint accordingly to Run the integration tests on internal or External MQTT server. 72 testManager: testManager will listen and serve the request on http://127.0.0.1:12345 73 edgedEndpoint: edgedEndpoint will listen and serve the request on http://127.0.0.1:10255 74 image_url: Specify the docker Image Name/Image URL's for application deployments on edge node. 75 ``` 76 ## Run Tests 77 ##### Choice of running integration test suite 78 79 * Integration test scripts are written in a way that user can run all test suites together or run individual test suites or only failed test case. 80 81 **Run all test suites:** 82 ```shell 83 cd $GOPATH/src/github.com/kubeedge/kubeedge/edge 84 85 1. bash -x test/integration/scripts/compile.sh 86 2. bash test/integration/scripts/fast_test.sh 87 88 Above 2 commands will ensure you run all the tests. 89 ``` 90 91 **Run Individual Test Suite:** 92 ```shell 93 cd $GOPATH/src/github.com/kubeedge/kubeedge/edge 94 95 Ex: 96 1. bash -x test/integration/scripts/compile.sh <device> 97 2. bash test/integration/scripts/fast_test.sh <device> 98 #or 99 1. bash -x test/integration/scripts/compile.sh <appdeployment> 100 2. bash test/integration/scripts/fast_test.sh <appdeployment> 101 ``` 102 103 **Run Failed Test:** 104 ```shell 105 cd $GOPATH/src/github.com/kubeedge/kubeedge/edge 106 107 Ex: 108 bash test/integration/scripts/fast_test.sh <device> -ginkgo.focus="Failed test case ID/Name" 109 ``` 110 ## Test Logs 111 ##### Integration test logs 112 113 * Path : tmp/testcase.log 114 115 ## Test Report 116 <img src="./Integration_test_report.png"> 117 118 ## References 119 * See [Ginkgo](https://github.com/onsi/ginkgo) and [Gomega](https://github.com/onsi/gomega) for detailed info on framework usage.