• Home
  • Company
    • About
    • Customers
    • Testimonials
    • Contact Us
    • My Account
  • Products
  • Downloads
  • Tutorials
  • Professional Services
  • Home
  • Company
    • About
    • Customers
    • Testimonials
    • Contact Us
    • My Account
  • Products
  • Downloads
  • Tutorials
  • Professional Services
Free Edition Compatible
Manage Multiple Communication Sessions in Parallel
Objectives
In this tutorial you'll learn HOW TO:
► Open many Telnet, Serial and SSH sessions in parallel
► Keep connections active even after the test completed  
► Send messages to a particular remote host and wait for its certain response
► Send automatic KEEP ALIVE periodic messages in background
► Refer to communication channels by logical names 
► Save separate communication log files for each connection
► Monitor all session in separate windows using the Coronys Viewer
All Tutorials
How to ...
Create Re-Usable Test Steps
Create the folowing test step items on the ETS Test Step Tree:
 
Start Viewer
Launches the Coronys Multi-Channel Viewer
Open Serial
Starts a new Serial connection
Open Telnet
Starts a new Telnet session
Open SSH
Starts a new SSH session
Send and Wait
Sends a message and waits for a particular text in the response
Start Keep Alive
Starts periodic send of KEEP ALIVE messages in background
Close
Closes a specific connection by name
Read the "Reusable Test Steps with Parameters" article to learn how to add test steps to the ETS Test Step Tree.
Implementation Notes
  • Copy scripts below and paste to the templates created by your ESL Editor.
  • All examples use the ESL special variable @RES (Resource object) that holds the unique resource handler.
  • The Start functions associate the name you provided in epChanName to the new connection.
  • RES:@epChanName holds the connection handler. It is recognized by the Coronys Interpreter in any context.
  • As long as a conection is active you can refer to it in your scripts by RES:@epChanName, where epChanName holds the channel name.
  • The Start functions in examples open the connections in protected mode.
  • You can start connection in protected mode in one test case and to close it in another one.
  • As long as a connection is active you'll ses the message exchange in an appropriate Coronys Viewer window.
  • The connection in protected mode stays active even after your test case has completed.
  • RC_RouteToViewer ESL function is used to re-direct a communication stream to the Coronys Viewer.
  • RC_RouteToFile ESL functions starts the communication log. Learn more about logs in "How to Create Drill Down Logs".
  • The RC_Close stops one particular connection and releases all assosiated events and resources.
Copy scripts above to the templates created by the ESL Editor.
This script example shows the usage of the ESL special variable @RES (Resource object) that holds the unique resource handler.
The function RC_TelnetPortSet associates the name held in epChanName to the channel it opens.
RES:@epChanName is the Telenet session handler referred by the variable epChanName.
The function RC_TelnetPortSet opens the Telnet port in protected mode that keeps Telenet session active as long as the RC_Close was not executed.
You can start Telnet in one test case and close it in another one.
In the mean time the channel is active and you can refer to it in your scripts by RES:@epChanName.
Start Viewer

The Coronys Viewer shows the messages exchange of each channel in a separate window.
Once started it will stay active until you close it explicitly. 
The RC_RouteToViewer command to show messages in the Viewer can be issued at any point as the channnel started.
In our examples, we start the re-routing to the VIewer at the open communication stage.
Read the Monitor Multiple Channels with Coronys Viewer article to learn more how to launch and use the Multi-Channel Monitor.
Open Serial

