protected void doCheckJavaIsInstalledViaSsh(NodeMetadata node) throws IOException { SshClient ssh = context.utils().sshForNode().apply(node); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); assertEquals(hello.getOutput().trim(), "hello"); ExecResponse exec = ssh.exec("java -version"); assert exec.getError().indexOf("1.6") != -1 || exec.getOutput().indexOf("1.6") != -1 : exec + "\n" + ssh.exec("cat /tmp/bootstrap/stdout.log /tmp/bootstrap/stderr.log"); } finally { if (ssh != null) ssh.disconnect(); } }
protected void doCheckJavaIsInstalledViaSsh(NodeMetadata node) throws IOException { IPSocket socket = new IPSocket(Iterables.get(node.getPublicAddresses(), 0), 22); socketTester.apply(socket); // TODO add transitionTo option that accepts // a socket conection // state. SshClient ssh = sshFactory.create(socket, node.getCredentials().account, keyPair.get("private").getBytes()); try { ssh.connect(); ExecResponse hello = ssh.exec("echo hello"); assertEquals(hello.getOutput().trim(), "hello"); ExecResponse exec = ssh.exec("java -version"); assert exec.getError().indexOf("OpenJDK") != -1 : exec; } finally { if (ssh != null) ssh.disconnect(); } }