Skip to content

Commit

Permalink
Made it possible to keep CLI live for test runs
Browse files Browse the repository at this point in the history
to enable testing of loged users
to enabel testing of cli at all
  • Loading branch information
judovana committed Dec 17, 2024
1 parent 4ff58ed commit ea8918b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,10 @@ ClientResponse syncSshExec(String cmd, InputStream is) throws IOException, Inter

}



ClientResponse syncSshExec(String cmd, InputStream is) throws IOException, InterruptedException {
LOGGER.log(Level.INFO, "Executing: ssh -p {0} " + user + "@{1} {2}", new Object[]{port, host, cmd});
LOGGER.log(Level.INFO, toString(cmd));
try (SshClient client = SshClient.setUpDefaultClient()) {
client.start();
//todo enable remote, customize-able server from config
Expand Down Expand Up @@ -185,6 +187,14 @@ ClientResponse syncSshExec(String cmd, InputStream is) throws IOException, Inter
}
}

public String toString(String cmd) {
return "Executing: ssh -p " + port + " " + user + "@" + host + " " + cmd;
}

public String toString() {
return "Will be " + toString("future_cmd");
}

public ClientResponse help() {
String cmd = "help";
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.fakekoji.DataGenerator;
import org.fakekoji.jobmanager.JenkinsCliWrapper;
import org.fakekoji.xmlrpc.server.JavaServerConstants;
import org.junit.Assert;
import org.junit.Test;

Expand All @@ -16,11 +17,21 @@
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.logging.Logger;

public class OToolServiceRun {

private static final Logger LOGGER = Logger.getLogger(JavaServerConstants.FAKE_KOJI_LOGGER);

public static void main(String[] args) throws IOException {
JenkinsCliWrapper.killCli();
if ("keep".equals(System.getProperty("otool.test.cli"))) {
LOGGER.severe("otool.test.cli=keep, cli kept running. This is dangerous!");
LOGGER.severe(JenkinsCliWrapper.getCli().toString());
} else {
LOGGER.info("otool.test.cli!=keep, cli will be correctly repalced by no-op instance.");
JenkinsCliWrapper.killCli();
LOGGER.info("Done");
}
final File oTool = Files.createTempDirectory("oTool").toFile();
final DataGenerator.FolderHolder folderHolder = DataGenerator.initFolders(oTool);
if (System.getProperty("otool.testdb.dir") != null) {
Expand Down

0 comments on commit ea8918b

Please sign in to comment.