LoadRunner內部結構

weixin_34321977發表於2015-12-04
 
英文版地址: http://www.rickyzhu.com/21_principle-graph-of-loadrunner.html
原文請參考這裡 http://www.wilsonmar.com/1loadrun.htm
 
 

1,             被測系統是由驅動程式mdrv.exe(多執行緒驅動的程式)和r3vuser.exe來產生壓力的,其中r3vuser.exe模擬應用程式的客戶端,如IE瀏覽器。它執行了三個主要的操作:

Kli> cpp (C 語言pre-processor)

1)cci (C語言編譯器),建立ci檔案,然後使用被測系統的協議相關的驅動來執行。

 

通過在Windows批處理指令碼中啟動Mdrv.exe來默默地啟動執行。

Mdrv能自動停止載入Vuser,因為他們與Vuser和Windows負載生成器上的CPU使用監視器之間互相通訊。

在Windows機器上,對於每一個基於Java的Vuser都有一個獨立的JVM。

2,             虛擬使用者通過在負載生成器客戶端機器上使用agent(3900 magentproc.exe)作為服務或者程式來按照組(在指定的負載生成器上執行相同指令碼的虛擬使用者的集合)啟動虛擬使用者。

3,             每一個擁有代理的機器維護一個在.qtp檔案中的執行日誌

4,             當日志被啟用後,代理同樣會在結果檔案中為每一個虛擬使用者(由虛擬使用者組分開)建立一系列日誌檔案。

5,             在執行過程中, 這些檔案可以通過在Controller機器上的view > Show Output視窗中顯示。

6,             在預先設定延時上,Controller上執行的Scheduler指導代理(通過Windows 54345埠,或者Unix上的動態埠)去初始化場景會話.Controller(wlrun.exe)在請求中傳送一份場景的拷貝.

7,             代理是由每一個負載生成器上的Remote Agent Dispatcher程式(以前叫Remote Command Launcher(RCL))啟動的.

8,             每一個根據場景(.lrs)定義檔案中設定的代理來決定哪一個虛擬使用者組和指令碼需要在主機上執行.

<!--[if !vml]-->

<!--[endif]--><!--[if !mso]-->
<!--[endif]-->

 

<!--[if !mso]-->
<!--[endif]--><!--[if !mso & !vml]--> <!--[endif]--><!--[if !vml]-->
<!--[endif]--> <!--[if !vml]--><!--[endif]-->## 這就是說Controller可以從DOS的批處理檔案(.batch)中啟動.

 

REM Start Controller:
SET M_ROOT=C:\Program Files\Mercury Interactive\LoadRunner\bin
cd %M_ROOT%
wlrun.exe -TestPath D:\Dev\Dev1.lrs -port 8080 -Run -DontClose

l       包含的-Run 引數與手動的點”開始場景”自動執行是一樣的. 這不是一個很好的方法,因為你可能需要決定從以前的執行中收集檔案或者想改變輸出資料夾.

l       這是假設系統環境變數PATH已經被更新了,包括LoadRunner的安裝.

9, Controller通過使用     Windows      作業系統資料夾裡的引數值來啟動.因為LoadRunner被設計成在一個機器上一次只能執行一個Controller例項,所以需要使用Windows資料夾.

<!--[if !vml]--><!--[endif]-->## 為了在幾個應用之間快速的切換, 在Controller工作之後儲存LoadRunner的ini檔案, 然後使用記事本來製作一個批處理檔案. 在執行wlrun之前拷貝應用程式的指定版本的ini檔案. 下面是一個應用程式檔案拷貝的例子:

copy %WinDir%/wlrun7-XXX.ini   %WinDir%/wlrun7.ini
copy %WinDir%/wlrun7-XXX.dft   %WinDir%/wlrun7.dft

需要修改一些預設值:

l       在wlrun7.ini檔案的output區域, MaxNumberOfOutputMessages= from 10000 to 100000, 這就限制了儲存在資料庫中的輸出資訊的數目.

l       MaxOutputUIRowsToShow限制了在Controller的輸出視窗中顯示的資訊/錯誤行總數.

l       在LoadRunner程式檔案的 dat\protocols   資料夾下的QTWeb.lrp檔案的[Vugen]部分, 新增一個MaxThreadPerProcess=5來限制由每個負載生成器mdrv.exe程式管理的執行緒數.

