Package org.opennms.smoketest.utils
Class KarafShellUtils
- java.lang.Object
-
- org.opennms.smoketest.utils.KarafShellUtils
-
public class KarafShellUtils extends Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
KarafShellUtils.HealthCheckResult
-
Constructor Summary
Constructors Constructor Description KarafShellUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
awaitHealthCheckSucceeded(InetSocketAddress addr, int timeoutMinutes, String what)
Awaits that the health check succeeds within the given amount of minutes.static KarafShellUtils.HealthCheckResult
executeHealthCheck(InetSocketAddress sshAddr)
Calls the health check on a newly opened Karaf shell and waits for its completion.static boolean
isEndMessage(String s)
static boolean
isFailureMessage(String s)
static boolean
isSuccessMsg(String s)
static void
testHealthCheckSucceeded(InetSocketAddress sshAddr)
Checks if the health check succeeds.static <T> T
withKarafShell(InetSocketAddress sshAddr, java.time.Duration waitForShellTimeout, java.util.function.Function<SshClient.Streams,T> withStreams)
Calls a test function within the context of an open Karaf shell.
-
-
-
Method Detail
-
isSuccessMsg
public static boolean isSuccessMsg(String s)
-
isFailureMessage
public static boolean isFailureMessage(String s)
-
isEndMessage
public static boolean isEndMessage(String s)
-
awaitHealthCheckSucceeded
public static void awaitHealthCheckSucceeded(InetSocketAddress addr, int timeoutMinutes, String what)
Awaits that the health check succeeds within the given amount of minutes.- Throws:
RuntimeException
- if the health check does not succeed.
-
testHealthCheckSucceeded
public static void testHealthCheckSucceeded(InetSocketAddress sshAddr) throws Exception
Checks if the health check succeeds.- Throws:
Exception
- Throws if the health check could not be called, did not completed, or completed with a failure.
-
executeHealthCheck
public static KarafShellUtils.HealthCheckResult executeHealthCheck(InetSocketAddress sshAddr) throws Exception
Calls the health check on a newly opened Karaf shell and waits for its completion.- Throws:
Exception
- Throws if the health check command could not be called or did not complete within time.
-
withKarafShell
public static <T> T withKarafShell(InetSocketAddress sshAddr, java.time.Duration waitForShellTimeout, java.util.function.Function<SshClient.Streams,T> withStreams) throws Exception
Calls a test function within the context of an open Karaf shell. The test function is called only once, i.e. there are no retries.- Throws:
Exception
- If no shell could be opened or the the test function raised an exception. The thrown exception contains the content of stdout and stderr that was received so far. The thrown exception should either be propagated or logged in order to preserve this valuable debugging information.
-
-