Skip to content

Commit

Permalink
Merge pull request #816 from PrabodDunuwila/prabod-testsuite
Browse files Browse the repository at this point in the history
Test framework healthy container check.
  • Loading branch information
pcnfernando authored Jan 6, 2020
2 parents 2763c6c + cbd70b6 commit 62d6627
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
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

0 comments on commit 62d6627

Please sign in to comment.