Skip to content

Commit

Permalink
Merge pull request #1621 from mohanachandran-s/develop
Browse files Browse the repository at this point in the history
MOSIP-36012 - Reports will be stored in mount path if push reports to s3 is No
  • Loading branch information
lsivanand authored Sep 25, 2024
2 parents ad17a05 + 16a86fb commit 9788f9d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.text.NumberFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -55,6 +58,7 @@ public class EmailableReport implements IReporter {
private final StringBuilder buffer = new StringBuilder();

private String fileName = "emailable-report.html";
private String mountPathForReport = ConfigManager.getMountPathForReport();

private static final String JVM_ARG = GlobalConstants.EMAILABLEREPORT2NAME;

Expand Down Expand Up @@ -152,6 +156,14 @@ public void generateReport(List<XmlSuite> xmlSuites, List<ISuite> suites, String
} else {
LOG.info("Failed while pushing file to S3");
}
} else {
try {
Path mountFilePath = Path.of(mountPathForReport, newString);
Files.copy(newReportFile.toPath(), mountFilePath, StandardCopyOption.REPLACE_EXISTING);
LOG.info("Successfully copied report file to mount path: " + mountFilePath.toString());
} catch (Exception e) {
LOG.error("Error occurred while copying file to mount path: " + e.getLocalizedMessage());
}
}
} else {
LOG.error("Renamed report file doesn't exist");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ public class ConfigManager {
private static String AUTHCERTS_PATH = "authCertsPath";
private static String MOUNT_PATH_FOR_SCENARIO = "mountPathForScenario";
private static String MOCK_NOTIFICATION_CHANNEL = "mockNotificationChannel";
private static String MOUNT_PATH_FOR_REPORT = "mountPathForReport";

private static String SERVER_ERRORS_TO_MONITOR = "serverErrorsToMonitor";

Expand Down Expand Up @@ -253,6 +254,7 @@ public class ConfigManager {
private static String serverErrorsToMonitor;

private static String mountPath;
private static String mountPathForReport;
private static String authCertsPath;
private static String mockNotificationChannel;
private static String mountPathForScenario;
Expand Down Expand Up @@ -369,6 +371,12 @@ public static void init() {

mountPath = System.getenv(MOUNT_PATH) == null ? propsKernel.getProperty(MOUNT_PATH) : System.getenv(MOUNT_PATH);
propsKernel.setProperty(MOUNT_PATH, mountPath);

mountPathForReport = System.getenv(MOUNT_PATH_FOR_REPORT) == null
? propsKernel.getProperty(MOUNT_PATH_FOR_REPORT)
: System.getenv(MOUNT_PATH_FOR_REPORT);
propsKernel.setProperty(MOUNT_PATH_FOR_REPORT, mountPathForReport);


mockNotificationChannel = System.getenv(MOCK_NOTIFICATION_CHANNEL) == null
? propsKernel.getProperty(MOCK_NOTIFICATION_CHANNEL)
Expand Down Expand Up @@ -643,6 +651,10 @@ public static String getmountPath() {
return mountPath;
}

public static String getMountPathForReport() {
return mountPathForReport;
}

public static String getmountPathForScenario() {
return mountPathForScenario;
}
Expand Down

0 comments on commit 9788f9d

Please sign in to comment.