l       儲存在wlrun5.ini 和wlrun7.dft檔案中的DefaultScenarioDir, DefaultscrīptDir, DefaultResultDir, [Recent File List]幾個資料的值會在每次Controller改變的時候更新。

10,             在Vu scrīpts中定義的每個虛擬使用者進行的操作是用LoadRunner的VuGen.exe生成的. 當這個程式啟動後, 它在windows資料夾下儲存了comparamui.INI檔案來儲存[LastTablesUsed]下面檔案的歷史,並且儲存由Insert > New Parameter > Dates 選單指定的[ParamDialogDates].

VuGen在Windows資料夾下儲存和檢索vugen.ini檔案.當使用JAVA的時候,需要新增一些其他的除錯選項:

[DynaDlg]
JavaLevel=3

當在VuGen 8.1中使用8.0的指令碼, 往Vugen.ini中加入資訊:

[Editor]
OLDEDITOR = 1

VuGen在LR資料夾template/qtweb default.cfg和指令碼檔案裡開啟.

Vu scrīpts可以使用指令碼外部的引數檔案來獲得的變數值進行編碼.

更多關於VuGen的資訊請看指令碼編寫的章節.

11. 執行過程中,執行結果儲存到一個結果資料夾中.

<!--[if !vml]--><!--[endif]-->我喜歡在場景執行中把結果設定成自動產生結果.這樣,LoadRunner會在每次啟動一個場景之後自動產生一個子增的結果名. 例如,結果名稱Res1會自動增長到Res12或有時候是R       es11-1.

錯誤被寫到output.mdb微軟的Access資料庫中。

12. 在每一個結果資料夾中, 程式自動建立Log資料夾來包含每個組的日誌檔案. 執行之後,在Controller中檢視日誌檔案,點 <!--[if !vml]--><!--[endif]-->, .然後在組中點右鍵,選擇 “Show Vuser Log”

13. 場景執行的時候, 監視器在本地維護每個主機的計數器.

14. 執行完成之後, "collate"程式處理.eve和.lrr結果檔案, 並且在結果資料夾下建立一個臨時的.mdb資料庫.

在處理大資料量的結果時, 為了防止錯誤發生,使用MSDE. ……

15.分析模組(8,320K analysisu.exe)使用mdb資料庫中的資料來產生分析圖表和報告.

16. 每一次場景執行後的結果檔案results_name.lrr,也叫分析文件檔案,由分析程式來讀取並且顯示百分點陣圖表.

LoadRunner內部結構2

17. 預設的LRReport資料夾建立在本地分析機器的My Documents資料夾下來儲存分析會話檔案.

18.可以使用HTML格式

19.格式是由.tem模版檔案控制的.

20.可選的, LR7.8的Remote Performance Monitoring (RPM) MS-IIS/ASP web server可以安裝在Windows 2000 Server(但不是Windows 2003 Server)上,這樣,負載測試的結果就可以使用web瀏覽器來瀏覽了.

Load Generator Agent程式和 Service

在安裝過程中, 使用者登陸頁面:

l       選擇” Allow virtual users to run on this machine without user login”意思是LoadRunner agent作為一個名稱為LoadRunner Agent Service的系統服務. 在Window的效能監視器中,這個圖示名稱為: magentservice.exe

<!--[if !vml]--><!--[endif]-->為了更好的安全,指定一個獨立的服務帳號,使用者名稱和密碼,這樣可以限制許可權.

安裝完之後,為了測試是否能執行,

在Windows 2000, 上開啟Start -> Control Panel -> Administrative Tools -> Services.
在  Windows NT4, 開啟Start -> Control Panel -> Services

你同樣需要輸入服務列表來改變密碼,或者復位服務為"Automatic"

l       選擇” Manual log in to the Load Generator”意味著LoadRunner agent按照名稱為magenproc.exe的程式來執行.這種方法意味著你需要每次啟動機器的時候從LoadRunner的 \launch_service\bin 手動執行Load Generator

<!--[if !vml]--><!--[endif]-->magentproc.exe

你可以通過在windows工作列中檢視是否有衛星圖示來判斷是否在執行.

<!--[if !vml]--><!--[endif]-->為了使機器每次重啟都會自動執行Agent,可以在程式-à啟動 這裡建立一個快截方式.

