如何进行EJB的压力测试
1、建立ejbdetector的代理服务器端
在测试机器上运行ejbdetector代理程序:
EJB_Detector.cmd
windows平台:
@echo off
rem This script should be used to run EJBDetector.
rem Before running it the user must supply the appropriate variables in env.cmd file which defines the environment for running
rem EJBDetector.
rem Usage: EJB_Detector [listenPort]
rem where: [listenPort] - (optional) specifies the port number on which mercury's HTTP server will wait for incoming requests
rem default is 2001
call env.cmd
if "%1"=="-help" (
goto :printUsage
)
if "%1"=="-h" (
goto :printUsage
)
set result=toRun
if %APP_SERVER_ROOT%=="" if %EJB_DIR_LIST%=="" set result=toError
if "%result%"=="toRun" goto :run
if "%result%"=="toError" goto :printError
:printExpl
echo NOTE: For running EJBDetector, define the following variables in env.cmd:
echo JAVA_HOME - the root directory of JDK installation
echo DETECTOR_INS_DIR - the root directory of Detector installation
echo APP_SERVER_DRIVE - the drive hosting the application server installation
echo APP_SERVER_ROOT - the root directory of application server as explained in env.cmd
echo EJB_DIR_LIST - (optional) list of directories/files separated by ';'
goto :end
:printUsage
echo Usage: EJB_Detector [listenPort]
echo where:
echo [listenPort](optional) specifies the port number on which mercury's HTTP server will wait for incoming requests (default is 2001)
goto :printExpl
:printError
echo ERROR: APP_SERVER_ROOT or EJB_DIR_LIST was not specified in env.cmd file
goto :printExpl
:run
if not %APP_SERVER_ROOT%=="" (
if not %EJB_DIR_LIST%=="" (
echo %JAVA_HOME%/bin/java -Dvendor=Weblogic7.x EJBDetector %APP_SERVER_ROOT%;%EJB_DIR_LIST% %1
%JAVA_HOME%/bin/java -Dvendor=Weblogic7.x EJBDetector %APP_SERVER_ROOT%;%EJB_DIR_LIST% %1
goto :end
)
)
if not %APP_SERVER_ROOT%=="" (
echo %JAVA_HOME%/bin/java -Dvendor=Weblogic7.x EJBDetector %APP_SERVER_ROOT% %1
%JAVA_HOME%/bin/java -Dvendor=Weblogic7.x EJBDetector %APP_SERVER_ROOT% %1
goto :end
)
if not %EJB_DIR_LIST%=="" (
echo %JAVA_HOME%/bin/java -Dvendor=Weblogic7.x EJBDetector %EJB_DIR_LIST% %1
%JAVA_HOME%/bin/java -Dvendor=Weblogic7.x EJBDetector %EJB_DIR_LIST% %1
goto :end
)
:end
pause
env.cmd
rem This script sets up environment for running EJB and Monitor Detector.
rem Define the following variables (Use quotes when your path contains spaces):
rem JAVA_HOME - the root directory of JDK installation
rem DETECTOR_INS_DIR - the root directory of Detector installation
rem APP_SERVER_DRIVE - the drive hosting the application server installation ( i.e. D: )
rem APP_SERVER_ROOT - Follow these guidelines:
rem BEA WebLogic Servers: Specify the application server root directory.
rem WebSphere Servers 3.0: Specify the full path to the deployed EJBs folder.
rem WebSphere Servers 3.5: Specify the application server root directory.
rem WebSphere Servers 4.0: Specify the application server root directory.
rem Oracle OC4J: Specify the application server root directory.
rem Sun J2EE Server: Specify the root directory of the application server installation or the full path to the deployable .ear file or directory containing a number of .ear files.
rem EJB_DIR_LIST - BEA WebLogic Servers 6.x and 7.x: Specify the full path to the domain folder.
rem (optional) list of directories/files separated by ';'
@echo on
set JAVA_HOME=C:/j2sdk1.4.2_04
set DETECTOR_INS_DIR=D:/CEBBank/ejbdetector8
set APP_SERVER_DRIVE="D:/bea"
set APP_SERVER_ROOT="D:/bea/weblogic92"
set EJB_DIR_LIST="D:/CEBBank/CEBApi/wtc_service.jar"
set PATH=%DETECTOR_INS_DIR%/bin;%PATH%
set CLASSPATH=%DETECTOR_INS_DIR%/dat;%DETECTOR_INS_DIR%/classes;%DETECTOR_INS_DIR%/classes/xerces.jar;%DETECTOR_INS_DIR%/classes/xml-apis.jar;%DETECTOR_INS_DIR%/classes/xalan.jar;D:/bea/weblogic92/server/lib
@echo off
if exist %JAVA_HOME%/lib/classes.zip set CLASSPATH=%JAVA_HOME%/lib/classes.zip;%CLASSPATH%
UNIX平台:
EJB_Detector.sh
#!/bin/sh
# $Id: EJB_Detector.sh,v 1.5 2002/12/01 13:19:28 dants Exp $ [MISCCSID]
#################################################################################################################################
#This script should be used to run EJBDetector.
# Before running it the user must supply the appropriate variables in env.sh file which defines the environment for running
# EJBDetector.
# Usage: EJB_Detector.sh [listenPort]
# where: [listenPort] - (optional) specifies the port number on which mercury's HTTP server will wait for incoming requests
# (defaults to 2001)
#################################################################################################################################
. ./env.sh
printExp() {
echo "NOTE: For running EJBDetector, define the following variables in env.cmd:"
echo " JAVA_HOME - the root directory of JDK installation"
echo " DETECTOR_INS_DIR - the root directory of Detector installation"
echo " APP_SERVER_ROOT - the root directory of application server"
echo " EJB_DIR_LIST - (optional) list of directories/files separated by ':'"
return 0
}
printUsage() {
echo "Usage: EJB_Detector [listenPort]"
echo " where:"
echo " [listenPort](optional) specifies the port number on which mercury's HTTP server will wait for incoming requests(default
is 2001)"
return 0
}
printError() {
echo "ERROR: APP_SERVER_ROOT or EJB_DIR_LIST was not specified in env.cmd file"
return 0
}
if [ "$JAVA_HOME" = "" ]; then
echo JAVA_HOME is NULL
printExp
exit 1
fi
if [ "$DETECTOR_INS_DIR" = "" ]; then
echo DETECTOR_INS_DIR is NULL
printExp
exit 1
fi
if [ "$1" = "-help" -o "$1" = "-h" ]; then
printUsage
printExp
exit 1
fi
result="toRun"
if [ "$APP_SERVER_ROOT" = "" ]; then
if [ "$EJB_DIR_LIST" = "" ]; then
result="toError"
fi
fi
if [ "$result" = "toRun" ]; then
if [ "$APP_SERVER_ROOT" != "" ]; then
if [ "$EJB_DIR_LIST" != "" ]; then
echo $JAVA_HOME/bin/java -Dvendor=Weblogic7.x EJBDetector "$APP_SERVER_ROOT:$EJB_DIR_LIST" $1
$JAVA_HOME/bin/java -Dvendor=Weblogic7.x EJBDetector "$APP_SERVER_ROOT:$EJB_DIR_LIST" $1
fi
if [ "$EJB_DIR_LIST" = "" ]; then
echo $JAVA_HOME/bin/java -Dvendor=Weblogic7.x EJBDetector $APP_SERVER_ROOT $1
$JAVA_HOME/bin/java -Dvendor=Weblogic7.x EJBDetector $APP_SERVER_ROOT $1
fi
fi
if [ "$APP_SERVER_ROOT" = "" ]; then
if [ "$EJB_DIR_LIST" != "" ]; then
echo $JAVA_HOME/bin/java -Dvendor=Weblogic7.x EJBDetector $EJB_DIR_LIST $1
$JAVA_HOME/bin/java -Dvendor=Weblogic7.x EJBDetector $EJB_DIR_LIST $1
fi
fi
fi
if [ "$result" = "toError" ]; then
printError
printExp
exit 1
fi
env.sh
#!/bin/sh
# $Id: env.sh,v 1.7 2002/12/01 10:31:03 dants Exp $ [MISCCSID]
##########################################################################################################################
# This script sets up environment for running EJB and Monitor Detector.
# Define the following variables:
# JAVA_HOME - the root directory of JDK installation
# DETECTOR_INS_DIR - the root directory of Detector installation
# APP_SERVER_ROOT - Follow these guidelines:
# BEA WebLogic Servers - Specify the application server root directory.
# IBM WebSphere Server 3.0 - specify the full path to the deployed EJBs folder.
# IBM WebSphere Server 3.5 - Specify the application server root directory.
# IBM WebSphere Server 4.x - Specify the application server root directory.
# Oracle OC4J server - Specify the application server root directory.
# SUN J2EE server - Specify the application server root directory or the full path to the deployable .ear file or a directory containing a number of .ear files.
# EJB_DIR_LIST - for BEA WebLogic Server 7.x and 6.x - the server domain
# (optional) list of directories/files separated by ':'
##########################################################################################################################
JAVA_HOME=/JFdev/bea/jdk150_01; export JAVA_HOME
DETECTOR_INS_DIR=/JFdev/ejbdetector8; export DETECTOR_INS_DIR
APP_SERVER_ROOT=/JFdev/bea/weblogic91; export APP_SERVER_ROOT
EJB_DIR_LIST=/JFdev/bea/user_projects/domains/base_domain/servers/AdminServer/upload/wtc_service.jar; export EJB_DIR_LIST
LD_LIBRARY_PATH=${DETECTOR_INS_DIR}/bin; export LD_LIBRARY_PATH
CLASSPATH=${DETECTOR_INS_DIR}/dat:${DETECTOR_INS_DIR}/classes:${DETECTOR_INS_DIR}/classes/xerces.jar:${DETECTOR_INS_DIR}/classes/xml-apis.jar:${DETECTOR_INS_DIR}/classes/xalan.jar:/JFdev/bea/weblogic91/server/lib; export CLASSPATH
if [ -f $JAVA_HOME/lib/classes.zip ]; then
CLASSPATH=${JAVA_HOME}/lib/classes.zip:${CLASSPATH}; export CLASSPATH
fi
OK 然后就可以启用 EJB_Detector的应用程序了。注意配置文件中的相关路径和相关EJB的jar包文件。必要的时候修订classes目录中的webserver.properties,将debug信息开关打开,查看debug信息。
windows平台,启动EJB_Detector.cmd 1234 查看:
------------------------- Found 3 EJBs ---------------------------
** PATH: D:/CEBBank/CEBApi/wtc_service.jar
- BEAN: com.gemfor.wtc.service.WTCServiceBean
- BEAN: com.gemfor.wtc.service.WtcserverbeanTest
- BEAN: com.gemfor.wtc.client.TuxedoConnectorBean
DetectClassLoader SOURCES:
- D:/bea/weblogic92/server/lib
- D:/bea/weblogic92
- D:/CEBBank/ejbdetector8/dat
- D:/CEBBank/CEBApi/wtc_service.jar
- D:/CEBBank/ejbdetector8/classes
- D:/CEBBank/ejbdetector8/classes/xalan.jar
- D:/CEBBank/ejbdetector8/classes/xml-apis.jar
Starting http server...
Loading webserver.properties[D:/CEBBank/ejbdetector8/classes/webserver.properties...
Using webserver properties directory to store the 'webserver.log' file...
Web Server started...
Listening on port: 1234
这样就算启动成功了。
2、下面开始启动Mercury LoadRunner的程序
开始-》程序-》Mercury LoadRunner-》Applications-》Virtual User Generator
启动后,选择到:
Enterprise Java Bean (EJB)类型:
在接下来的弹出页面中:
NAME:输入刚才启动的机器和端口 例如:10.1.112.155:1234(这是我的),很快就会看到连接成功。
如果不能,点击:Options,查看是否包含:
.
C:/j2sdk1.4.2_04/lib
D:/bea/weblogic92/server/lib/weblogic.jar
这些环境包。
在我遇到的问题中,不管怎么加总是提示连接不到指定的server机器,但是因为我在客户这边是通过代理上网,而当时又没有设定代理上网,然后我就尝试修订了IE中的代理服务器设定,居然就可以了,这个问题比较迷惑,个人认为可能是EJB RMI获取JNDI时候获取不到引起的问题。
以上内容,只是随笔记录,让大家自行学习和参考。