2015年5月18日 星期一

Apache JMeter 壓力測試 Mobile API

Hello 大家好!!!

記得上一節是介紹如何用 WAPT 做壓測 Mobile API。這一節我們就來介紹一下如何用 Apache JMeter 做 Mobile API 的壓力測試。

在開始實做之前,我們先來介紹一下 Apache JMeter:
  1. 100%由 Java 開發的測是工具。
  2. 開放原碼軟體 (Open Source)。
  3. 支援效能測試、功能測試和負載測試。
  4. 原先設計做 Web 測試,現在已延伸可以做其它功能測試。
  5. 對附載及效能測,支援多項服務和協定:HTTP, HTTPS, SOAP, REST, FTP, JDBC, LDAP, JMS, SMTP, POP3, IMAP, NoSQL, Commands, Shell Scripts and TCP...
  6. GUI介面方便建立測試計畫和除錯。
  7. 高擴充性核心等等...
缺點:
  1. JMeter 並不像瀏覽器可以執行 CSS 或 JavaScript 等等瀏覽器語言。
  2. 因受 thread 的限制,所以無法長時間執行測試。
  3. Debug 較不易。
  4. 測試報告不夠完整性。
  5. 需要安裝 JRE 6 以上版本才能執行。 
現在就來開始我們這一節的實作說明:


Step 1: Download JRE from the official website.
https://www.java.com/en/download/ie_manual.jsp?locale=en

Step 2: Install JRE from download folder then double click the installation file "JavaSetup8u45.exe"

Step 3: Click "Yes" for continuous.

Step 4: Click "Install" for the installation.

Step 5: Un-tick the check box then click "Next"


Step 6: Click "Close" for finished the JRE installation.

Step 7: Download from the link as below or the official website.

Step 8: Unzip file "apache-jmeter-2.13.zip"

Step 9: Double click the file "jmeter.bat" for start JMetrer.
C:\"Download Folder" \apache-jmeter-2.13\bin

Step 10: Show the JMeter main GUI as below.

Step 11: Create the first test plan.
Test Plan | Add | Threads(Users) | Thread Group

Step 12: Set every 5 seconds(blue), ramp-up 5 VUs(yellow) and loop 100 times(red) then total 500 VUs.

Step 13: If want to repeat the VUs for this test plan set in red. For our case just set loop 1 time means doesn't want any VUs to do repeat test.
Thread Group | Add | Logic Controller | Loop Controller


Step 14: If need to test more APIs for HTTP Request, we can set the defaults for the HTTP Request then separate the APIs HTTP Request. For our case just create a "HTTP Request Defaults" don't do any setup with this.
Loop Controller | Add | Config Element | HTTP Request Defaults


Step 15: Create the API "HTTP Request"
Loop Controller | Add | Sampler | HTTP Request

Step 16: Set IP for HTTP server in red, Path in green and API parameters in blue. Click "Add" in yellow to add the parameters.

Step 17: Create the graph results.
Loop Controller | Add | Listener | Graph Results

Step 18: Create the results tree for recording the results bit by bit.
Loop Controller | Add | Listener | View Results Tree

Step 19: Click the icon   on navigation bar to save this test plan.

Step 20: Click the icon  to start the test plan.

Step 21: Click the icon  to clear all results.

Step 22: Graph Results of "No of Samples" means total requests, "Average" means average of response time, "Deviation" means deviation of response time if the number near 0 will be the best. "Throughput /minute" means per minute of response requests if the number much higher will be the better of the performance.

Step 23: List of Results Tree.

Step 24: Check the back-end of management GUI page to verify the requests.

介紹到這裡相信各位對於 JMeter 這套壓測工具,應該有了初步的認識和基本的使用方式。

這套壓測工具就如同上圖所見,並沒有很清楚或漂亮的圖形表現,這也是 Freeware 的測試工具普遍存在的問題,但是就單純的以一個實用性的壓力測試工具來說,JMeter 的測試表現算是一個蠻專業的測試工具,唯一的缺點就是在製作測試報告時,需要花較多的時間在圖表和測試報告的說明上面。

