1

I have tried Karate framework feature karate.fork to execute SSH/SCP commands but sysOut is not capturing output values to validate. It returns only exitCode (0: represent script executed successfully, non-zero : represents the script error code).

I am facing 2 issues right now. It would be great if you guide me for below listed issues:-

Operating System : Windows 10

Code snippet - ISSUE-1

* def command =
            """
                function(line) {
                var proc = karate.fork({redirectErrorStream: false, useShell: true, line: line });
                proc.waitSync();
                karate.set('sysOut', proc.sysOut);
                karate.set('sysErr', proc.sysErr);
                karate.set('exitCode', proc.exitCode);
              }
            """
       * command('ssh user@<remote-server> "cd /data && ls"')
       * match sysOut contains 'volume1'
       * assert exitCode == 0

Karate Debug Logs shows

22:17:29.915 [1606236446563] DEBUG com.intuit.karate - inputrun1
22:17:29.916 [1606236446563] DEBUG com.intuit.karate - outputrun1
22:17:29.924 [1606236446563] DEBUG com.intuit.karate - volume1
22:17:29.954 [ForkJoinPool-1-worker-3] INFO  com.intuit.karate - **sysOut undefined** 

Also, facing another issue - ISSUE-2

  * command('scp -r -i ~/.ssh/id_rsa user@<remote-server>:/data/volume1/ D:/karatetest/test/features/api/output')


20:07:59.947 [1606574279820-err]  DEBUG com.intuit.karate - 'scp' is not recognized as an internal or external command,
20:07:59.947 [1606574279820-err]  DEBUG com.intuit.karate - operable program or batch file.

The above SCP command is working fine in command prompt and in powershell window separately. But it throws 'scp' is not recognized as an internal or external command when I execute the same command in karate project inside VS code and when I ran karate command in VS code command prompt using java -Dkarate.config.dir=test/resources/ -cp test/karate.jar com.intuit.karate.Main test/features/api/test_bash_script.feature. I have verified the environment variables path and physical path has scp application (C:\Windows\System32\OpenSSH). Earlier this was working for me and suddenly it throws this exception. I am not sure this issue appearing because of I have uninstalled application and installed new app eclipse for java.

Thanks Chandra

1 Answers1

0

For the second question, my guess is your new Eclipse does not get the PATH correctly. Yes, this is tricky to troubleshoot and I don't have any other tips other than trying various combinations and using absolute paths if needed.

I don't understand the first question. It all works for me, e.g: fork.feature.

If needed, follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • The first issue I said, sysOut is not capturing output values for karate.fork to validate. It returns only exitCode (0: represent script executed successfully, non-zero : represents the script error code). But I see the logs in DEBUG com.intuit.karate terminal and sysOut returns undefined – Chandramohan Ramabadran Nov 30 '20 at 09:49
  • @ChandramohanRamabadran it works for me :) so it well may be a bug. an open source project relies on community feedback (and ideally code contribution) so I leave it to you as to how to proceed – Peter Thomas Nov 30 '20 at 09:56