From 6ef5659a392cde390e1d03feeabaee451fe8c0b4 Mon Sep 17 00:00:00 2001 From: Andrei Piankouski Date: Tue, 17 Sep 2024 12:54:31 +0300 Subject: [PATCH 1/4] EPMRPP-95322 || Job 'CleanLaunchcron' doesn't clean the attachments for 'Regular' launches --- .../com/epam/reportportal/jobs/clean/CleanAttachmentJob.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java index a2f6fc7..80a0b0e 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java @@ -22,8 +22,8 @@ WITH moved_rows AS ( DELETE FROM attachment\s WHERE project_id = ?\s AND creation_date <= ?::TIMESTAMP\s - AND launch_id IN ( - SELECT id FROM launch WHERE retention_policy='REGULAR' + AND launch_id NOT IN ( + SELECT id FROM launch WHERE retention_policy='IMPORTANT' )\s RETURNING * ) From 3fb3aa00ffd0ab0c7a4aa5cb04471b971514f91f Mon Sep 17 00:00:00 2001 From: Andrei Piankouski Date: Wed, 18 Sep 2024 11:18:53 +0300 Subject: [PATCH 2/4] Add logs --- .../com/epam/reportportal/jobs/clean/CleanAttachmentJob.java | 1 + .../java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java | 1 + src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java | 1 + 3 files changed, 3 insertions(+) diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java index 80a0b0e..7a75dbd 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java @@ -43,6 +43,7 @@ public void execute() { } void moveAttachments() { + LOGGER.info("CleanAttachmentJob has been started!!!"); AtomicInteger counter = new AtomicInteger(0); getProjectsWithAttribute(KEEP_SCREENSHOTS).forEach((projectId, duration) -> { LocalDateTime lessThanDate = LocalDateTime.now(ZoneOffset.UTC).minus(duration); diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java index d519999..425d554 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java @@ -63,6 +63,7 @@ public void execute() { } private void removeLaunches() { + LOGGER.info("CleanLaunchJob has been started!!!"); AtomicInteger counter = new AtomicInteger(0); getProjectsWithAttribute(KEEP_LAUNCHES).forEach((projectId, duration) -> { final LocalDateTime lessThanDate = LocalDateTime.now(ZoneOffset.UTC).minus(duration); diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java index 55fa6c1..39d1f32 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java @@ -64,6 +64,7 @@ public void execute() { } void removeLogs() { + LOGGER.info("CleanLogJob has been started!!!"); AtomicInteger counter = new AtomicInteger(0); // TODO: Need to refactor Logs to keep real it's launchId and combine code with // CleanLaunch to avoid duplication From 4aeff45741b58ab0748568a26a8ea064c5a6e14e Mon Sep 17 00:00:00 2001 From: Andrei Piankouski Date: Wed, 18 Sep 2024 11:33:26 +0300 Subject: [PATCH 3/4] Call CleanAttachmentJob in CleanLogJob --- src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java index 39d1f32..80e6806 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java @@ -60,7 +60,6 @@ public CleanLogJob(JdbcTemplate jdbcTemplate, CleanAttachmentJob cleanAttachment @SchedulerLock(name = "cleanLog", lockAtMostFor = "24h") public void execute() { removeLogs(); - cleanAttachmentJob.moveAttachments(); } void removeLogs() { @@ -84,6 +83,7 @@ void removeLogs() { } } }); + cleanAttachmentJob.moveAttachments(); } private void deleteLogsFromSearchEngineByLaunchIdsAndProjectId(List launchIds, From dc5b96e1ddb4cc3bab6e2d3f3513e79fd00e352b Mon Sep 17 00:00:00 2001 From: Andrei Piankouski Date: Wed, 18 Sep 2024 11:44:33 +0300 Subject: [PATCH 4/4] Revert "Add logs" This reverts commit 3fb3aa00ffd0ab0c7a4aa5cb04471b971514f91f. --- .../com/epam/reportportal/jobs/clean/CleanAttachmentJob.java | 1 - .../java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java | 1 - src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java | 1 - 3 files changed, 3 deletions(-) diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java index 7a75dbd..80a0b0e 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanAttachmentJob.java @@ -43,7 +43,6 @@ public void execute() { } void moveAttachments() { - LOGGER.info("CleanAttachmentJob has been started!!!"); AtomicInteger counter = new AtomicInteger(0); getProjectsWithAttribute(KEEP_SCREENSHOTS).forEach((projectId, duration) -> { LocalDateTime lessThanDate = LocalDateTime.now(ZoneOffset.UTC).minus(duration); diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java index 425d554..d519999 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanLaunchJob.java @@ -63,7 +63,6 @@ public void execute() { } private void removeLaunches() { - LOGGER.info("CleanLaunchJob has been started!!!"); AtomicInteger counter = new AtomicInteger(0); getProjectsWithAttribute(KEEP_LAUNCHES).forEach((projectId, duration) -> { final LocalDateTime lessThanDate = LocalDateTime.now(ZoneOffset.UTC).minus(duration); diff --git a/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java b/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java index 80e6806..8d5da38 100644 --- a/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java +++ b/src/main/java/com/epam/reportportal/jobs/clean/CleanLogJob.java @@ -63,7 +63,6 @@ public void execute() { } void removeLogs() { - LOGGER.info("CleanLogJob has been started!!!"); AtomicInteger counter = new AtomicInteger(0); // TODO: Need to refactor Logs to keep real it's launchId and combine code with // CleanLaunch to avoid duplication