However, when I rerun with SSH and run the same test manually from the ssh session it succeeds. How can I make the CI succeed?
Do the tests take longer than 10 minutes? If so, you need to either increase the output timeout or add some dummy output so that the task is not killed.
If your tests do not take longer than 10 minutes then it is possible that your test runner is not exiting properly.