Forum Discussion

shrik18's avatar
shrik18
Occasional Contributor
7 years ago

jsch session instance

Hi, I am using jsch session in multiple test cases. I setup the server at start of the testcase and close the session at the end using groovy script.

 

Server setup code :

import com.jcraft.jsch.Session;

def servName = context.expand( '${#Project#servName}' )

ServerConfig servCon = new ServerConfig(servName)

def session = servCon.serverConnect(servName)

context.testCase.metaClass.session = session

log.info("Connected")

 

Session closing code:

import com.jcraft.jsch.Session;

def session = context.testCase.session

session.disconnect()

 

This works fine when testcases are run sequentially. However, throws error when they are run in parallel.

ERROR:An error occurred [session is down], see error log for details

ERROR:An error occurred [connection is closed by foreign host], see error log for details

 

I am guessing either it is not recognizing the individual sessions or closing all sessions when any of the testcase finishes. Rest of them throws the error. I would want to mention that whenever Ready!API is launched and run the testcases do run in parallel without any issues. But in the second run they throw this error. Is there a issue with how I am passing the instance?

6 Replies

  • shrik18's avatar
    shrik18
    Occasional Contributor
    Hi, I am using jsch session in my test cases. I setup the server in first step(groovy) of every test case and close it in last step(groovy). I am currently using following code: Setup server code: import com.jcraft.jsch.Session; def servName = context.expand( '${#Project#servName}' ) ServerConfig servCon = new ServerConfig(servName) def session = servCon.serverConnect(servName) context.testCase.metaClass.session = session //Note: ServerConfig is a library. Session Disconnect code: import com.jcraft.jsch.Session; def session = context.testCase.session session.disconnect(); This works for multiple test cases running sequentially. But when I runt testcases in parallel I get following error: ERROR:An error occurred [session is down], see error log for details I am thinking this is due to one of the test cases finishing early and running session disconnect code, which disconnects all session. Please help how can I run test cases in parallel, with individual sessions running and closing.
  • shrik18's avatar
    shrik18
    Occasional Contributor

    Hi, I am using jsch session in multiple test cases. I setup the server at start of the testcase and close the session at the end using groovy script.

     

    Server setup code :

    import com.jcraft.jsch.Session;

    def servName = context.expand( '${#Project#servName}' )

    ServerConfig servCon = new ServerConfig(servName)

    def session = servCon.serverConnect(servName)

    context.testCase.metaClass.session = session

    log.info("Connected")

     

    Session closing code:

    import com.jcraft.jsch.Session;

    def session = context.testCase.session

    session.disconnect()

     

    This works fine when testcases are run sequentially. However, throws error when they are run in parallel.

    ERROR:An error occurred [session is down], see error log for details

    ERROR:An error occurred [connection is closed by foreign host], see error log for details

     

    I am guessing either it is not recognizing the individual sessions or closing all sessions when any of the testcase finishes. Rest of them throws the error. I would want to mention that whenever Ready!API is launched and run the testcases do run in parallel without any issues. But in the second run they throw this error. Is there a issue with how I am passing the instance?

  • shrik18's avatar
    shrik18
    Occasional Contributor

    Hi,
    I am using jsch session in multiple test cases. I setup server at start of the testcase and close the session at the end using groovy script.

     

    Server setup code :
    import com.jcraft.jsch.Session;
    def servName = context.expand( '${#Project#servName}' )
    ServerConfig servCon = new ServerConfig(servName)
    def session = servCon.serverConnect(servName)
    context.testCase.metaClass.session = session
    log.info("Connected")

     

    Session closing code:
    import com.jcraft.jsch.Session;
    def session = context.testCase.session
    session.disconnect()

     

    This works fine when testcases are run sequentially. However, throws error when they are run in parallel.

     

    ERROR:An error occurred [session is down], see error log for details
    ERROR:An error occurred [connection is closed by foreign host], see error log for details

     

    I am guessing either it is not recognizing the individual sessions or closing all sessions when any of the testcase finishes and rest of them throws the error.

    I would want to mention that whenever Ready!API is launched and run the testcases do run in parallel without any issues. But in the second run they throw this error.

    Is there a issue with how I am passing the instance?

    • nmrao's avatar
      nmrao
      Champion Level 3
      Just for your information.

      This is a community forum, please post question once and let some one answer, be little patient.
      • shrik18's avatar
        shrik18
        Occasional Contributor

        nmrao  I understand that. It was some issue where it gave me an error that the post was failed. I refreshed my profile a couple of times but there was nothing,  so I kept trying. And after a while there were three questions in my profile. As you can see from the time difference of the questions. I tried finding an option to delete the redundant ones, but its not there.