File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
main/java/com/scalar/db/dataloader/core/dataimport/log
test/java/com/scalar/db/dataloader/core/dataimport/log Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -75,6 +75,10 @@ public void onTransactionBatchCompleted(ImportTransactionBatchResult batchResult
7575 if (shouldSkipLoggingSuccess (batchResult )) {
7676 return ;
7777 }
78+ // Skip logging records if log raw records is not enabled and execution is not success
79+ if (!batchResult .isSuccess () && !config .isLogRawSourceRecordsEnabled ()) {
80+ return ;
81+ }
7882
7983 logTransactionBatch (batchResult );
8084 notifyTransactionBatchCompleted (batchResult );
Original file line number Diff line number Diff line change 2525import org .junit .jupiter .api .BeforeEach ;
2626import org .junit .jupiter .api .Test ;
2727import org .junit .jupiter .api .io .TempDir ;
28+ import org .mockito .Mockito ;
2829import org .slf4j .Logger ;
2930import org .slf4j .LoggerFactory ;
3031
@@ -262,4 +263,28 @@ private void assertDataChunkStatusEquals(
262263 assertEquals (
263264 expected .getTotalDurationInMilliSeconds (), actual .getTotalDurationInMilliSeconds ());
264265 }
266+
267+ @ Test
268+ void onTransactionBatchCompleted_ShouldNotLogOrNotify_WhenRawLoggingIsSkipped ()
269+ throws IOException {
270+ // Arrange
271+ ImportLoggerConfig config =
272+ ImportLoggerConfig .builder ()
273+ .logDirectoryPath (tempDir .toString () + "/" )
274+ .isLogRawSourceRecordsEnabled (false )
275+ .isLogSuccessRecordsEnabled (true ) // success logging OFF
276+ .build ();
277+
278+ // Spy on logger to verify internal calls
279+ SingleFileImportLogger loggerSpy =
280+ Mockito .spy (new SingleFileImportLogger (config , logWriterFactory ));
281+
282+ ImportTransactionBatchResult batch = createBatchResults (1 , false ).get (0 ); // success batch
283+
284+ // Act
285+ loggerSpy .onTransactionBatchCompleted (batch );
286+
287+ // Assert
288+ Mockito .verify (loggerSpy , Mockito .never ()).logTransactionBatch (Mockito .any ());
289+ }
265290}
You can’t perform that action at this time.
0 commit comments