From 69084612ddd9f074c5ef1b2b5e008d4a3f59bb11 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 17 Jul 2024 12:05:39 +0300 Subject: [PATCH] fix(sqlExecutionRepo): Return compressed columns when enabled for retrieve pipelines with configId (backport #4765) (#4766) * fix(sqlExecutionRepo): Return compressed columns when enabled for retrieve pipelines with configId (#4765) (cherry picked from commit ccaeb0ac9b50fd8f236f032189f20c8e7122b8fe) # Conflicts: # orca-sql/src/test/groovy/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlPipelineExecutionRepositorySpec.groovy * fix(backport): Fix tests on bad backport for search API breakage due to compression changes --------- Co-authored-by: Christos Arvanitis Co-authored-by: Jason --- .../persistence/SqlExecutionRepository.kt | 5 ++- .../SqlPipelineExecutionRepositorySpec.groovy | 39 ++++++++++++------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/orca-sql/src/main/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepository.kt b/orca-sql/src/main/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepository.kt index 33575f5d30..11af3e26a5 100644 --- a/orca-sql/src/main/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepository.kt +++ b/orca-sql/src/main/kotlin/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlExecutionRepository.kt @@ -665,7 +665,10 @@ class SqlExecutionRepository( .join( jooq.selectExecutions( PIPELINE, - listOf(field("id")), + fields = if (compressionProperties.enabled) + listOf(field("id")) + field("compressed_body") + field("compression_type") + else + listOf(field("id")), conditions = { var conditions = it.where( field("config_id").`in`(*pipelineConfigIds.toTypedArray()) diff --git a/orca-sql/src/test/groovy/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlPipelineExecutionRepositorySpec.groovy b/orca-sql/src/test/groovy/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlPipelineExecutionRepositorySpec.groovy index 56936c8d4d..5824a5b729 100644 --- a/orca-sql/src/test/groovy/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlPipelineExecutionRepositorySpec.groovy +++ b/orca-sql/src/test/groovy/com/netflix/spinnaker/orca/sql/pipeline/persistence/SqlPipelineExecutionRepositorySpec.groovy @@ -95,10 +95,10 @@ abstract class SqlPipelineExecutionRepositorySpec extends PipelineExecutionRepos return createExecutionRepository("test") } - ExecutionRepository createExecutionRepository(String partition, Interlink interlink = null) { + ExecutionRepository createExecutionRepository(String partition, Interlink interlink = null, boolean compression = false) { return InstrumentedProxy.proxy( new DefaultRegistry(), - new SqlExecutionRepository(partition, currentDatabase.context, mapper, new RetryProperties(), 10, 100, "poolName", interlink, [], new ExecutionCompressionProperties()), + new SqlExecutionRepository(partition, currentDatabase.context, mapper, new RetryProperties(), 10, 100, "poolName", interlink, [], new ExecutionCompressionProperties(enabled: compression)), "namespace") } @@ -583,15 +583,16 @@ abstract class SqlPipelineExecutionRepositorySpec extends PipelineExecutionRepos def "can retrieve pipelines by configIds between build time boundaries"() { given: + ExecutionRepository repo = createExecutionRepository("test", null, compressionEnabled) (storeLimit + 1).times { i -> - repository.store(pipeline { + repo.store(pipeline { application = "spinnaker" pipelineConfigId = "foo1" name = "Execution #${i + 1}" buildTime = i + 1 }) - repository.store(pipeline { + repo.store(pipeline { application = "spinnaker" pipelineConfigId = "foo2" name = "Execution #${i + 1}" @@ -600,7 +601,7 @@ abstract class SqlPipelineExecutionRepositorySpec extends PipelineExecutionRepos } when: - def results = repository + def results = repo .retrievePipelinesForPipelineConfigIdsBetweenBuildTimeBoundary( ["foo1", "foo2"], 0L, @@ -614,21 +615,23 @@ abstract class SqlPipelineExecutionRepositorySpec extends PipelineExecutionRepos } where: - storeLimit = 6 - retrieveLimit = 10 + storeLimit | retrieveLimit | compressionEnabled + 6 | 10 | false + 6 | 10 | true } def "can retrieve ALL pipelines by configIds between build time boundaries"() { given: + ExecutionRepository repo = createExecutionRepository("test", null, compressionEnabled) (storeLimit + 1).times { i -> - repository.store(pipeline { + repo.store(pipeline { application = "spinnaker" pipelineConfigId = "foo1" name = "Execution #${i + 1}" buildTime = i + 1 }) - repository.store(pipeline { + repo.store(pipeline { application = "spinnaker" pipelineConfigId = "foo2" name = "Execution #${i + 1}" @@ -637,14 +640,14 @@ abstract class SqlPipelineExecutionRepositorySpec extends PipelineExecutionRepos } when: - List forwardResults = repository + List forwardResults = repo .retrieveAllPipelinesForPipelineConfigIdsBetweenBuildTimeBoundary( ["foo1", "foo2"], 0L, 5L, new ExecutionCriteria().setPageSize(1).setSortType(BUILD_TIME_ASC) ) - List backwardsResults = repository + List backwardsResults = repo .retrieveAllPipelinesForPipelineConfigIdsBetweenBuildTimeBoundary( ["foo1", "foo2"], 0L, @@ -660,18 +663,28 @@ abstract class SqlPipelineExecutionRepositorySpec extends PipelineExecutionRepos where: - storeLimit = 6 + storeLimit | compressionEnabled + 6 | false + 6 | true } def "doesn't fail on empty configIds"() { + given: + ExecutionRepository repo = createExecutionRepository("test", null, compressionEnabled) + expect: - repository + repo .retrieveAllPipelinesForPipelineConfigIdsBetweenBuildTimeBoundary( [], 0L, 5L, new ExecutionCriteria().setPageSize(1).setSortType(BUILD_TIME_ASC) ).size() == 0 + + where: + compressionEnabled | _ + false | _ + true | _ } }