UNIX Machines and Tests Triggered From Windows

How to run regression tests on UNIX machines and UNIX commands triggered from Windows machines with VBScript or VB.NET code.

Part of my SOA automation framework was to write a layer on VB.NET, that internally calls the QTP (to run some functional tests for a Windows application) and also call many other tools needed to be run both in Windows and all supported UNIX hosts. After a little investigation I learned to call the UNIX boxes from my regression test machine and run a series of UNIX commands from a Windows machine using VB.NET or VBScript code. I finally found a solution with the option to use a UNIX Remote Shell object to do the same without writing any test script specifically for UNIX boxes in Python again. Still we are able to manage the VBScript for the same for both Windows and UNIX boxes.    

RSH is used to execute commands on a remote machine. The RSH command executes the command or a program in another host from the current working machine without having to log into that remote machine by entering a password as in ssh. You can run any UNIX command, or a shell script of a remote host.

As an example of rsh use, the following executes the command mkdir testdir as user remoteuser on the computer "host.example.com" running a UNIX-like system:

rsh -l remoteuser host.example.com "mkdir testdir"
 
Sample UNIX command to execute the product exe file from a Windows machine:

Rsh.exe aix -l g1qareg setenv  LIBPATH /export/home/hg1/host_6.0.1306.0.exe

Command executed:

Rsh.exe aix -l g1qareg setenv  LIBPATH /export/home/hg1/STT_Tests/Generate_Regression/builds/aix5/doc1host_6.0.1306.0/; cd /export/home/hg1/STT_Tests/Generate_Regression/Input/56_inputs/all;/export/home/hg1/STT_Tests/Generate_Regression/builds/aix5/Test_6.0.1306.0/TestTool /export/home/hg1/Test1.rem ops=/export/home/hg1/STT_Tests/56_generic_ops/Test1.ops MMGX CMP ecp=/export/home/hg1/STT_Tests/builds/aix5/Test1/doc1ecp;

Part of the code snippet in VBScript to generate dynamically using configuration settings parameters:

'=================INSTALL SETTINGS====================================

Install_on = array("zsuse") 'Names should be same as  arrUnixBoxNames below

'arrUnixBoxNames=array("hpux11","redhat","sun480","sun450","tru64","aix","hpuxi","zsuse")

'================= RUN - MANDATORY SETTINGS==========================

user_ID ="g1qareg" ' used in RSH calls.

Public Const use_Doc1gen_MMGX_Swtich = True

Private Sub setBuildVersion()

    If Lcase(Shell_Verbosity) = "on" Then : wscript.echo("setBuildVersion() called.") : End If

    Dim strLine, logFileStream, localFSO, objWshShell, objWshShellExec, strCmd

    localFSO = CreateObject("Scripting.FileSystemObject")

    'Set localFSO.CreateTextFile(oTempLogFile, True)

    'On Error Resume Next

    objWshShell = WScript.CreateObject("WScript.Shell")

    Select Case Unix_Boxes(i)

        Case "windows"

            strCmd = "%comspec% /c " & strDOC1GenDir & " Test.exe > " & oTempLogFile

        Case Else

            strCmd = "%comspec% /c Rsh.exe " & Unix_Boxes(i) & " -l " & user_ID & " " _

                                                                            & strEnv & "; " & strDir & "Test.exe > " & oTempLogFile

    End Select

    objWshShellExec = objWshShell.Exec(strCmd)

    If Lcase(Debug_Mode) = "on" Then

        'wscript.echo "Rsh.exe "&Unix_Boxes(i) &" -l g1ar01 " &strEnv &"; " &strDOC1GenDir &"doc1gen"

        msgbox("Rsh.exe " & Unix_Boxes(i) & " -l " & user_ID & " " & strEnv & "; " & strDir & "Test.exe")

    End If


The following shows the PUTTY or TELNET configuration to open the UNIX boxes from the Windows machines.

Note: RSH does not require any of the tools to be installed in the test machine, only manual verification requires these tools.

UNIX-Commands-1.jpg

UNIX-Commands-2.jpg

Note: if you are not able open the telnet client from "RUN"  -> "COMMAND" then enable the client in Windows 7 machines using the following setting:

"Control Panel"  -> "Program and Features" -> "Windows features on or off" -> "Enable the Telnet client"

UNIX-Commands-3.jpg

Overview of Framework Architecture

UNIX-Commands-4.jpg

Regression Script Basic Flow Diagram

UNIX-Commands-5.jpg


Similar Articles