Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test framework healthy container check. #816

Merged
merged 15 commits into from
Jan 6, 2020
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public class SiddhiRunnerContainer extends GenericContainer<SiddhiRunnerContaine
private static final String OVERRIDE_CONF_SYSTEM_PARAMETER = "-Dconfig";
private static final String DEPLOY_APP_SYSTEM_PARAMETER = "-Dapps";
private static final String BLANK_SPACE = " ";
private File localDeploymentPath = null;
private List<Integer> portsToExpose = new ArrayList<>(defaultExposePorts);
private String initScriptPath = "/home/siddhi_user/init.sh";
private StringBuilder initCommand = new StringBuilder(initScriptPath);
Expand Down Expand Up @@ -137,10 +138,10 @@ public SiddhiRunnerContainer withConfig(String confPath) {
* @return self
*/
public SiddhiRunnerContainer withSiddhiApps(String deploymentDirectory) {
File siddhiApps = new File(deploymentDirectory);
localDeploymentPath = new File(deploymentDirectory);
String deploymentPath = DEPLOYMENT_DIRECTORY;
if (!siddhiApps.isDirectory()) {
deploymentPath = DEPLOYMENT_DIRECTORY.concat(File.pathSeparator).concat(siddhiApps.getName());
if (!localDeploymentPath.isDirectory()) {
deploymentPath = DEPLOYMENT_DIRECTORY.concat(File.pathSeparator).concat(localDeploymentPath.getName());
}
withFileSystemBind(deploymentDirectory, deploymentPath, BindMode.READ_ONLY);
initCommand.append(BLANK_SPACE).append(DEPLOY_APP_SYSTEM_PARAMETER).append("=").append(DEPLOYMENT_DIRECTORY);
Expand Down Expand Up @@ -187,7 +188,7 @@ private void mountJarFile(String jarPath, boolean isBundle) {
}
}

private void mountFile (String sourcePath, String outputPath) {
private void mountFile(String sourcePath, String outputPath) {
int mountMode = 444;
MountableFile mountableFile = MountableFile.forHostPath(sourcePath,
mountMode);
Expand Down Expand Up @@ -215,7 +216,20 @@ protected void waitUntilContainerStarted() {
}
HTTPClient.HTTPResponseMessage httpResponseMessage = callHealthAPI();
if (httpResponseMessage.getResponseCode() == 200) {
logger().info("Siddhi Runner Health API reached successfully.");
logger().debug("Siddhi Runner Health API reached successfully.");
if (localDeploymentPath != null) {
String[] siddhiAppsArray = localDeploymentPath.list();
if (siddhiAppsArray != null) {
String logs = this.getLogs();
for (String siddhiApp : siddhiAppsArray) {
String fileName = siddhiApp.substring(0, siddhiApp.length() - ".siddhi".length());
if (!logs.contains("Siddhi App " + fileName + " deployed successfully")) {
throw new Exception("Siddhi App " + fileName + " deployment failed.");
}
}
logger().info("All Siddhi Apps deployed successfully.");
}
}
return null;
} else {
throw new ConnectException("Failed to connect with the Siddhi Runner health API");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class TemperatureAlertAppTest {
private NatsClient natsClient;
private WaitingConsumer siddhiLogConsumer = new WaitingConsumer();

private static final String DATABSE_NAME = "TemperaureDB";
private static final String DATABSE_NAME = "TemperatureDB";
private static final String DATABSE_HOST = "mysqldb";
private static final String NATS_CLUSTER_ID = "TemperatureCluster";
private static final String NATS_CLUSTER_HOST = "nats-streaming";
Expand Down