Wednesday, March 20, 2013

Run scripts through the Rational Functional Tester command line

http://www.ibm.com/developerworks/rational/library/run-scripts-through-the-rational-functional-tester-command-line/index.html#fig01


In this first section, software testers will learn how to use IBM® Rational® Functional Tester to run Java or .NET scripts from the command line. This gives you the ability to integrate Rational Functional Tester with external test drivers, such as STAF (Software Testing Automation Framework) and STAX. You can create a script by using the recorder or just create an empty script.
To play back a Java script, use the script in Listing 1.
Important: 
The order of the arguments is significant.

Listing 1. To play back a Java script
java -Drational_ft.install.dir=<Rational FT
install directory> <-classpath...>
com.rational.test.ft.rational_ft -datastore
<directory> -log <logname> [options] -playback
<script-name> 

To play back a Microsoft VB.NET script, use the script in Listing 2.

Listing 2. To play back a VB.NET script
rational_ft.exe -datastore <directory> -log
<logname> [options] -playback <script-name> 


Listing 3. Batch file to run the Rational Functional Tester Java script
: Disclaimer that this batch file is created for Rational Functional Tester 
:version 8.0  on the Operating System Windows XP
: Usage of the batch file 
:e.g. RFT_PlayScript ProjectPath ScriptName LogName [silent]

@ECHO OFF
:start
:save_args_as_variables
set RFT_PROJECT_LOCATION=%1
set RFT_SCRIPT_NAME=%2
set RFT_LOGFILE_NAME=%3
goto check_args
:check_args
if "%RFT_PROJECT_LOCATION%" == "" goto missing_args
if "%RFT_SCRIPT_NAME%" == "" goto missing_args
if "%RFT_LOGFILE_NAME%" == "" goto missing_args
goto args_ok
:args_ok
if "%4" == "silent" goto playback
echo.
echo RFT_PROJECT_LOCATION = %RFT_PROJECT_LOCATION%
echo RFT_SCRIPT_NAME = %RFT_SCRIPT_NAME%
echo RFT_LOGFILE_NAME = %RFT_LOGFILE_NAME%
echo IBM_RATIONAL_RFT_ECLIPSE_DIR = %IBM_RATIONAL_RFT_ECLIPSE_DIR%
echo IBM_RATIONAL_RFT_INSTALL_DIR = %IBM_RATIONAL_RFT_INSTALL_DIR%
echo.
echo Initializing RFT Playback...
:playback
"%IBM_RATIONAL_RFT_ECLIPSE_DIR%\jdk\jre\bin\java" 
-classpath "%IBM_RATIONAL_RFT_INSTALL_DIR%\rational_ft.jar" 

com.rational.test.ft.rational_ft -datastore %RFT_PROJECT_LOCATION%
 -playback %RFT_SCRIPT_NAME% -log %RFT_LOGFILE_NAME%
if "%4" == "silent" goto end
echo RFT playback complete.
goto end
:missing_args
echo.
echo ERROR: Invalid syntax! Usage: 
echo RFT_PlayScript ProjectPath ScriptName LogName [silent]
goto end
:end

Parameters passed here are the location of the project, the name of the script to run, and the name of the log file.
For example, suppose that you have a project named SampleProject at C:\SampleWorkSpace, and a script called SampleScript. In this situation:
Your RFT_PROJECT_LOCATION is C:\SampleWorkSpace\SampleProject
RFT_SCRIPT_NAME is SampleScript
RFT_LOGFILE_NAME is SampleScript
To run this batch file from command prompt, go to the location where this batch is present. For the example in Figure 1, assuming that this batch file PlayBack.bat file is at the command prompt: c:\

Listing 4. How to run the batch file through command prompt
C:\>PlayBack.bat C:\SampleWorkSpace\SampleProject SampleScript SampleScript


Figure 1. Command prompt
Executing the batch file 


Listing 5. Batch file to run the RFT VB.NET script
: Disclaimer that this batch file is created for Rational Functional Tester 
:version 8.0 on the operating system Windows XP

: Usage of the batch file
: e.g. RFT_PlayScript ProjectPath ScriptName LogName [silent]

:start

:save_args_as_variables
set RFT_PROJECT_LOCATION=%1
set RFT_SCRIPT_NAME=%2
set RFT_LOGFILE_NAME=%3
goto check_args

:check_args
if "%RFT_PROJECT_LOCATION%" == "" goto missing_args
if "%RFT_SCRIPT_NAME%" == "" goto missing_args
if "%RFT_LOGFILE_NAME%" == "" goto missing_args
goto args_ok