<!--[if !vml]--><!--[endif]-->作為一個程式,windows作業系統限制在執行的GUI(Winrunner, QuickTest Professinail等)或者類似GUI指令碼(Citrix, SAPGUI等)。因此,如果在負載生成器上的Remote Agent Dispatcher安裝成服務而不是程式的話,GUI和SAP Vuser就不能執行。

安裝之後,為了把執行的LoadRunner由服務變成程式:

<!--[if !vml]--><!--[endif]-->cd \PROGRA~1\MERCUR~1\MERCUR~1\LAUNCH~1\bin
<!--[if !vml]--><!--[endif]-->magentservice.exe –remove

LoadRunner作為服務安裝:

<!--[if !vml]--><!--[endif]-->magentservice.exe –install

這些命令不會產生響應結果。但是把m_agent_attribs.cfg檔案放到負載生成器的C:\根目錄下。

 

如果你沒有管理員許可權,然後去試圖改變使用者ID:Admin,密碼:Admin,你會看到這樣的資訊:

"29972:- Failed to reset launcher status call back function reason:no monikor was passed.

在UNIX機器上,代理的配置是修改LoadRunner根目錄下dat資料夾下的br_Inch_server.cfg實現的。

 

確保代理就緒

在控制器的負載生成器對話方塊中,在你點選“Connect”之後,你會看到“Ready”。

重新試驗這些命令,直到你得到資訊“Failed to connect to the agent。 Load Generator not responding after timeout Command line that was executed”

如果這樣仍然不能顯示為“Ready”狀態,在負載生成器的機器上看windows 服務,在重新使用上面的命令之前,kill 然後 刪除“LoadRunner Agent Service”

設定FireWallServiceActive 1 為true,0為false。執行bin/agent_config

使用網路驅動對映

如果一些負載生成器需要訪問相同的物理檔案,而不是必須去記得每次檔案改變後去拷貝這些檔案,每一個負載生成器可可以使用對映驅動器來引用通用的資料夾。但是因為網路驅動對映是跟制定的使用者關聯的:

1,             使用負載生成器要使用的使用者來登入負載生成器的機器。

2,             開啟windows瀏覽器,在工具下選擇對映一個網路驅動,然後建立一個驅動。

3,             在服務中開啟LoadRunner的服務。

4,             點 登入 標籤卡

5,             指定負載生成器服務使用的使用者名稱和密碼(如果使用者ID是本地域,使用者名稱稱這裡會顯示一個. )

6,             停止然後啟動服務。

控制負載生成器,穿過防火牆來監控

防火器的目的是通過阻止一些通訊來增強安全,它只允許一些特定的埠與外網通訊,如HTTP的80和HTTPS的443埠。

預設的情況下,負載生成器通過MI Listener使用動態的埠傳送資訊的返回。

為了避免必須請求管理員來開放更多的埠,在防火牆內的每個負載生成器機器,從Start > Programs > ... LoadRunner > Advanced Settings > Agent Configuration (launch_service\bin\AgentConfig.exe),安裝(Monitoring Over Firewall machine) MoFW/RoWF agent,檢查“Enable Firewall Agent”選項。

它收集效能計數器的資料,並且穿過防火期傳送這些資料給控制器。

MoFW與MI Listener通過埠443來通訊,所以機器上不要裝有任何的Web伺服器(Apache WebTours, IIS,或 Oracle HTTP servers)

為了驗證埠443是否允許通訊,使用下面的命令:

<!--[if !vml]--><!--[endif]-->telnet   194.194.194.194   443

這會開啟一個telnet視窗。

UNIX負載生成器使用一個動態的埠,這個埠不能固定。

當在控制器上定義一個遠端的負載生成器時,在“Load Generator Information”對話方塊上點“Details”,這裡你可以點“Firewall”標籤然後選擇“Enable Firewall”。

在windows和Unix/Liunx系統上監控資源

監控UNIX機器

在Liunx上啟動監控之前,檢查確保rstatd監控器是活動的。如果服務因為太忙或者重啟而使rstatd服務停止,LR7.8就不能從rstatd中獲得需要的資訊了。需要退出或者重新初始化控制器。

HTTPS/SSL 通訊的MI Listener

