Skip to content

Commit

Permalink
make sure that we create delete events when deleting units
Browse files Browse the repository at this point in the history
verinice-veo#2854
  • Loading branch information
jochenkemnade committed Jul 22, 2024
1 parent 6240e12 commit 5811fa0
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ import org.veo.core.usecase.catalogitem.GetProfileIncarnationDescriptionUseCase
import org.veo.core.usecase.unit.DeleteUnitUseCase
import org.veo.core.usecase.unit.DeleteUnitUseCase.InputData
import org.veo.persistence.access.ClientRepositoryImpl
import org.veo.persistence.access.jpa.StoredEventDataRepository
import org.veo.persistence.metrics.DataSourceProxyBeanPostProcessor

import groovy.json.JsonSlurper
import net.ttddyy.dsproxy.QueryCountHolder

@WithUserDetails("[email protected]")
Expand All @@ -52,6 +54,9 @@ class DeleteUnitUseCaseITSpec extends AbstractPerformanceITSpec {
@Autowired
private DeleteUnitUseCase deleteUnitUseCase

@Autowired
private StoredEventDataRepository storedEventDataRepository

@DynamicPropertySource
static void setRowCount(DynamicPropertyRegistry registry) {
registry.add("veo.logging.datasource.row_count", { -> true })
Expand Down Expand Up @@ -87,6 +92,7 @@ class DeleteUnitUseCaseITSpec extends AbstractPerformanceITSpec {
queryCounts.time < 1000
// 115 is the currently observed count of 108 rows plus an acceptable safety margin
DataSourceProxyBeanPostProcessor.totalResultSetRowsRead - rowCountBefore <= 115
storedDeleteEvents.size() == 10
}
}

Expand Down Expand Up @@ -186,9 +192,14 @@ class DeleteUnitUseCaseITSpec extends AbstractPerformanceITSpec {
queryCounts.time < 6000
// 16500 is the currently observed count of 15824 rows plus an acceptable safety margin
DataSourceProxyBeanPostProcessor.totalResultSetRowsRead - rowCountBefore <= 16500
storedDeleteEvents.size() == 1100
}
}

def getStoredDeleteEvents() {
storedEventDataRepository.findAll().findAll{it.content != null && new JsonSlurper().parseText(it.content).type == 'HARD_DELETION'}
}

def runUseCase(Unit unit) {
executeInTransaction {
deleteUnitUseCase.execute(new InputData(unit.id, unit.client))
Expand Down

0 comments on commit 5811fa0

Please sign in to comment.