Skip to content

Commit 8108060

Browse files
fix deletion not working on great amount of scenarios
1 parent 772afa8 commit 8108060

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ api/kubernetes/cronjob/*.yaml
4949
### Personal directory ###
5050
perso
5151
config/application-dev*.properties
52-
config/application-dev*.yml
52+
config/application-*.yml
53+
!config/application-dev.sample.yml
5354
api/kubernetes/helm-chart/values-vcr.yaml
5455
/api/kubernetes/helm-chart/values-JREY*.yaml
5556

scenario/src/integrationTest/kotlin/com/cosmotech/scenario/service/ScenarioServiceIntegrationTest.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ class ScenarioServiceIntegrationTest : CsmRedisTestBase() {
240240
scenarioApiService.findAllScenarios(organizationSaved.id!!, workspaceSaved.id!!, null, null)
241241
assertTrue(scenarioListAfterDelete.size == 1)
242242

243+
// We create more scenario than there can be on one page of default size to assert
244+
// deleteAllScenarios still works with high quantities of scenarios
245+
repeat(csmPlatformProperties.twincache.scenario.defaultPageSize + 1) {
246+
scenarioApiService.createScenario(organizationSaved.id!!, workspaceSaved.id!!, makeScenario())
247+
}
248+
243249
logger.info("should delete all Scenarios and assert there is no Scenario left")
244250
scenarioApiService.deleteAllScenarios(organizationSaved.id!!, workspaceSaved.id!!)
245251
val scenarioListAfterDeleteAll =

scenario/src/main/kotlin/com/cosmotech/scenario/service/ScenarioServiceImpl.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ internal class ScenarioServiceImpl(
321321
// TODO Only the workspace owner should be able to do this
322322
val workspace = workspaceService.findWorkspaceById(organizationId, workspaceId)
323323
csmRbac.verify(workspace.getRbac(), PERMISSION_WRITE)
324-
var pageable = Pageable.ofSize(csmPlatformProperties.twincache.scenario.defaultPageSize)
324+
val pageable = Pageable.ofSize(csmPlatformProperties.twincache.scenario.defaultPageSize)
325325

326326
do {
327327
val scenarioList =
@@ -331,7 +331,6 @@ internal class ScenarioServiceImpl(
331331
scenarioRepository.delete(it)
332332
eventPublisher.publishEvent(ScenarioDeleted(this, organizationId, workspaceId, it.id!!))
333333
}
334-
pageable = pageable.next()
335334
} while (scenarioList.isNotEmpty())
336335
}
337336

0 commit comments

Comments
 (0)