這一節 JMeter 的說明我們就先介紹到這裡,以後如果還有需要,我們再來做更深入的說明。那我們就下次見~ 掰掰!!!

~ See you ~

參考出處:
https://www.java.com/
http://jmeter.apache.org/

2015年5月5日 星期二

WAPT 壓力測試 Mobile API

Hello 大家好 !!!

距離上次發表文章的時間,是不是有點久呢?
其實這一陣子因為忙於公司的教育訓練,所以就比較沒有時間寫文章。不過剛好利用這段時間,可以好好研究一下 WAPT 壓力測試 Mobile API 的功能。

經過這段時間的研究,壓測行動裝置的 API,除了可以用頗負盛名的 Freeware - JMeter 這套外,用 WAPT 做壓測不管在功能性或是使用性來說,甚至所得的測試報告的完整性,相對於 JMeter 的表現都要更為優越。

所以今天這一節我們就來好好討論,如何用 WAPT 來做手機的 API 壓力測試:


Step 1: Download WAPT from link as below or official website.
WAPTPro.exe
http://www.loadtestingtool.com/download.shtml

Step 2: After download then double click the file "waptpro.exe"

Step 3: Then Click "Next" for continuous.

Step 4: Check "Yes, I agree with all the terms of this license agreement" then click "Next"

Step 5: Click "Next" for the next step.

Step 6: Make sure have checked both "WAPT Pro Workplace" and "Load Agent" then click "Next"

Step 7: Destination folder keep as default then click "Next"

Step 8: Keep as default for Load Agent Setting then click "Next"

Step 9: Click "Next" for Ready to install WAPT.


Step 10: Click "Finish" for completed the installation.

Step 11: Click "Start trial period" for 30 days trial licence.

Step 12: Show WAPT main GUI as below.

Step 13: Create a new scenario for the stress test. Make sure marking the "Stress Test" then click "Next"

Step 14: The trail licence only arrow test 20 users for this scenario ramp up load from 0 to 20 users with 1 users per every 5 second.

Step 15: Check "Run time: 000:02:00 hhh:mm:ss" then click "Next"

Step 16: Unchecked "Start recording virtual user profiles" then click "Finish"

Step 17: Click record icon 

Step 18: Create a new profile name as "Mobile API Test" then select "Embedded Internet Explorer Window" and click "OK"

Step 19: Check the API release note for API URL then type the URL at "Address"


Step 20: Click "Stop Rec" button then select left side "page_1:http://192.168.1.xxx/xxxxx/api/wcms"

Step 21: Check the API release note for method parameter (Ex. method: login)

Step 22: Select "Code page" as "Unicode (UTF-8)"

Step 23: Click "Add" then type "method" at "Name".

Step 24: click "Add" then type "login" for the method parameter and click "OK"

Step 25: Then add others parameter as below.

Step 26: Click "Verify Test" for testing 1 virtual user.

Step 27: The "Summary Report" show "200 OK" means successful for the verify test.

Step 28: Click "Run Test" for real testing then select "Log level of detail" as "Full" and click "OK"

Step 29: After real testing show a report page as below.

Step 30: Check the database status to verify the login sessions.

Step 31: Check the managerial GUI page to verify the login sessions.

Step 32: Test Report
Summary Report

Performance Data

Response Time

Bandwidth Usage

Errors Report

Performance Graph

Bandwidth Graph

Errors Graph

Custom Graph

說明到這裡,相信各位都已經瞭解如何運用 WAPT 壓測 Mobile API。
值得注意在測試的過程中,尤其在設定測試腳本時,只要 API 的 Method 所以對應的參數設定正確,就可以依不同 Method 的功能性來做壓力測試,以達到客戶的壓測需求。

這節 WAPT 就說明到這裡,如果以後還有其它需要,我們再來繼續討論。

~ See you ~

參考出處:
http://www.loadtestingtool.com/