Skip to content

Commit

Permalink
chore: Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar committed Aug 7, 2023
1 parent e74b104 commit f3d78cc
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 16 deletions.
1 change: 1 addition & 0 deletions backend/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ task runStandardTests(type: Test, group: 'verification') {
useJUnitPlatform {
excludeTags "contextRecreating", "websocket"
}
maxHeapSize = "8000m"
}

task runWebsocketTests(type: Test, group: 'verification') {
Expand Down
12 changes: 6 additions & 6 deletions backend/app/src/test/resources/application.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ tolgee:
telemetry:
enabled: false
server: http://localhost:8080
#logging:
# level:
# io.tolgee.billing.api.v2.OrganizationInvoicesController: DEBUG
# io.tolgee.batch.BatchJobActionService: DEBUG
# io.tolgee.component.atomicLong.AtomicLongProvider: DEBUG
# io.tolgee.batch: TRACE
logging:
level:
io.tolgee.billing.api.v2.OrganizationInvoicesController: DEBUG
io.tolgee.batch.BatchJobActionService: DEBUG
io.tolgee.component.atomicLong.AtomicLongProvider: DEBUG
io.tolgee.batch: DEBUG
# org.springframework.orm.jpa: DEBUG
# org.springframework.transaction: DEBUG
# org.hibernate.type: TRACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.tolgee.batch
import io.sentry.Sentry
import io.tolgee.component.CurrentDateProvider
import io.tolgee.configuration.tolgee.BatchProperties
import io.tolgee.fixtures.waitFor
import io.tolgee.util.Logging
import io.tolgee.util.logger
import kotlinx.coroutines.CoroutineScope
Expand All @@ -28,7 +29,17 @@ class BatchJobConcurrentLauncher(
}

val runningJobs: ConcurrentHashMap<Long, Pair<Long, Job>> = ConcurrentHashMap()

var pause = false
set(value) {
field = value
if (value) {
waitFor(30000) {
runningJobs.size == 0
}
}
}

var masterRunJob: Job? = null
var run = true

Expand Down Expand Up @@ -106,12 +117,12 @@ class BatchJobConcurrentLauncher(
"Pulled ${items.size} items from queue: " +
items.joinToString(", ") { it.chunkExecutionId.toString() }
)
logger.debug(
"${batchJobChunkExecutionQueue.size} is left in the queue " +
"(${System.identityHashCode(batchJobChunkExecutionQueue)}): " +
batchJobChunkExecutionQueue.joinToString(", ") { it.chunkExecutionId.toString() }
)
}
logger.debug(
"${batchJobChunkExecutionQueue.size} is left in the queue " +
"(${System.identityHashCode(batchJobChunkExecutionQueue)}): " +
batchJobChunkExecutionQueue.joinToString(", ") { it.chunkExecutionId.toString() }
)
}

private fun CoroutineScope.handleItem(
Expand Down
10 changes: 6 additions & 4 deletions backend/testing/src/main/kotlin/io/tolgee/CleanDbTestListener.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.tolgee

import io.tolgee.batch.BatchJobChunkExecutionQueue
import io.tolgee.batch.BatchJobConcurrentLauncher
import kotlinx.coroutines.TimeoutCancellationException
import org.postgresql.util.PSQLException
Expand All @@ -25,14 +26,15 @@ class CleanDbTestListener : TestExecutionListener {

override fun beforeTestMethod(testContext: TestContext) {
val appContext: ApplicationContext = testContext.applicationContext
val jobChunkExecutionQueue = appContext.getBean(BatchJobConcurrentLauncher::class.java)
jobChunkExecutionQueue.pause = true
val batchJobConcurrentLauncher = appContext.getBean(BatchJobConcurrentLauncher::class.java)
val batchJobQueue = appContext.getBean(BatchJobChunkExecutionQueue::class.java)

if (!shouldClenBeforeClass(testContext)) {
batchJobConcurrentLauncher.pause = true
batchJobQueue.clear()
cleanWithRetries(testContext)
batchJobConcurrentLauncher.pause = false
}

jobChunkExecutionQueue.pause = false
}

private fun cleanWithRetries(testContext: TestContext) {
Expand Down
2 changes: 1 addition & 1 deletion e2e/cypress/e2e/organizations/organizationsList.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('Organization List', () => {
cy.contains('Organization created').should('be.visible');
});

it('validates creation fields', () => {
it('validates creation fields', { retries: { runMode: 3 } }, () => {
goToNewOrganizationForm();
gcy('organization-name-field').within(() => {
cy.get('input').type('aaa').clear();
Expand Down

0 comments on commit f3d78cc

Please sign in to comment.