當代理從防火牆之後傳送HTTPS通訊,它會使用” Monitoring over Firewall Component”,然後控制器為代理使用一個符號的名稱,通過Mercury Interactive's MI Listener Machine(通過埠50500)與外邊的防火牆通訊。通過防火牆監控WINDOWS機器使用TCP埠139。

 

為了測試外部的防火牆mercuryinteractive.com/products/protune_ds/ Mercury ProTune Delivery Service

 

 

LoadRunner的工作原理圖

下面一個是LoadRunner的工作原理圖,更多的LoadRunner的理論請參考: http://www.wilsonmar.com/1loadrun.htm
wilson先生對LoadRunner有比較透徹的研究,這可以從他的分析中看出.

這張是LoadRunner的總體架構圖,包括各個元件VUGen, Controller和Analysis之間的關係.

這是LoadRunner的工作原理,從圖中可以看出如何利用LoadRunner進行一次典型的系統效能測試

這是一個內部流程圖,LoadRunner內部各個元件之間如何進行互動,資料流和檔案流之間如何進行.

下面是各個步驟的簡單介紹:


1. application serverson this page under test are placed under stress by
2. driver processes mdrv.exe (the Multi-threaded Driver Process) and r3vuser.exe which emulate application clients such as Internet Explorer web brower. It performs 3 main actions:
(1). Kli> cpp (C language pre-processor) cci (C pre-compiling) which creaes a file with ci file, and
(2). execute using the driver for the protocol technology being tested.

Runs can be invoked to run “silently” by invoking Mdrv.exe from a Windows batch script.

Mdrv can automatically stop loading Vusers because they communicate with Vusers and monitor CPU usage on Windows Load Generator machines.

A separate JVM is instantiated by each Java-based Vuser on Windows-based machines. #Java Vusers are not supported on Unix platforms.

3. virtual Vusers are invoked as groups (logical collection of virtual users running the same script on a specific load generator machine)
4. by agents (3,900K magentproc.exe) running as a service or as a processon this page
5. on load generator client machines.

6. Each machine hosting agents maintains an Execution Log in a .qtp file.
7. When logging is enabled, the agent also creates within the results folder a sequential log file for each Vuser (segregated by Vuser group).
8. During execution, this file is displayed in the view > Show Output window on the LoadRunner Controller machine.

9. Upon a pre-set delay, the Scheduler running on a Controller machine instructs agents (via Windows port 54345 or dynamic Unix port) to initiate test session scenarios. The Controller (wlrun.exe) sends a copy of scenario files along with the request.
10. Agents are launched by the Remote Agent Dispatcher process (formerly called Remote Command Launcher (RCL)) on each load generator machine.
11. Each agent refer to scenario (.lrs) definition files to determine which Vuser groups and scripts to run on host machines.

Idea This means the Controller can be started from a DOS batch (.bat) file (preferrably with a short name on a root drive):
REM Start Controller:
SET M_ROOT=C:\Program Files\Mercury Interactive\LoadRunner\bin
cd %M_ROOT%
wlrun.exe -TestPath D:\Dev\Dev1.lrs -port 8080 -Run -DontClose
pause Press Ctrl-Z to keep this window or

* Including the -Run parameter is the same as manually pressing the “Start Scenario” automatically upon invocation. This is not a good idea because you may have to decide about collating the file from a previous run or want to change the output folder.
* This assumes that the system’s environment PATH variableanother page on this site was updated to include where LoadRunner is installed.

12. The Controller is invoked using parameter values within files in the Windows OS folder (WINNT for Windows 2000 and WINDOWS for Windows XP). The Windows folder is used because LoadRunner is designed to have only one instance of Controller running at a time on a machine.

Idea To quickly switch among several applications, save a copy of LoadRunner’s ini files after working on it within the Controller, then use Notepad to craft a batch fileanother page on this site to copy application-specific versions of ini files before executing wlrun. An example of file copy actions for application XXX:

copy %WinDir%/wlrun7-XXX.ini %WinDir%/wlrun7.ini
copy %WinDir%/wlrun7-XXX.dft %WinDir%/wlrun7.dft