This starts a new Serial connection.
Selection Time Parameters
epChanName - the connection logical name. You should specify a unique name, e.g. "Host_1"
epCOM - the COM port name, the default='COM1'
epBaudRate - the baud rate, the default=115200
The defaults should be replaced with actual settings.
Script Implementation
     DeclareOnce  epChanName = `MySerial`     ;Unique channel logical name
     DeclareOnce  epCOM = `COM1`      ;COM port
     DeclareOnce  epBaudRate = `115200`   ;Baud rate, the default=115200  
    
     Declare  Status ,  FileName

     ; Start Serial in Protected mode (active after script end)
     RC_SerialPortSet  Status ,  epCOM ,  epBaudRate ,   8 ,   2 ,   1 ,  epChanName  ; 2 is for protected mode
     If  Status == 0   Then   Abort   "Failed to open Channel="   $  epChanName  $   " on COM="   $  epCOM

     ; Write Rx and Tx messages to Log file
    FileName  =   'C:\temp\'   $  epChanName  $   '.log'
     RC_RouteToFile  Status ,   @RES:@epChanName ,   1 ,  FileName ,   3
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Failed to create a log, File name='   $  FileName
    
     ; Start routing Rx and Tx messages to Coronys Viewer
     RC_RouteToViewer  Status ,   @RES:@epChanName ,   3 ,  epChanName
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Error connecting the Viwer at Start'
    
     ; Clean up the Coronys Viewer window
     RC_RouteToViewer  Status ,   @RES:@epChanName ,   4 ,  epChanName 
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Error connecting the Viwer at Clean'

     End  
Open Telnet

This starts a new Telnet session.
Open Step Parameters
Selection Time Parameters
epIP - the remote host IP address
epChanName - the connection logical name. You should specify a unique name, e.g. "Host_1"
The defaults should be replaced with actual settings.
Script Implementation

     ; Test Step Input Parameters
     DeclareOnce  epIP = `10.10.10.10`        ;Target  IP
     DeclareOnce  epChanName = `MyTelnet`     ;Channel unique logical name
    
     Declare  Status ,  FileName
    
     ; Start Telnet in Protected mode to keep active after test case end
     RC_TelnetPortSet  Status ,  epIP ,   23 ,   0 ,   2 ,  epChanName  ; 2 is for protected mode
     If  Status == 0   Then   Abort   "Failed to open Telnet, IP= "   $  epIP   $   " Channel="   $  epChanName

     ; Write Rx and Tx messages to Log file
    FileName  =   'C:\temp\'   $  epChanName  $   '.log'
     RC_RouteToFile  Status ,   @RES:@epChanName ,   1 ,  FileName ,   3
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Failed to create a log, File name='   $  FileName
    
     ; Start routing Rx and Tx messages to Coronys Viewer
     RC_RouteToViewer  Status ,   @RES:@epChanName ,   3 ,  epChanName
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Error connecting the Viwer at Start'
    
     ; Clean up the Coronys Viewer window
     RC_RouteToViewer  Status ,   @RES:@epChanName ,   4 ,  epChanName 
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Error connecting the Viwer at Clean'

     End  
Open SSH

This starts a new SSH session.
Selection Time Parameters
epIP - the remote host IP address
epChanName - the connection logical name. You should specify a unique name, e.g. "Host_1"
epUserName - login user name 
epPassword - login password
The defaults should be replaced with actual settings.
Script Implementation
     ; Test Step Input Parameters
     DeclareOnce  epIP = `10.10.10.10`    ;Target  IP
     DeclareOnce  epChanName = `MySSH`    ;Channel logical name
     DeclareOnce  epUserName = `MyName`   ;SSH user name
     DeclareOnce  epPassword = `MyPassword`   ;SSH Password
    
     Declare  Status ,  FileName
    
     ; Start SSH in Protected mode (active after script end)
     RC_SSHPortSet  Status ,  epIP ,   22 ,  epUserName ,  epPassword ,   _None ,   2 ,  epChanName  ; 2 is for protected mode
     If  Status == 0   Then   Abort   "Failed to open SSH, IP= "   $  epIP   $   " Channel="   $  epChanName

     ; Write Rx and Tx messages to Log file
    FileName  =   'C:\temp\'   $  epChanName  $   '.log'
     RC_RouteToFile  Status ,   @RES:@epChanName ,   1 ,  FileName ,   3
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Failed to create a log, File name='   $  FileName
      
     ; Start routing Rx and Tx messages to Coronys Viewer
     RC_RouteToViewer  Status ,   @RES:@epChanName ,   3 ,  epChanName
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Error connecting the Viwer at Start'
  
     ; Clean up the Coronys Viewer window
     RC_RouteToViewer  Status ,   @RES:@epChanName ,   4 ,  epChanName 
     If  Status == 0   Then   TMMessage   GT_ErrorID ,   'Error connecting the Viwer at Clean'
    
     End  