:args_ok
if "%4" == "silent" goto playback
echo.
echo RFT_PROJECT_LOCATION = %RFT_PROJECT_LOCATION%
echo RFT_SCRIPT_NAME = %RFT_SCRIPT_NAME%
echo RFT_LOGFILE_NAME = %RFT_LOGFILE_NAME%
echo IBM_RATIONAL_RFT_INSTALL_DIR = %IBM_RATIONAL_RFT_INSTALL_DIR%
echo.
echo Initializing RFT Playback...

:playback
"%IBM_RATIONAL_RFT_INSTALL_DIR%\rational_ft.exe" -datastore 
%RFT_PROJECT_LOCATION% -playback %RFT_SCRIPT_NAME% 
-language vb -log %RFT_LOGFILE_NAME%

if "%4" == "silent" goto end
echo RFT playback complete.
goto end

:missing_args
echo.
echo ERROR: Invalid syntax! Usage: 
echo RFT_PlayScript ProjectPath ScriptName LogName [silent]
echo.
pause
goto end

:end


Listing 6. To play back a Java script with parameters
java -Drational_ft.install.dir=<Rational FT
install directory> <-classpath...>
com.rational.test.ft.rational_ft -datastore
<directory> -log <logname> [options] -playback
<script-name> [-args <values>]


Listing 7. Batch file to run the RFT JavaScript with parameters
: Disclaimer that this batch file is created for Rational Functional Tester 
:version 8.0  on the Operating System Windows XP

: Usage of the batch file 
:e.g. RFT_PlayScript ProjectPath ScriptName LogName [silent]

@ECHO OFF
:start
:save_args_as_variables
set RFT_PROJECT_LOCATION=%1
set RFT_SCRIPT_NAME=%2
set RFT_LOGFILE_NAME=%3
set RFT_Argument =%4

goto check_args
:check_args
if "%RFT_PROJECT_LOCATION%" == "" goto missing_args
if "%RFT_SCRIPT_NAME%" == "" goto missing_args
if "%RFT_LOGFILE_NAME%" == "" goto missing_args
goto args_ok
:args_ok
if "%4" == "silent" goto playback
echo.
echo RFT_PROJECT_LOCATION = %RFT_PROJECT_LOCATION%
echo RFT_SCRIPT_NAME = %RFT_SCRIPT_NAME%
echo RFT_LOGFILE_NAME = %RFT_LOGFILE_NAME%
echo IBM_RATIONAL_RFT_ECLIPSE_DIR = %IBM_RATIONAL_RFT_ECLIPSE_DIR%
echo IBM_RATIONAL_RFT_INSTALL_DIR = %IBM_RATIONAL_RFT_INSTALL_DIR%
echo.
echo Initializing RFT Playback...
:playback
"%IBM_RATIONAL_RFT_ECLIPSE_DIR%\jdk\jre\bin\java" 
-classpath "%IBM_RATIONAL_RFT_INSTALL_DIR%\rational_ft.jar"
 com.rational.test.ft.rational_ft -datastore 
%RFT_PROJECT_LOCATION%
 -playback %RFT_SCRIPT_NAME% -log %RFT_LOGFILE_NAME% 
 [-agrs %RFT_Argument%]
if "%5" == "silent" goto end
echo RFT playback complete.
goto end
:missing_args
echo.
echo ERROR: Invalid syntax! Usage: 
echo RFT_PlayScript ProjectPath ScriptName LogName [silent]
goto end
:end


Listing 8. To play back a Microsoft .NET script with parameters
rational_ft.exe -datastore <directory> -log
<logname> [options] -playback <script-name> [-args<values>]

This section offers a few tips for creating and recording Rational Functional Tester scripts through the command line. You can integrate these with the batch files described previously to perform different actions using Rational Functional Tester on command line.

Listing 9. Record a new script
rational_ft.exe -datastore <directory> -log
<logname> [options] -record <script-name>


Listing 10. Record into an existing script, inserting before or after a given line
rational_ft.exe -datastore <directory> -[ -insertbefore <line>] 
[ -insertafter <line>] [options] -map <sharedmap>] 
[options] -record <script-name>

Note:
You must enable the Java environment before compiling a script with this command. You must also install the Java SDK and add the bin directory to the path.

Listing 11. Compile a script
rational_ft.exe -datastore <directory> [options] [options] -compile <script-name>


Listing 12. Record, compile, and play back a script
rational_ft.exe -datastore <directory> [options] -record <script-name> 
-compile -playback [ -args <values>]


