@Test public void runResource () throws IOException { Resource resource = mock(Resource.class); String finalPath = randomUUID().toString(); String command = String.format(SSHConstants.SCRIPT_NOHUP_WRAPPER, finalPath); doReturn(finalPath).when(kubernetesShellClient).copyResourceToPath(resource, "/tmp/"); doReturn(ShellOutput.EMPTY_SHELL_OUTPUT).when(kubernetesShellClient).runCommand(new String[]{ "sh", "-c", command }, false); kubernetesShellClient.runResource(resource); verify(kubernetesShellClient, times(1)).copyResourceToPath(resource, "/tmp/"); verify(kubernetesShellClient, times(1)).runCommand(new String[]{ "sh", "-c", command }, false); }
@Override public String runResource (Resource resource) { try { String innerCommand = String.format(SSHConstants.SCRIPT_NOHUP_WRAPPER, copyResourceToPath(resource)); return runCommand(new String[]{ "sh", "-c", innerCommand }, false).getStdOut(); } catch (IOException e) { throw new ChaosException(KubernetesChaosErrorCode.K8S_SHELL_CLIENT_ERROR, e); } }
KubernetesShellClient implements ShellClient { @Override public String runResource (Resource resource) { try { String innerCommand = String.format(SSHConstants.SCRIPT_NOHUP_WRAPPER, copyResourceToPath(resource)); return runCommand(new String[]{ "sh", "-c", innerCommand }, false).getStdOut(); } catch (IOException e) { throw new ChaosException(KubernetesChaosErrorCode.K8S_SHELL_CLIENT_ERROR, e); } } }
KubernetesShellClient implements ShellClient { @Override public String runResource (Resource resource) { try { String innerCommand = String.format(SSHConstants.SCRIPT_NOHUP_WRAPPER, copyResourceToPath(resource)); return runCommand(new String[]{ "sh", "-c", innerCommand }, false).getStdOut(); } catch (IOException e) { throw new ChaosException(KubernetesChaosErrorCode.K8S_SHELL_CLIENT_ERROR, e); } }  }
KubernetesShellClient implements ShellClient { @Override public String runResource (Resource resource) { try { String innerCommand = String.format(SSHConstants.SCRIPT_NOHUP_WRAPPER, copyResourceToPath(resource)); return runCommand(new String[]{ "sh", "-c", innerCommand }, false).getStdOut(); } catch (IOException e) { throw new ChaosException(KubernetesChaosErrorCode.K8S_SHELL_CLIENT_ERROR, e); } }  static KubernetesShellClientBuilder builder(); @Override String runResource(Resource resource); @Override ShellOutput runCommand(String command); @Override void close(); }
KubernetesShellClient implements ShellClient { @Override public String runResource (Resource resource) { try { String innerCommand = String.format(SSHConstants.SCRIPT_NOHUP_WRAPPER, copyResourceToPath(resource)); return runCommand(new String[]{ "sh", "-c", innerCommand }, false).getStdOut(); } catch (IOException e) { throw new ChaosException(KubernetesChaosErrorCode.K8S_SHELL_CLIENT_ERROR, e); } }  static KubernetesShellClientBuilder builder(); @Override String runResource(Resource resource); @Override ShellOutput runCommand(String command); @Override void close();  }