Send and Wait

This sends a message over a specific channel and waits for a particular text in the response.
Selection Time Parameters
epChanName - the connection logical name you assigned at Open
epBaudRate - the message to be sent
epExpResp - the expected text in Rx stream to stop waiting and to return the SUCCESS
epTimeout - max time to wait for epExpResp in response in milliseconds
The defaults should be replaced with actual settings.
Script Implementation
     ; Test Step Input Parameters
     DeclareOnce  epChanName = `MyChan`   ;Channel name
     DeclareOnce  epMsg = `My Message`    ;Message to Send
     DeclareOnce  epExpResp = `Text`      ;Expected text in the response stream
     DeclareOnce  epTimeout = 1000        ;Max time to wait for epExpResp in msecs

     Declare  Status
    
     ; @RES:@epChanName stands for a specific channel handler. 
     ; The variable epChanName should hold the resource name assigned at Open. 
     If   @RES:@epChanName == 0   Then   End   ; Leave if does not exist

     ; Send a message with the carrage return (^M) terminator (may depend on channel type)
     RC_SendAndWait  Status ,   @RES:@epChanName ,  epMsg  $   "^M" ,  epExpResp ,  epTimeout
     If  Status  ==   1   Then   TMMessage   GT_ErrorID ,   "Timeout waiting for "   $  epExpResp  $   " at "   $  epChanName

     End  
Start Keep Alive

This starts periodic KEEP ALIVE messages through a specific chanel in background.
Multiple KEEP ALIVE sequences can be defined for one channel.
Selection Time Parameters
epChanName -  the connection logical name you assigned at Open
epSeqID -  unique number that udentifies a certain keep alive message.
epMsg -  message to be sent
epPeriod - time between two sends in milliseconds
epBinary - epMsg format: 0 - textual, 1 - binary, e.g. "65;1;0.33;4"
The defaults should be replaced with actual settings.
Script Implementation
     ; Test Step Input Parameters
     DeclareOnce  epChanName = `MyChan`   ;Channel logical name
     DeclareOnce  epSeqID = `1  ;Uniques sequence ID
     DeclareOnce  epMsg = `1`     ;Message to be sent
     DeclareOnce  epPeriod = `1000`   ;Time between two sends in msecs
     DeclareOnce  epBinary = `1`      ;EpMsg format: 0-text  1-binary e.g. "65;1;0.33;4"

     Declare  Status
    
     ; Start periodic send of emMsg
     RC_PeriodicSend   @RES:@epChanName ,  epSeqID ,   1 ,  epMsg ,   - 1 ,  epPeriod ,  epBinary
    
     End  
Close

This terminates a specific connection by name and releases its resources.
Selection Time Parameters
epChanName - the connection logical name of any type assigned at Open.
Script Implementation
     DeclareOnce  epChanName = `MyTelnet`     ;Channel name
    
     ; Close resource by name 
     RC_Close   @RES:@epChanName
    
     End  
 
Drag your new test step to the Flow Editor:
If you defined "Selection Time Parameters", the "User Parameters" window will pop up:
Click on Value field to open FIle Explorer to choose your application to run.
Define timeout longer than expected execution time.
Ckick OK to apply.
Click "Run" button to run your test.
  • Home
  • Products
  • Downloads
  • Tutorials
  • Contact Us
  • Terms of Use
  • Privacy Policy

Copyright © 2002-2017 Coronys Ltd. All Rights Reserved.
 
Back to top