Learn
Get products and technologies
  • Try Rational Functional Tester free requires registration).
  • Evaluate IBM software in the way that suits you best: Download it for a trial, try it online, use it in a cloud environment, or spend a few hours in the SOA Sandbox learning how to implement service-oriented architecture efficiently.
Discuss

Tuesday, March 5, 2013

Set up my svn server for svnsync purpose


OS = RHEL/CentOS/Fedora

1. Install LAMP or at least httpd and php

yum install httpd php php-common

yum install php-pecl-apc php-cli php-pear php-pdo php-mysql php-pgsql php-pecl-mongo php-sqlite php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml

start apache:

Start apache server:

/etc/init.d/httpd start ## use restart after update
## OR ##
service httpd start ## use restart after update
chkconfig --levels 235 httpd on


Add following content to /var/www/html/test.php file to test php

<?php
 
    phpinfo();
 
?>



2. then install svn:

yum install mod_dav_svn subversion

Add following config to /etc/httpd/conf.d/subversion.conf file:

LoadModule dav_svn_module     modules/mod_dav_svn.so
LoadModule authz_svn_module   modules/mod_authz_svn.so
 
<Location /svn>
   DAV svn
   SVNParentPath /var/www/svn
   AuthType Basic
   AuthName "Subversion repositories"
   AuthUserFile /etc/svn-auth-users
   Require valid-user
</Location>


Add subversion users:
## Create testuser ##
htpasswd -cm /etc/svn-auth-users testuser
New password: 
Re-type new password: 
Adding password for user testuser
 
## Create testuser2 ##
htpasswd -m /etc/svn-auth-users testuser2
New password: 
Re-type new password: 
Adding password for user testuser2




Create and configure SVN repository

mkdir /var/www/svn
cd /var/www/svn
 
svnadmin create testrepo
chown -R apache.apache testrepo
 
chcon -R -t httpd_sys_content_t /var/www/svn/testrepo
 
## Following enables commits over http ##
chcon -R -t httpd_sys_rw_content_t /var/www/svn/testrepo

Restart Apache:

/etc/init.d/httpd restart
## OR ##
service httpd restart
Goto http://localhost/svn/testrepo address and you should see something like following, write username and password:
SVN Subversion username and password
SVN testrepo revision 0:
SVN Subversion Repository Revision 0

6. Configure repository

To disable anonymous access and enable access control add following rows to testrepo/conf/svnserve.conf file:
## Disable anonymous access ##
anon-access = none
 
## Enable access control ##
authz-db = authz

7. Create trunkbranches and tags structure under testrepo

Create “template” directories with following command:
mkdir -p /tmp/svn-structure-template/{trunk,branches,tags}
Then import template to project repository using “svn import” command:
svn import -m 'Initial import' /tmp/svn-structure-template/ http://localhost/svn/testrepo/
Adding         /tmp/svn-structure-template/trunk
Adding         /tmp/svn-structure-template/branches
Adding         /tmp/svn-structure-template/tags
 
Committed revision 1.
Check results on browser and see testrepo revision 1:



SVN Subversion Repository Revision 1








svnadmin create /var/www/svn/iphone-mirror

chown -R apache.labtools /var/www/svn/iphone-mirror

vi /var/www/svn/iphone-mirror/hooks/pre-revprop-change


#!/bin/sh
USER="$3"
if [ "$USER" = "user-who-is-allowed-to-do-the svnsync" ]; then exit 0; fi
echo "Only the svnsync user can change revprops" >&2
exit 1


chmod 755 /var/www/svn/iphone-mirror/hooks/pre-revprop-change

svnsync init --username cccc file:///var/www/svn/iphone-mirror svn://xx.xx.xx.121:3692/

svnsync sync --username cccc file:///var/www/svn/iphone-mirror




------------------------------------------------------------------------------------------
more URL's

http://svn.apache.org/repos/asf/subversion/trunk/notes/svnsync.txt
http://josephscott.org/archives/2010/01/setting-up-svnsync-and-svn-notify/
http://www.kirkdesigns.co.uk/mirror-svn-repository-svnsync
https://blogs.oracle.com/ashamash/entry/using_svnsync_to_migrate_an
http://blogs.collab.net/subversion/mirroring-repos


Schedule a cron job to run the sync periodically, say once every hour (on a nice odd number like 17 after the hour): 17 * * * * /usr/local/bin/svnsync --non-interactive sync file:///home/svn/repo-name