Some defaults you might want to change:
* In the wlrun7.ini file file [output] section, MaxNumberOfOutputMessages= from 10000 to 100000 for long runs. This limits the number of output messages stored in the database.
* MaxOutputUIRowsToShow limits the amount of messages/errors (lines) displayed in the Controller’s Output window.
* In the QTWeb.lrp file within the LoadRunner Program Files dat\protocols folder section [Vugen], add entry MaxThreadPerProcess=5 to limit the number of threads managed by each load generator mdrv.exe process.

Values for DefaultScenarioDir, DefaultScriptDir, DefaultResultDir, and [Recent File List] stored in the wlrun5.ini and wlrun7.dft files updated whenever values are changed within the Controller.

13. The blocks of actions taken by each Vuser are
14. defined in Vu scriptsanother page on this site created using Loadrunner’s VuGen.exe. When this program is invoked, it stores in the Windows folder a comparamui.INI file to save under “[LastTablesUsed]” a history of files and [ParamDialogDates] specified using menu option Insert > New Parameter > Dates.

VuGen stores and retrieves a vugen.ini file in the Windows folder. Mercury KnowledgeBase article When using Java, enable additional debug options:
[DynaDlg]
JavaLevel=3

When using 8.0 scripts within VuGen 8.1, add to Vugen.ini:
[Editor]
OLDEDITOR = 1

VuGen opens in LR folder template/qtweb default.cfg and script files.

Vu scripts can be coded to use variable values obtained from parameter files external to the script.

I have a lot more on VuGenanother page on this site here

15. During a run, execution results are stored to a results folder.
Idea I prefer to set Results Settings to “Automatically create a results directory for each scenario execution.” which means that LR will increment the name of the Results Name when I start a scenario runs. For example, a value of “Res11” will be automatically incremented to “Res12” or sometimes “Res11-1”.

Errors are written to the output.mdb MS Access database. tool See the ASP page I have written to access this databaseanother page on this site

16. Within each results folder, a “Log” folder is automatically created to contain a log file for each group. After a run, to view a log file from within the Controller, click Vusers button then right-click on a group to select “Show Vuser Log”.

17. As a scenario is run, monitors maintain counters locally on each host.

18. After a run, the “collate” process takes .eve and .lrr result files and creates in the results folder a temporary .mdb (MS-Accessanother page on this site) database.

To prevent errors when processing large result files, use MSDE (Microsoft SQL Desktop Engine). Don’t install it from the Add-in folder on the LoadRunner 7.8 CD, which is obsolete SQL7. Download MSDE 2000 Release A which includes MSDE 2000 Service Pack 3a and MDAC 2.7 SP1a for use by Analysis on any Windows machine. Extract the file and share that folder. Open a command window to run a command such as:

setup SAPWD=”StrongPassword” INSTANCENAME=”LR” SECURITYMODE=SQL DISABLENETWORKPROTOCOLS=0 /L*v path to log file

Using Windows Explorer, share the Data folder.
Then in Analysis Options > Database tab, use 8.3 names without spaces (indentified with DOS command DIR /X):
1. Input the SAPWD password specified above.
2. Logical Storage location: \\loadclient02\Data (the folder you shared)
3. Physical Storage Location: C:\PROGRA~1\MICROS~1\MSSQL\Data (not C:\Program Files\Microsoft SQL Server\MSSQL\Data)
4. Click “Test parameters”. (This takes a few seconds)

19. [icon for Analysis module] The Analysis Module (8,320K analysisu.exe)
20. generates analysis graphs and reports using data from the .mdb database.
21. The LoadRunner Results file results_name.lrr from each scenario run — also called an Analysis document file — is read by the Analysis program to display Percentile graphs.
22. By default, the LRReport folder is created in the test analyst’s local machine My Documents folder to store Analysis Session files.
23. They can optionally be formated in HTML.
24. Their format are controlled by a .tem template file.

25. Optionally, Mercury’s Remote Performance Monitoring (RPM) MS-IIS/ASP web server for LoadRunner 7.8 can be installed on a Windows 2000 server (Caution! but not on a Windows 2003 server) so that
26. load test results to be viewed using a web browser.
Not pictured is the LoadRunner Tuning Module (a separate $50,000 product).

原文請參考這裡 http://www.wilsonmar.com/1loadrun.htm

- See more at: http://www.rickyzhu.com/21_principle-graph-of-loadrunner.html#sthash.OX52qhHf.dpuf

 

相關文章