Access to a SSH object from other test unit

6 views
Skip to first unread message

Daniel Silva

unread,
Dec 18, 2017, 11:15:21 AM12/18/17
to Extensive Testing Users
Hi,


I have two test units, one for connect SSH and other for send commands. 


To connect I use the SSH.Terminal class, with doSession method. How I can access to the object with the session from the other test unit? I already tried some methods like connect and isOpened but no luck.



The idea is to avoid code duplication.


Thanks,
Daniel 

Daniel Silva

unread,
Dec 18, 2017, 11:44:38 AM12/18/17
to Extensive Testing Users
I put the object in cache but I cannot connect to an existing session

Denis MACHARD

unread,
Dec 18, 2017, 2:29:03 PM12/18/17
to Daniel Silva, Extensive Testing Users
You need to configure your ssh adapter with the shared mode activated and also with a name  in the test unit A

Inline image 1

In your test unit B, you can retrieve the adapter by the name

self.ADP_EXAMPLE = self.findAdapter(name="SSH_1")
if self.ADP_EXAMPLE is None: Test(self).interrupt("unable to find the adapter")


But for ssh testing, I recommended stronly to use the following approach https://documentations.extensivetesting.org/docs/generic_use/send_ssh

Denis

On Mon, Dec 18, 2017 at 5:44 PM, Daniel Silva <dani.s...@gmail.com> wrote:
I put the object in cache but I cannot connect to an existing session

--
If you like this project and you want to sponsor me then I am accepting donations :) via PayPal. The money received will be used to cover web site costs, domain name reservation and more;).
---
You received this message because you are subscribed to the Google Groups "Extensive Testing Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to extensive-testing-users+unsub...@googlegroups.com.
To post to this group, send email to extensive-testing-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/extensive-testing-users/f8e1b5c5-09cf-48ec-b7e1-465ef4f443e3%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Daniel Silva

unread,
Dec 19, 2017, 5:59:25 AM12/19/17
to Extensive Testing Users
Thank you,


Indeed is that what I need. I understand that is better to use snippets, but after I cannot interact with the terminal. I have 2 different test units: one for open SSH session works well, but after when I try to send commands to the terminal I have no interaction:

def prepare(self):
    # adapters and libraries definitions
    self.ADP_SSH = self.findAdapter(name="SSH_ADAPTER")
    if self.ADP_SSH is None: Test(self).interrupt("Unable to find the adapter")
    pass
   

def definition(self):
    if self.step1.isEnabled():
        self.step1.start()
        ##CAPTURE_SYS>
        #SYS_RET1 = self.ADP_SSH.connect()
        SYS_RET1 = self.ADP_SSH.doText(text=input('COMMAND'))
        if not SYS_RET1:
            self.abort("Unable to ")



The adapter is created on the Open SSH :

def prepare(self):
    # adapters and libraries definitions
    self.ADP_SYS = SutAdapters.SSH.Terminal(parent=self, name="SSH_ADAPTER", shared=True, destIp=input('SSH_HOST'),destPort=input('SSH_PORT'),login=input('SSH_USER'),password=input('SSH_PWD'),agent=agent('AGENT_SYSTEM'),debug=input('DEBUG'),agentSupport=input('SYS_AGT_SUPPORT') )

   

def definition(self):
    if self.step1.isEnabled():
        self.step1.start()
        Cache().set(name="session",data=self.ADP_SYS)
        ##CAPTURE_SYS>
        SYS_RET1 = self.ADP_SYS.doSession(timeout=input('TIMEOUT_SYS'))
        if not SYS_RET1:
            self.abort("Unable to connect to " + input('SSH_HOST') )

Daniel Silva

unread,
Dec 19, 2017, 7:05:46 AM12/19/17
to Extensive Testing Users
It works! The output it's only visible on the report in the first Test: Open SSH
Reply all
Reply to author
Forward
0 new messages