Skip to content

Commit

Permalink
perf: Update Spring & Faster Startup and time to test (#2457)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanCizmar authored Sep 10, 2024
1 parent 16d764c commit a8fb3ee
Show file tree
Hide file tree
Showing 83 changed files with 193 additions and 54 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/prerelease-alpha.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/reportIntermittentTests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down Expand Up @@ -146,7 +146,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down Expand Up @@ -232,7 +232,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Cache Gradle packages
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down Expand Up @@ -83,7 +83,7 @@ jobs:
- uses: actions/checkout@v3
- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down Expand Up @@ -122,7 +122,7 @@ jobs:
with:
timeout_minutes: 30
max_attempts: ${{ github.event_name == 'push' && 5 || 1 }}
command: ./gradlew ${{ matrix.command }} -x classes -x compileKotlin -x compileJava
command: ./gradlew ${{ matrix.command }}
env:
SKIP_SERVER_BUILD: true
CI_RELEASE: ${{ github.event_name == 'push' && true || false }}
Expand Down Expand Up @@ -163,7 +163,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down Expand Up @@ -269,7 +269,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Cache Gradle packages
Expand Down Expand Up @@ -420,7 +420,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 17
java-version: 21
distribution: adopt

- name: Setup node
Expand Down
2 changes: 1 addition & 1 deletion backend/api/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ repositories {
}

kotlin {
jvmToolchain(17)
jvmToolchain(21)
}

allOpen {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import io.tolgee.security.authentication.JwtService
import io.tolgee.security.authentication.TolgeeAuthentication
import io.tolgee.service.security.SecurityService
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Lazy
import org.springframework.messaging.Message
import org.springframework.messaging.MessageChannel
import org.springframework.messaging.MessagingException
Expand All @@ -21,7 +22,9 @@ import org.springframework.web.socket.config.annotation.WebSocketMessageBrokerCo
@Configuration
@EnableWebSocketMessageBroker
class WebSocketConfig(
@Lazy
private val jwtService: JwtService,
@Lazy
private val securityService: SecurityService,
) : WebSocketMessageBrokerConfigurer {
override fun configureMessageBroker(config: MessageBrokerRegistry) {
Expand Down
8 changes: 4 additions & 4 deletions backend/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ allOpen {
}

kotlin {
jvmToolchain(17)
jvmToolchain(21)
}

dependencies {
Expand Down Expand Up @@ -205,23 +205,23 @@ test {
setTestRetry(it)
}

task runContextRecreatingTests(type: Test, group: 'verification') {
tasks.register('runContextRecreatingTests', Test) {
useJUnitPlatform {
includeTags "contextRecreating"
}
maxHeapSize = "4096m"
setTestRetry(it)
}

task runStandardTests(type: Test, group: 'verification') {
tasks.register('runStandardTests', Test) {
useJUnitPlatform {
excludeTags "contextRecreating", "websocket"
}
maxHeapSize = "4096m"
setTestRetry(it)
}

task runWebsocketTests(type: Test, group: 'verification') {
tasks.register('runWebsocketTests', Test) {
useJUnitPlatform {
includeTags "websocket"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
import org.springframework.boot.web.servlet.FilterRegistrationBean
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.Lazy
import org.springframework.core.Ordered
import org.springframework.core.annotation.Order
import org.springframework.security.config.Customizer
Expand All @@ -46,12 +47,19 @@ import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
@Configuration
@EnableWebSecurity
class WebSecurityConfig(
@Lazy
private val authenticationFilter: AuthenticationFilter,
@Lazy
private val globalIpRateLimitFilter: GlobalIpRateLimitFilter,
@Lazy
private val globalUserRateLimitFilter: GlobalUserRateLimitFilter,
@Lazy
private val rateLimitInterceptor: RateLimitInterceptor,
@Lazy
private val authenticationInterceptor: AuthenticationInterceptor,
@Lazy
private val organizationAuthorizationInterceptor: OrganizationAuthorizationInterceptor,
@Lazy
private val projectAuthorizationInterceptor: ProjectAuthorizationInterceptor,
private val exceptionHandlerFilter: ExceptionHandlerFilter,
) : WebMvcConfigurer {
Expand Down
2 changes: 1 addition & 1 deletion backend/data/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ diff.dependsOn compileKotlin
diffChangelog.dependsOn compileKotlin

kotlin {
jvmToolchain(17)
jvmToolchain(21)
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,24 @@ import io.tolgee.util.addSeconds
import io.tolgee.util.logger
import io.tolgee.util.runSentryCatching
import jakarta.persistence.EntityManager
import org.springframework.context.annotation.Lazy
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional

@Component
class ScheduledJobCleaner(
@Lazy
private val batchJobService: BatchJobService,
@Lazy
private val lockingManager: BatchJobProjectLockingManager,
private val currentDateProvider: CurrentDateProvider,
@Lazy
private val batchJobStateProvider: BatchJobStateProvider,
private val entityManager: EntityManager,
@Lazy
private val cachingBatchJobService: CachingBatchJobService,
@Lazy
private val batchJobStatusProvider: BatchJobStatusProvider,
) : Logging {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package io.tolgee.configuration

import io.micrometer.core.instrument.MeterRegistry
import io.micrometer.prometheus.PrometheusConfig
import io.micrometer.prometheus.PrometheusMeterRegistry
import io.micrometer.prometheusmetrics.PrometheusConfig
import io.micrometer.prometheusmetrics.PrometheusMeterRegistry
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ImportFile(
@field:Size(max = 2000)
@Column(length = 2000)
var name: String?,
@ManyToOne(optional = false)
@field:ManyToOne(optional = false)
val import: Import,
) : StandardAuditModel() {
@OneToMany(mappedBy = "file", orphanRemoval = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ package io.tolgee.repository
import io.tolgee.model.DismissedAnnouncement
import io.tolgee.model.DismissedAnnouncementId
import io.tolgee.model.enums.announcement.Announcement
import org.springframework.context.annotation.Lazy
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository

@Repository
@Lazy
interface AnnouncementRepository : JpaRepository<DismissedAnnouncement, DismissedAnnouncementId> {
@Query(
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.tolgee.repository

import io.tolgee.model.ApiKey
import org.springframework.context.annotation.Lazy
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.EntityGraph
Expand All @@ -11,6 +12,7 @@ import org.springframework.stereotype.Repository
import java.util.*

@Repository
@Lazy
interface ApiKeyRepository : JpaRepository<ApiKey, Long> {
fun findByKeyHash(hash: String): Optional<ApiKey>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package io.tolgee.repository

import io.tolgee.model.AutoTranslationConfig
import io.tolgee.model.Project
import org.springframework.context.annotation.Lazy
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository

@Repository
@Lazy
interface AutoTranslationConfigRepository : JpaRepository<AutoTranslationConfig, Long> {
fun findOneByProjectAndTargetLanguageId(
project: Project,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package io.tolgee.repository

import io.tolgee.model.automations.Automation
import org.springframework.context.annotation.Lazy
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository

@Repository
@Lazy
interface AutomationRepository : JpaRepository<Automation?, Long?> {
@Query(
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package io.tolgee.repository
import io.tolgee.model.batch.BatchJob
import io.tolgee.model.batch.BatchJobStatus
import io.tolgee.model.views.JobErrorMessagesView
import org.springframework.context.annotation.Lazy
import org.springframework.data.domain.Page
import org.springframework.data.domain.Pageable
import org.springframework.data.jpa.repository.JpaRepository
Expand All @@ -11,6 +12,7 @@ import org.springframework.stereotype.Repository
import java.util.*

@Repository
@Lazy
interface BatchJobRepository : JpaRepository<BatchJob, Long> {
@Query(
value = """
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
package io.tolgee.repository

import io.tolgee.model.EmailVerification
import org.springframework.context.annotation.Lazy
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.stereotype.Repository

@Repository
@Lazy
interface EmailVerificationRepository : JpaRepository<EmailVerification, Long>
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ package io.tolgee.repository
import io.tolgee.model.Invitation
import io.tolgee.model.Organization
import io.tolgee.model.Project
import org.springframework.context.annotation.Lazy
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository
import java.util.*

@Repository
@Lazy
interface InvitationRepository : JpaRepository<Invitation?, Long?> {
fun deleteAllByCreatedAtLessThan(date: Date)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package io.tolgee.repository

import io.tolgee.model.key.KeyCodeReference
import org.springframework.context.annotation.Lazy
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional

@Repository
@Lazy
interface KeyCodeReferenceRepository : JpaRepository<KeyCodeReference, Long> {
@Modifying
@Transactional
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package io.tolgee.repository

import io.tolgee.model.key.KeyComment
import org.springframework.context.annotation.Lazy
import org.springframework.data.jpa.repository.JpaRepository
import org.springframework.data.jpa.repository.Modifying
import org.springframework.data.jpa.repository.Query
import org.springframework.stereotype.Repository
import org.springframework.transaction.annotation.Transactional

@Repository
@Lazy
interface KeyCommentRepository : JpaRepository<KeyComment?, Long?> {
@Modifying
@Transactional
Expand Down
Loading

0 comments on commit a8fb3ee

Please sign in to comment.