Forum Discussion
Hi,
Ofcourse the webservice response is being checked on Ready API window, but as one of pre-requisite of my test case I have to make property changes, restart services and then send a SOAP request. Basically this is a negative test to verify SOAP response when server is down.
Hi vivekanandan_m ,
The answer to your question is yes - you can log into a Linux machine and execute commands through ReadyApi.
Short answer
In order to execute a command you need to create a text file that contains the command. This file must be on the same machine as the ReadyApi application. You also need to have Putty on the same machine. Then you create a groovy script step and you can execute the command as:
'cmd /c D:\\applications\\putty\\putty.exe -ssh yourserver -l yourusername -pw yourpassword -m D:\\applications\\putty\\commands.txt'.execute()
Long answer
ReadyApi can execute cmd commands through groovy script. Luckily, putty can be ran from cmd. :)
Follow the following steps to be able to run commands from ReadyApi in Linux machines:
1. Copy Putty on the same machine as ReadyApi.
2. Again, on the same machine as ReadyApi create text files containing your commands. Normally you can put multiple commands in the same ile when working with Linux but I can't guarantee that. You will need to try it yourself.
3. Open your ReadyApi project and add a step of type Groovy script. The synthax for executing a cmd command is:
'cmd /c DUMMYCOMMAND'.execute()
4. The command for running putty is:
putty.exe -ssh hostname -l yourusername -pw yourpassword -m fileFromWhichToExecuteCommands
5. From points 3 and 5 we get then:
'cmd /c putty.exe -ssh hostname -l yourusername -pw yourpassword -m fileFromWhichToExecuteCommands'.execute()
6. Please note that when using putty.exe you also need to specify the path to it. So this would look like
'cmd /c D:\\applications\\putty\\putty.exe...
The same goes for the file containing your commands.
7. If you don't want to worry about point 6, you can always add putty to your Windows path.
Considerents
1. If you commit this project in git like this, you will also commit the username and password there, which is a bad practice.
2. Changing properties and restarting servers will increase your test duration. On the long run, it might be useful to find other solutions for this. (like putting property changes in the unit tests instead)
- nmrao6 years agoChampion Level 3Alternative to passwords is to use the private key to connect.
Related Content
- 6 years ago
- 9 years ago
- 10 years ago
Recent Discussions
- 6 days ago
- 10 days ago