From 0a5e5feefe7992bf489c507ff45426554b502ff0 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 16 Oct 2023 14:10:30 +0200 Subject: [PATCH 01/69] upgraded micronaut to 4 --- build.gradle | 70 ++++++++++--------- ...qera.wave.groovy-common-conventions.gradle | 4 +- ...eqera.wave.java-library-conventions.gradle | 4 +- gradle.properties | 2 +- settings.gradle | 2 +- .../wave/controller/PairingController.groovy | 5 +- .../wave/controller/ValidateController.groovy | 3 +- .../ValidateRegistryCredsRequest.groovy | 4 +- .../wave/exchange/PairingRequest.groovy | 5 +- .../io/seqera/wave/proxy/ErrResponse.groovy | 6 +- .../impl/SpillWayStorageFactory.groovy | 4 +- .../ratelimit/impl/SpillwayRateLimiter.groovy | 4 +- .../groovy/io/seqera/wave/tower/User.groovy | 6 +- 13 files changed, 56 insertions(+), 63 deletions(-) diff --git a/build.gradle b/build.gradle index 32c084470..ac212001a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,9 +4,9 @@ import java.time.format.DateTimeFormatter plugins { id 'java-library' id 'io.seqera.wave.groovy-application-conventions' - id "com.github.johnrengelman.shadow" version "7.1.1" - id "io.micronaut.minimal.application" version "3.7.0" - id "com.google.cloud.tools.jib" version "3.4.0" + id 'com.github.johnrengelman.shadow' version '8.1.1' + id 'io.micronaut.minimal.application' version '4.1.0' + id 'com.google.cloud.tools.jib' version '3.4.0' id 'org.asciidoctor.jvm.convert' version '3.3.2' } @@ -28,68 +28,70 @@ repositories { } dependencies { - annotationProcessor("io.micronaut:micronaut-http-validation") - compileOnly("io.micronaut.data:micronaut-data-processor") - compileOnly("io.micronaut:micronaut-inject-groovy") - compileOnly("io.micronaut:micronaut-http-validation") - implementation("jakarta.persistence:jakarta.persistence-api:3.0.0") + annotationProcessor 'io.micronaut.validation:micronaut-validation-processor' + annotationProcessor 'io.micronaut:micronaut-http-validation' + compileOnly 'io.micronaut.data:micronaut-data-processor' + compileOnly 'io.micronaut:micronaut-inject-groovy' + compileOnly 'io.micronaut:micronaut-http-validation' + api 'io.seqera:lib-mail:1.0.0' api 'io.seqera:wave-api:0.5.0' api 'io.seqera:wave-utils:0.7.4' - implementation("io.micronaut:micronaut-http-client") - implementation("io.micronaut:micronaut-jackson-databind") - implementation("io.micronaut.groovy:micronaut-runtime-groovy") - implementation("jakarta.annotation:jakarta.annotation-api") - implementation("io.micronaut:micronaut-validation") - implementation "org.codehaus.groovy:groovy-json" - implementation "org.codehaus.groovy:groovy-nio" + implementation 'io.micronaut:micronaut-http-client' + implementation 'io.micronaut:micronaut-jackson-databind' + implementation 'io.micronaut.groovy:micronaut-runtime-groovy' + implementation 'jakarta.annotation:jakarta.annotation-api' + implementation 'io.micronaut.validation:micronaut-validation' + implementation 'org.apache.groovy:groovy-json' + implementation 'org.apache.groovy:groovy-nio' implementation 'com.google.guava:guava:32.1.2-jre' implementation 'dev.failsafe:failsafe:3.1.0' - implementation('io.projectreactor:reactor-core') - implementation("io.seqera:tower-crypto:22.4.0-watson") { transitive = false } // to be replaced with 22.4.0 once released + implementation 'io.projectreactor:reactor-core' + implementation ('io.seqera:tower-crypto:22.4.0-watson') { transitive = false } // to be replaced with 22.4.0 once released implementation 'org.apache.commons:commons-compress:1.24.0' implementation 'org.apache.commons:commons-lang3:3.12.0' implementation 'io.kubernetes:client-java:18.0.1' implementation 'io.kubernetes:client-java-api-fluent:18.0.1' implementation 'com.google.code.gson:gson:2.9.0' - implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" + implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' implementation 'com.squareup.moshi:moshi:1.14.0' implementation 'com.squareup.moshi:moshi-adapters:1.14.0' implementation 'redis.clients:jedis:4.4.3' - implementation "io.github.resilience4j:resilience4j-ratelimiter:0.17.0" + implementation 'io.github.resilience4j:resilience4j-ratelimiter:0.17.0' + implementation 'io.micronaut:micronaut-retry' // caching deps - implementation("io.micronaut.cache:micronaut-cache-core") - implementation("io.micronaut.cache:micronaut-cache-caffeine") - implementation("io.micronaut.aws:micronaut-aws-parameter-store") - implementation "software.amazon.awssdk:ecr" - implementation "software.amazon.awssdk:ecrpublic" + implementation 'io.micronaut.cache:micronaut-cache-core' + implementation 'io.micronaut.cache:micronaut-cache-caffeine' + implementation 'io.micronaut.aws:micronaut-aws-parameter-store' + implementation 'software.amazon.awssdk:ecr' + implementation 'software.amazon.awssdk:ecrpublic' implementation 'com.amazonaws:aws-java-sdk-ses:1.12.42' implementation 'org.yaml:snakeyaml:2.0' //object storage dependency - implementation("io.micronaut.objectstorage:micronaut-object-storage-aws") + implementation 'io.micronaut.objectstorage:micronaut-object-storage-aws' // this sts dependency is require by micronaut-aws-parameter-store, // not directly used by the app, for this reason keeping `runtimeOnly` - runtimeOnly "software.amazon.awssdk:sts" + runtimeOnly 'software.amazon.awssdk:sts' - runtimeOnly("io.netty:netty-tcnative-boringssl-static:2.0.0.Final") - runtimeOnly("javax.xml.bind:jaxb-api:2.3.1") - testImplementation("org.testcontainers:testcontainers") - testImplementation("org.testcontainers:mysql:1.17.3") + runtimeOnly 'io.netty:netty-tcnative-boringssl-static:2.0.0.Final' + runtimeOnly 'javax.xml.bind:jaxb-api:2.3.1' + testImplementation 'org.testcontainers:testcontainers' + testImplementation 'org.testcontainers:mysql:1.17.3' // -- - implementation("ch.qos.logback:logback-classic:1.4.8") + implementation 'ch.qos.logback:logback-classic:1.4.8' // rate limit implementation 'com.github.seqeralabs:spillway:7b72700293' // monitoring - implementation "io.micronaut.micrometer:micronaut-micrometer-registry-prometheus" + implementation 'io.micronaut.micrometer:micronaut-micrometer-registry-prometheus' // Also required to enable endpoint - implementation "io.micronaut:micronaut-management" + implementation 'io.micronaut:micronaut-management' //views - implementation("io.micronaut.views:micronaut-views-handlebars") + implementation 'io.micronaut.views:micronaut-views-handlebars' } application { diff --git a/buildSrc/src/main/groovy/io.seqera.wave.groovy-common-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.groovy-common-conventions.gradle index da3059f91..95ef3896f 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.groovy-common-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.groovy-common-conventions.gradle @@ -23,8 +23,8 @@ compileJava { } tasks.withType(GroovyCompile) { - sourceCompatibility = '11' - targetCompatibility = '11' + sourceCompatibility = '17' + targetCompatibility = '17' } group = 'io.seqera' diff --git a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle index f6197b641..7dcafaa42 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle @@ -25,8 +25,8 @@ compileJava { } tasks.withType(GroovyCompile) { - sourceCompatibility = '11' - targetCompatibility = '11' + sourceCompatibility = '17' + targetCompatibility = '17' } test { diff --git a/gradle.properties b/gradle.properties index 86290bb28..55e82ffdc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,5 +16,5 @@ # along with this program. If not, see . # -micronautVersion=3.10.1 +micronautVersion=4.1.4 micronautEnvs=dev,h2,mail,aws-ses diff --git a/settings.gradle b/settings.gradle index 395412606..b3a8e3e24 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,4 @@ rootProject.name="wave" // only for development // clone https://github.com/seqeralabs/libseqera // in a sibling directory and include the build below -//includeBuild('../libseqera') +includeBuild('../libseqera') diff --git a/src/main/groovy/io/seqera/wave/controller/PairingController.groovy b/src/main/groovy/io/seqera/wave/controller/PairingController.groovy index 9f28d939c..f6cad02f2 100644 --- a/src/main/groovy/io/seqera/wave/controller/PairingController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/PairingController.groovy @@ -18,9 +18,6 @@ package io.seqera.wave.controller -import javax.validation.ConstraintViolationException -import javax.validation.Valid - import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import io.micronaut.core.convert.exceptions.ConversionErrorException @@ -38,6 +35,8 @@ import io.seqera.wave.service.pairing.PairingService import io.seqera.wave.service.validation.ValidationService import io.seqera.wave.tower.client.TowerClient import jakarta.inject.Inject +import jakarta.validation.ConstraintViolationException +import jakarta.validation.Valid import static io.seqera.wave.WaveDefault.TOWER /** * Allow a remote Tower instance to register itself diff --git a/src/main/groovy/io/seqera/wave/controller/ValidateController.groovy b/src/main/groovy/io/seqera/wave/controller/ValidateController.groovy index 1ea6c3321..c700ed7f3 100644 --- a/src/main/groovy/io/seqera/wave/controller/ValidateController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/ValidateController.groovy @@ -18,12 +18,11 @@ package io.seqera.wave.controller -import javax.validation.Valid - import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Post import io.seqera.wave.auth.RegistryAuthService import jakarta.inject.Inject +import jakarta.validation.Valid import reactor.core.publisher.Mono @Controller("/validate-creds") diff --git a/src/main/groovy/io/seqera/wave/controller/ValidateRegistryCredsRequest.groovy b/src/main/groovy/io/seqera/wave/controller/ValidateRegistryCredsRequest.groovy index dce588f4c..511c62446 100644 --- a/src/main/groovy/io/seqera/wave/controller/ValidateRegistryCredsRequest.groovy +++ b/src/main/groovy/io/seqera/wave/controller/ValidateRegistryCredsRequest.groovy @@ -18,10 +18,8 @@ package io.seqera.wave.controller -import io.micronaut.core.annotation.Nullable -import javax.validation.constraints.NotBlank - import io.micronaut.core.annotation.Introspected +import jakarta.validation.constraints.NotBlank @Introspected class ValidateRegistryCredsRequest { diff --git a/src/main/groovy/io/seqera/wave/exchange/PairingRequest.groovy b/src/main/groovy/io/seqera/wave/exchange/PairingRequest.groovy index a93e88512..beafab0df 100644 --- a/src/main/groovy/io/seqera/wave/exchange/PairingRequest.groovy +++ b/src/main/groovy/io/seqera/wave/exchange/PairingRequest.groovy @@ -18,11 +18,10 @@ package io.seqera.wave.exchange -import javax.validation.constraints.NotBlank -import javax.validation.constraints.NotNull - import groovy.transform.CompileStatic import io.micronaut.core.annotation.Introspected +import jakarta.validation.constraints.NotBlank +import jakarta.validation.constraints.NotNull /** * Model the request for a remote service instance to register diff --git a/src/main/groovy/io/seqera/wave/proxy/ErrResponse.groovy b/src/main/groovy/io/seqera/wave/proxy/ErrResponse.groovy index 6bb5a53c0..615657796 100644 --- a/src/main/groovy/io/seqera/wave/proxy/ErrResponse.groovy +++ b/src/main/groovy/io/seqera/wave/proxy/ErrResponse.groovy @@ -90,17 +90,17 @@ class ErrResponse implements HttpResponse { } static ErrResponse forString(String msg, HttpRequest request) { - final head = HttpHeaders.of('Content-Type': ['text/plain'], {true}) + final head = HttpHeaders.of('Content-Type': ['text/plain'], (a, b) -> true) new ErrResponse(statusCode: 400, body: msg, request: request, uri: request.uri(), headers: head) } static ErrResponse forStream(String msg, HttpRequest request) { - final head = HttpHeaders.of('Content-Type': ['text/plain'], {true}) + final head = HttpHeaders.of('Content-Type': ['text/plain'], (a, b) -> true) new ErrResponse(statusCode: 400, body: new ByteArrayInputStream(msg.bytes), request: request, uri: request.uri(), headers: head) } static ErrResponse forByteArray(String msg, HttpRequest request) { - final head = HttpHeaders.of('Content-Type': ['text/plain'], {true}) + final head = HttpHeaders.of('Content-Type': ['text/plain'], (a, b) -> true) new ErrResponse(statusCode: 400, body: msg.bytes, request: request, uri: request.uri(), headers: head) } } diff --git a/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillWayStorageFactory.groovy b/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillWayStorageFactory.groovy index 56ebc177c..621b1612e 100644 --- a/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillWayStorageFactory.groovy +++ b/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillWayStorageFactory.groovy @@ -18,8 +18,6 @@ package io.seqera.wave.ratelimit.impl -import javax.validation.constraints.NotNull - import com.coveo.spillway.storage.InMemoryStorage import com.coveo.spillway.storage.LimitUsageStorage import com.coveo.spillway.storage.RedisStorage @@ -27,9 +25,9 @@ import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import io.micronaut.context.annotation.Factory import io.micronaut.context.annotation.Requires -import io.seqera.wave.configuration.RateLimiterConfig import io.seqera.wave.configuration.RedisConfig import jakarta.inject.Singleton +import jakarta.validation.constraints.NotNull import redis.clients.jedis.JedisPool /** diff --git a/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy b/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy index 7e54d0d6b..0eba86975 100644 --- a/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy +++ b/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy @@ -18,9 +18,6 @@ package io.seqera.wave.ratelimit.impl - -import javax.validation.constraints.NotNull - import com.coveo.spillway.Spillway import com.coveo.spillway.SpillwayFactory import com.coveo.spillway.limit.Limit @@ -36,6 +33,7 @@ import io.seqera.wave.ratelimit.AcquireRequest import io.seqera.wave.ratelimit.RateLimiterService import jakarta.inject.Singleton +import jakarta.validation.constraints.NotNull /** * This class manage how many requests can be requested from an user during a configurable period diff --git a/src/main/groovy/io/seqera/wave/tower/User.groovy b/src/main/groovy/io/seqera/wave/tower/User.groovy index 4821b4cd6..a7c9b9a55 100644 --- a/src/main/groovy/io/seqera/wave/tower/User.groovy +++ b/src/main/groovy/io/seqera/wave/tower/User.groovy @@ -18,12 +18,12 @@ package io.seqera.wave.tower -import javax.validation.constraints.NotNull -import javax.validation.constraints.Size - import groovy.transform.CompileStatic import groovy.transform.EqualsAndHashCode import groovy.transform.ToString +import jakarta.validation.constraints.NotNull +import jakarta.validation.constraints.Size + /** * Model a tower user * From 4762bcb6c6503dea362e89d97b77b36914eaee18 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 17 Oct 2023 09:30:33 +0200 Subject: [PATCH 02/69] minor change --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index b3a8e3e24..395412606 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,4 @@ rootProject.name="wave" // only for development // clone https://github.com/seqeralabs/libseqera // in a sibling directory and include the build below -includeBuild('../libseqera') +//includeBuild('../libseqera') From 4c1dc4f58badd199c3b0e3470e83cc7bacdcbdb0 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 17 Oct 2023 10:29:37 +0200 Subject: [PATCH 03/69] JUnitPlatform added --- build.gradle | 4 ++++ settings.gradle | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index ac212001a..cea170f95 100644 --- a/build.gradle +++ b/build.gradle @@ -38,6 +38,7 @@ dependencies { api 'io.seqera:wave-api:0.5.0' api 'io.seqera:wave-utils:0.7.4' + implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0' implementation 'io.micronaut:micronaut-http-client' implementation 'io.micronaut:micronaut-jackson-databind' implementation 'io.micronaut.groovy:micronaut-runtime-groovy' @@ -107,6 +108,9 @@ micronaut { } } +test { + useJUnitPlatform() +} // // Build container image with JIB diff --git a/settings.gradle b/settings.gradle index 395412606..b3a8e3e24 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,4 @@ rootProject.name="wave" // only for development // clone https://github.com/seqeralabs/libseqera // in a sibling directory and include the build below -//includeBuild('../libseqera') +includeBuild('../libseqera') From 04d974c580968cfcddc146f8c492f6519630d038 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 17 Oct 2023 10:32:54 +0200 Subject: [PATCH 04/69] minor change --- settings.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle b/settings.gradle index b3a8e3e24..395412606 100644 --- a/settings.gradle +++ b/settings.gradle @@ -3,4 +3,4 @@ rootProject.name="wave" // only for development // clone https://github.com/seqeralabs/libseqera // in a sibling directory and include the build below -includeBuild('../libseqera') +//includeBuild('../libseqera') From 0ee7d232726112fa79c0455bbf6afd9365b11481 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 18 Oct 2023 13:40:04 +0200 Subject: [PATCH 05/69] Error fixed --- src/main/groovy/io/seqera/wave/auth/RegistryConfig.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/io/seqera/wave/auth/RegistryConfig.groovy b/src/main/groovy/io/seqera/wave/auth/RegistryConfig.groovy index 54a75f173..bd6b7c4ec 100644 --- a/src/main/groovy/io/seqera/wave/auth/RegistryConfig.groovy +++ b/src/main/groovy/io/seqera/wave/auth/RegistryConfig.groovy @@ -45,7 +45,7 @@ class RegistryConfig { * io: [ ... ] * ] */ - private Map registries + Map registries RegistryKeys getRegistryKeys(String registryName) { final String defaultRegistry = registries.get('default')?.toString() ?: 'docker.io' From 6c775cdcd81be86573482c75e2a13b1912bb99da Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Thu, 19 Oct 2023 10:55:49 +0200 Subject: [PATCH 06/69] updated to groovy 4 --- .../io.seqera.wave.java-library-conventions.gradle | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle index 7dcafaa42..fff193d30 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle @@ -44,13 +44,12 @@ dependencies { testImplementation 'ch.qos.logback:logback-core:1.2.11' testImplementation 'ch.qos.logback:logback-classic:1.2.11' - testImplementation "org.codehaus.groovy:groovy:3.0.15" - testImplementation "org.codehaus.groovy:groovy-nio:3.0.15" - testImplementation ("org.codehaus.groovy:groovy-test:3.0.17") - testImplementation ("cglib:cglib-nodep:3.3.0") - testImplementation ("org.objenesis:objenesis:3.2") - testImplementation ("org.spockframework:spock-core:2.3-groovy-3.0") { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } - testImplementation ('org.spockframework:spock-junit4:2.3-groovy-3.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } + testImplementation 'org.apache.groovy:groovy:4.0.15' + testImplementation 'org.apache.groovy:groovy-nio:4.0.15' + testImplementation 'org.apache.groovy:groovy-test:4.0.15' + testImplementation 'org.objenesis:objenesis:3.2' + testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' + testImplementation 'org.spockframework:spock-junit4:2.3-groovy-4.0' } tasks.withType(Test) { From 675b74b4f7b5242d3d3c1535775dcd23aca4601f Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Thu, 19 Oct 2023 11:03:09 +0200 Subject: [PATCH 07/69] removed useJUnitPlatform() --- build.gradle | 4 ---- 1 file changed, 4 deletions(-) diff --git a/build.gradle b/build.gradle index cea170f95..29e8d4c11 100644 --- a/build.gradle +++ b/build.gradle @@ -108,10 +108,6 @@ micronaut { } } -test { - useJUnitPlatform() -} - // // Build container image with JIB // https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin From 1c8ff4dafdc7443bcca9c4793d7f7e857839ceda Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Fri, 3 Nov 2023 08:56:06 +0100 Subject: [PATCH 08/69] updated more dependencies --- build.gradle | 12 +++++++----- .../io.seqera.wave.java-library-conventions.gradle | 13 +++++++------ gradle/wrapper/gradle-wrapper.properties | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 29e8d4c11..feaab6c16 100644 --- a/build.gradle +++ b/build.gradle @@ -4,10 +4,10 @@ import java.time.format.DateTimeFormatter plugins { id 'java-library' id 'io.seqera.wave.groovy-application-conventions' - id 'com.github.johnrengelman.shadow' version '8.1.1' - id 'io.micronaut.minimal.application' version '4.1.0' - id 'com.google.cloud.tools.jib' version '3.4.0' - id 'org.asciidoctor.jvm.convert' version '3.3.2' + id "com.github.johnrengelman.shadow" version "8.1.1" + id "io.micronaut.minimal.application" version "4.1.0" + id "com.google.cloud.tools.jib" version "3.4.0" + id "org.asciidoctor.jvm.convert" version "3.3.2" } String gitVersion() { @@ -48,7 +48,7 @@ dependencies { implementation 'org.apache.groovy:groovy-nio' implementation 'com.google.guava:guava:32.1.2-jre' implementation 'dev.failsafe:failsafe:3.1.0' - implementation 'io.projectreactor:reactor-core' + implementation 'io.micronaut.reactor:micronaut-reactor' implementation ('io.seqera:tower-crypto:22.4.0-watson') { transitive = false } // to be replaced with 22.4.0 once released implementation 'org.apache.commons:commons-compress:1.24.0' implementation 'org.apache.commons:commons-lang3:3.12.0' @@ -78,6 +78,8 @@ dependencies { runtimeOnly 'io.netty:netty-tcnative-boringssl-static:2.0.0.Final' runtimeOnly 'javax.xml.bind:jaxb-api:2.3.1' + runtimeOnly 'org.yaml:snakeyaml' + runtimeOnly 'io.micronaut.testresources:micronaut-test-resources-client:2.1.0' testImplementation 'org.testcontainers:testcontainers' testImplementation 'org.testcontainers:mysql:1.17.3' diff --git a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle index fff193d30..47fe466cc 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle @@ -40,16 +40,17 @@ java { } dependencies { - implementation 'org.slf4j:slf4j-api:1.7.36' + implementation 'org.slf4j:slf4j-api:2.0.9' - testImplementation 'ch.qos.logback:logback-core:1.2.11' - testImplementation 'ch.qos.logback:logback-classic:1.2.11' + testImplementation 'ch.qos.logback:logback-core:1.4.11' + testImplementation 'ch.qos.logback:logback-classic:1.4.11' testImplementation 'org.apache.groovy:groovy:4.0.15' testImplementation 'org.apache.groovy:groovy-nio:4.0.15' testImplementation 'org.apache.groovy:groovy-test:4.0.15' - testImplementation 'org.objenesis:objenesis:3.2' - testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' - testImplementation 'org.spockframework:spock-junit4:2.3-groovy-4.0' + testImplementation 'cglib:cglib-nodep:3.3.0' + testImplementation 'org.objenesis:objenesis:3.3' + testImplementation ('org.spockframework:spock-core:2.3-groovy-4.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } + testImplementation ('org.spockframework:spock-junit4:2.3-groovy-4.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } } tasks.withType(Test) { diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index db9a6b825..e411586a5 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.3-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 9c8ac3ac2cac1de5a5705ca06947f219bbcc14ca Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 13 Nov 2023 08:05:57 +0100 Subject: [PATCH 09/69] fixed UTs --- build.gradle | 3 ++- gradle.properties | 2 +- .../io/seqera/wave/controller/ContainerTokenController.groovy | 3 ++- .../seqera/wave/controller/ContainerBuildControllerTest.groovy | 2 +- .../wave/controller/ContainerTokenControllerHttpTest.groovy | 2 +- .../seqera/wave/controller/ContainerTokenControllerTest.groovy | 2 +- 6 files changed, 8 insertions(+), 6 deletions(-) diff --git a/build.gradle b/build.gradle index feaab6c16..4d99a7204 100644 --- a/build.gradle +++ b/build.gradle @@ -4,6 +4,7 @@ import java.time.format.DateTimeFormatter plugins { id 'java-library' id 'io.seqera.wave.groovy-application-conventions' + id 'io.seqera.wave.java-library-conventions' id "com.github.johnrengelman.shadow" version "8.1.1" id "io.micronaut.minimal.application" version "4.1.0" id "com.google.cloud.tools.jib" version "3.4.0" @@ -106,7 +107,7 @@ micronaut { testRuntime("spock2") processing { incremental(true) - annotations("com.example.*") + annotations("io.seqera.*") } } diff --git a/gradle.properties b/gradle.properties index 55e82ffdc..51764ade4 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,5 +16,5 @@ # along with this program. If not, see . # -micronautVersion=4.1.4 +micronautVersion=4.1.6 micronautEnvs=dev,h2,mail,aws-ses diff --git a/src/main/groovy/io/seqera/wave/controller/ContainerTokenController.groovy b/src/main/groovy/io/seqera/wave/controller/ContainerTokenController.groovy index e71de538d..eca9e489e 100644 --- a/src/main/groovy/io/seqera/wave/controller/ContainerTokenController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/ContainerTokenController.groovy @@ -28,6 +28,7 @@ import groovy.util.logging.Slf4j import io.micronaut.context.annotation.Value import io.micronaut.http.HttpRequest import io.micronaut.http.HttpResponse +import io.micronaut.http.annotation.Body import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Get import io.micronaut.http.annotation.Post @@ -145,7 +146,7 @@ class ContainerTokenController { } @Post('/container-token') - CompletableFuture> getToken(HttpRequest httpRequest, SubmitContainerTokenRequest req) { + CompletableFuture> getToken(HttpRequest httpRequest, @Body SubmitContainerTokenRequest req) { validateContainerRequest(req) // this is needed for backward compatibility with old clients diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerBuildControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerBuildControllerTest.groovy index 88789352b..1fea99ce5 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerBuildControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerBuildControllerTest.groovy @@ -108,7 +108,7 @@ class ContainerBuildControllerTest extends Specification { 1 * buildLogService.fetchLogStream(buildId) >> response and: res.code() == 200 - new String(res.bodyBytes) == LOGS + res.body == LOGS } } diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerHttpTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerHttpTest.groovy index 0313b8893..14e5b0dcb 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerHttpTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerHttpTest.groovy @@ -93,7 +93,7 @@ class ContainerTokenControllerHttpTest extends Specification { def cfg = new ContainerConfig(workingDir: '/foo') SubmitContainerTokenRequest request = new SubmitContainerTokenRequest( - towerWorkspaceId: 10, containerImage: 'ubuntu:latest', containerConfig: cfg, containerPlatform: 'arm64',) + towerWorkspaceId: 10, containerImage: 'ubuntu:latest', containerConfig: cfg, containerPlatform: 'arm64') def resp = client.toBlocking().exchange(HttpRequest.POST("http://localhost:$port/container-token", request), SubmitContainerTokenResponse) then: resp.status() == HttpStatus.OK diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerTest.groovy index fd41b31a4..d72bc6955 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerTest.groovy @@ -268,7 +268,7 @@ class ContainerTokenControllerTest extends Specification { def 'should add library prefix' () { when: - def body = new SubmitContainerTokenRequest(containerImage: 'docker.io/hello-world') + SubmitContainerTokenRequest body = new SubmitContainerTokenRequest(containerImage: 'docker.io/hello-world') def req1 = HttpRequest.POST("/container-token", body) def resp1 = client.toBlocking().exchange(req1, SubmitContainerTokenResponse) then: From ff509a5406fce125cc89da073881e33a90161644 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 13 Nov 2023 08:41:08 +0100 Subject: [PATCH 10/69] added useJUnitPlatform() --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 4d99a7204..4e007fc6f 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,6 @@ import java.time.format.DateTimeFormatter plugins { id 'java-library' id 'io.seqera.wave.groovy-application-conventions' - id 'io.seqera.wave.java-library-conventions' id "com.github.johnrengelman.shadow" version "8.1.1" id "io.micronaut.minimal.application" version "4.1.0" id "com.google.cloud.tools.jib" version "3.4.0" @@ -158,6 +157,7 @@ run{ } test { + useJUnitPlatform() testLogging { outputs.upToDateWhen {false} showStandardStreams = true From 66a8e88ba089aa09da803f556903baaa35cde9b6 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 11 Mar 2024 11:48:53 +0100 Subject: [PATCH 11/69] added micronaut-reactor-http-client Signed-off-by: munishchouhan --- build.gradle | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/build.gradle b/build.gradle index 250f8e97a..722b6c001 100644 --- a/build.gradle +++ b/build.gradle @@ -38,30 +38,31 @@ dependencies { api 'io.seqera:wave-api:0.5.0' api 'io.seqera:wave-utils:0.7.4' - implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0' + implementation 'com.google.code.gson:gson:2.9.0' + implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' + implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' + implementation 'com.squareup.moshi:moshi:1.14.0' + implementation 'com.squareup.moshi:moshi-adapters:1.14.0' implementation 'io.micronaut:micronaut-http-client' implementation 'io.micronaut:micronaut-jackson-databind' implementation 'io.micronaut.groovy:micronaut-runtime-groovy' - implementation 'jakarta.annotation:jakarta.annotation-api' + implementation 'io.micronaut.reactor:micronaut-reactor' + implementation 'io.micronaut.reactor:micronaut-reactor-http-client' implementation 'io.micronaut.validation:micronaut-validation' + implementation 'io.kubernetes:client-java:19.0.0' + implementation 'io.kubernetes:client-java-api-fluent:18.0.1' + implementation 'io.micronaut:micronaut-retry' + implementation "io.github.resilience4j:resilience4j-ratelimiter:0.17.0" + implementation ('io.seqera:tower-crypto:22.4.0-watson') { transitive = false } // to be replaced with 22.4.0 once released + implementation 'jakarta.annotation:jakarta.annotation-api' + implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0' implementation 'org.apache.groovy:groovy-json' implementation 'org.apache.groovy:groovy-nio' implementation 'com.google.guava:guava:32.1.2-jre' implementation 'dev.failsafe:failsafe:3.1.0' - implementation 'io.micronaut.reactor:micronaut-reactor' - implementation ('io.seqera:tower-crypto:22.4.0-watson') { transitive = false } // to be replaced with 22.4.0 once released implementation 'org.apache.commons:commons-compress:1.24.0' implementation 'org.apache.commons:commons-lang3:3.12.0' - implementation 'io.kubernetes:client-java:19.0.0' - implementation 'io.kubernetes:client-java-api-fluent:18.0.1' - implementation 'com.google.code.gson:gson:2.9.0' - implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' - implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' - implementation 'com.squareup.moshi:moshi:1.14.0' - implementation 'com.squareup.moshi:moshi-adapters:1.14.0' - implementation 'io.micronaut:micronaut-retry' implementation 'redis.clients:jedis:5.0.2' - implementation "io.github.resilience4j:resilience4j-ratelimiter:0.17.0" // caching deps implementation 'io.micronaut.cache:micronaut-cache-core' implementation 'io.micronaut.cache:micronaut-cache-caffeine' From 6145e2c73754df1f1a284c0c6bbc1d2eca09318c Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 11 Mar 2024 12:28:43 +0100 Subject: [PATCH 12/69] fixed api changes Signed-off-by: munishchouhan --- build.gradle | 90 +++++++++---------- .../auth/BasicAuthenticationProvider.groovy | 2 +- .../impl/SurrealPersistenceService.groovy | 8 +- .../ContainerTokenControllerTest.groovy | 2 +- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/build.gradle b/build.gradle index b56cf26dd..36417bf7f 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ plugins { id "com.github.johnrengelman.shadow" version "8.1.1" id "io.micronaut.minimal.application" version "4.1.0" id "com.google.cloud.tools.jib" version "3.4.0" - id "org.asciidoctor.jvm.convert" version "3.3.2" + id 'org.asciidoctor.jvm.convert' version '3.3.2' } String gitVersion() { @@ -28,75 +28,75 @@ repositories { } dependencies { - annotationProcessor 'io.micronaut.validation:micronaut-validation-processor' - annotationProcessor 'io.micronaut:micronaut-http-validation' - compileOnly 'io.micronaut.data:micronaut-data-processor' - compileOnly 'io.micronaut:micronaut-inject-groovy' - compileOnly 'io.micronaut:micronaut-http-validation' - + annotationProcessor("io.micronaut.validation:micronaut-validation-processor") + annotationProcessor("io.micronaut:micronaut-http-validation") + compileOnly("io.micronaut.data:micronaut-data-processor") + compileOnly("io.micronaut:micronaut-inject-groovy") + compileOnly("io.micronaut:micronaut-http-validation") + implementation("jakarta.persistence:jakarta.persistence-api:3.0.0") api 'io.seqera:lib-mail:1.0.0' api 'io.seqera:wave-api:0.7.2' api 'io.seqera:wave-utils:0.7.4' - implementation 'com.google.code.gson:gson:2.9.0' - implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jsr310' - implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' - implementation 'com.squareup.moshi:moshi:1.14.0' - implementation 'com.squareup.moshi:moshi-adapters:1.14.0' - implementation 'io.micronaut:micronaut-http-client' - implementation 'io.micronaut:micronaut-jackson-databind' - implementation 'io.micronaut.groovy:micronaut-runtime-groovy' - implementation 'io.micronaut.reactor:micronaut-reactor' - implementation 'io.micronaut.reactor:micronaut-reactor-http-client' - implementation 'io.micronaut.validation:micronaut-validation' - implementation 'io.kubernetes:client-java:19.0.0' - implementation 'io.kubernetes:client-java-api-fluent:18.0.1' - implementation 'io.micronaut:micronaut-retry' - implementation "io.github.resilience4j:resilience4j-ratelimiter:0.17.0" - implementation ('io.seqera:tower-crypto:22.4.0-watson') { transitive = false } // to be replaced with 22.4.0 once released - implementation 'jakarta.annotation:jakarta.annotation-api' - implementation 'jakarta.persistence:jakarta.persistence-api:3.1.0' - implementation 'org.apache.groovy:groovy-json' - implementation 'org.apache.groovy:groovy-nio' + implementation("io.micronaut:micronaut-http-client") + implementation("io.micronaut:micronaut-jackson-databind") + implementation("io.micronaut.groovy:micronaut-runtime-groovy") + implementation("io.micronaut.reactor:micronaut-reactor") + implementation("io.micronaut.reactor:micronaut-reactor-http-client") + implementation("jakarta.annotation:jakarta.annotation-api") + implementation("io.micronaut.validation:micronaut-validation") + implementation 'io.micronaut.security:micronaut-security' + implementation "org.apache.groovy:groovy-json" + implementation "org.apache.groovy:groovy-nio" implementation 'com.google.guava:guava:32.1.2-jre' implementation 'dev.failsafe:failsafe:3.1.0' + implementation 'io.micronaut.reactor:micronaut-reactor' + implementation 'io.micronaut.reactor:micronaut-reactor-http-client' + implementation("io.seqera:tower-crypto:22.4.0-watson") { transitive = false } // to be replaced with 22.4.0 once released implementation 'org.apache.commons:commons-compress:1.24.0' implementation 'org.apache.commons:commons-lang3:3.12.0' + implementation 'io.kubernetes:client-java:19.0.0' + implementation 'io.kubernetes:client-java-api-fluent:18.0.1' + implementation 'com.google.code.gson:gson:2.9.0' + implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" + implementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-yaml' + implementation 'com.squareup.moshi:moshi:1.14.0' + implementation 'com.squareup.moshi:moshi-adapters:1.14.0' implementation 'redis.clients:jedis:5.0.2' + implementation "io.github.resilience4j:resilience4j-ratelimiter:0.17.0" + implementation("io.micronaut:micronaut-retry") // caching deps - implementation 'io.micronaut.cache:micronaut-cache-core' - implementation 'io.micronaut.cache:micronaut-cache-caffeine' - implementation 'io.micronaut.aws:micronaut-aws-parameter-store' - implementation 'software.amazon.awssdk:ecr' - implementation 'software.amazon.awssdk:ecrpublic' - implementation 'com.amazonaws:aws-java-sdk-ses:1.12.42' + implementation("io.micronaut.cache:micronaut-cache-core") + implementation("io.micronaut.cache:micronaut-cache-caffeine") + implementation("io.micronaut.aws:micronaut-aws-parameter-store") + implementation "software.amazon.awssdk:ecr" + implementation "software.amazon.awssdk:ecrpublic" + implementation 'software.amazon.awssdk:ses' implementation 'org.yaml:snakeyaml:2.0' //object storage dependency implementation("io.micronaut.objectstorage:micronaut-object-storage-aws") // include sts to allow the use of service account role - https://stackoverflow.com/a/73306570 // this sts dependency is require by micronaut-aws-parameter-store, // not directly used by the app, for this reason keeping `runtimeOnly` - runtimeOnly 'software.amazon.awssdk:sts' + runtimeOnly "software.amazon.awssdk:sts" - runtimeOnly 'io.netty:netty-tcnative-boringssl-static:2.0.0.Final' - runtimeOnly 'javax.xml.bind:jaxb-api:2.3.1' - runtimeOnly 'org.yaml:snakeyaml' - runtimeOnly 'io.micronaut.testresources:micronaut-test-resources-client:2.1.0' - testImplementation 'org.testcontainers:testcontainers' - testImplementation 'org.testcontainers:mysql:1.17.3' + runtimeOnly("io.netty:netty-tcnative-boringssl-static:2.0.0.Final") + runtimeOnly("javax.xml.bind:jaxb-api:2.3.1") + testImplementation("org.testcontainers:testcontainers") + testImplementation("org.testcontainers:mysql:1.17.3") // -- - implementation 'ch.qos.logback:logback-classic:1.4.8' + implementation("ch.qos.logback:logback-classic:1.5.3") // rate limit implementation 'com.github.seqeralabs:spillway:7b72700293' // monitoring - implementation 'io.micronaut.micrometer:micronaut-micrometer-registry-prometheus' + implementation "io.micronaut.micrometer:micronaut-micrometer-registry-prometheus" // Also required to enable endpoint - implementation 'io.micronaut:micronaut-management' + implementation "io.micronaut:micronaut-management" //views - implementation 'io.micronaut.views:micronaut-views-handlebars' + implementation("io.micronaut.views:micronaut-views-handlebars") } application { @@ -112,6 +112,7 @@ micronaut { } } + // // Build container image with JIB // https://github.com/GoogleContainerTools/jib/tree/master/jib-gradle-plugin @@ -159,7 +160,6 @@ run{ } test { - useJUnitPlatform() testLogging { outputs.upToDateWhen {false} showStandardStreams = true diff --git a/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy b/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy index fdb188f16..ebdb1c00c 100644 --- a/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy +++ b/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy @@ -44,7 +44,7 @@ class BasicAuthenticationProvider implements AuthenticationProvider { private AccountService accountService @Override - Publisher authenticate(@Nullable HttpRequest httpRequest, AuthenticationRequest authRequest) { + Publisher authenticate(@Nullable Object httpRequest, AuthenticationRequest authenticationRequest) { Flux.create(emitter -> { final user = authRequest.identity?.toString() final pass = authRequest.secret?.toString() diff --git a/src/main/groovy/io/seqera/wave/service/persistence/impl/SurrealPersistenceService.groovy b/src/main/groovy/io/seqera/wave/service/persistence/impl/SurrealPersistenceService.groovy index 407203f45..0b93b7bad 100644 --- a/src/main/groovy/io/seqera/wave/service/persistence/impl/SurrealPersistenceService.groovy +++ b/src/main/groovy/io/seqera/wave/service/persistence/impl/SurrealPersistenceService.groovy @@ -248,9 +248,9 @@ class SurrealPersistenceService implements PersistenceService { def results = map.get("result") as List log.trace("Total builds count results: $results") if( results && results.size() > 0) - return results[0].get("total_count")? results[0].get("total_count") as Long : 0 + return results[0].get("total_count")? results[0].get("total_count") as Long : 0L else - return 0 + return 0L } static String getBuildMetricFilter(MetricFilter metricFilter){ @@ -297,9 +297,9 @@ class SurrealPersistenceService implements PersistenceService { def results = map.get("result") as List log.trace("Total pulls count results: $results") if( results && results.size() > 0) - return results[0].get("total_count")? results[0].get("total_count") as Long : 0 + return results[0].get("total_count")? results[0].get("total_count") as Long : 0L else - return 0 + return 0L } static String getPullMetricFilter(MetricFilter metricFilter){ diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerTest.groovy index 2ec95028a..9db111107 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerTokenControllerTest.groovy @@ -313,7 +313,7 @@ class ContainerTokenControllerTest extends Specification { def 'should add library prefix' () { when: - SubmitContainerTokenRequest body = new SubmitContainerTokenRequest(containerImage: 'docker.io/hello-world') + def body = new SubmitContainerTokenRequest(containerImage: 'docker.io/hello-world') def req1 = HttpRequest.POST("/container-token", body) def resp1 = client.toBlocking().exchange(req1, SubmitContainerTokenResponse) then: From 181a6719064784d77a9bc3983545b69ab2f17e73 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 27 May 2024 22:23:55 +0200 Subject: [PATCH 13/69] fixed build error --- .../wave/service/metric/impl/MetricsServiceImpl.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/service/metric/impl/MetricsServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/metric/impl/MetricsServiceImpl.groovy index 03298ddda..b0feb795b 100644 --- a/src/main/groovy/io/seqera/wave/service/metric/impl/MetricsServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/metric/impl/MetricsServiceImpl.groovy @@ -47,17 +47,17 @@ class MetricsServiceImpl implements MetricsService { @Override Long getBuildsMetrics(String date, String org) { - return metricsCounterStore.get(getKey(MetricConstants.PREFIX_BUILDS, date, org)) ?: 0 + return metricsCounterStore.get(getKey(MetricConstants.PREFIX_BUILDS, date, org)) ?: 0L } @Override Long getPullsMetrics(String date, String org) { - return metricsCounterStore.get(getKey(MetricConstants.PREFIX_PULLS, date, org)) ?: 0 + return metricsCounterStore.get(getKey(MetricConstants.PREFIX_PULLS, date, org)) ?: 0L } @Override Long getFusionPullsMetrics(String date, String org) { - return metricsCounterStore.get(getKey(MetricConstants.PREFIX_FUSION, date, org)) ?: 0 + return metricsCounterStore.get(getKey(MetricConstants.PREFIX_FUSION, date, org)) ?: 0L } @Override From d06a265bb6c8ccd9135450f264d9b32878693a17 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 27 May 2024 22:29:02 +0200 Subject: [PATCH 14/69] fixed dependency --- build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/build.gradle b/build.gradle index b74c1528c..2681244b3 100644 --- a/build.gradle +++ b/build.gradle @@ -6,7 +6,6 @@ plugins { id 'io.seqera.wave.groovy-application-conventions' id "com.github.johnrengelman.shadow" version "8.1.1" id "io.micronaut.minimal.application" version "4.1.0" - id "com.google.cloud.tools.jib" version "3.4.0" id "com.google.cloud.tools.jib" version "3.4.2" id 'org.asciidoctor.jvm.convert' version '3.3.2' } From f718b0ebdedca2565bc73aff2397d01465918d8f Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 27 May 2024 23:03:56 +0200 Subject: [PATCH 15/69] fixed gradle --- .../io.seqera.wave.groovy-application-conventions.gradle | 4 ++-- .../groovy/io.seqera.wave.groovy-common-conventions.gradle | 2 +- .../groovy/io.seqera.wave.java-library-conventions.gradle | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/buildSrc/src/main/groovy/io.seqera.wave.groovy-application-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.groovy-application-conventions.gradle index 0cf39fc5e..c14579b32 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.groovy-application-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.groovy-application-conventions.gradle @@ -12,7 +12,7 @@ plugins { group = 'io.seqera' -tasks.withType(Test) { +tasks.withType(Test).configureEach { // note: "--enable-preview" is required to use virtual thread on Java 19 and 20 - jvmArgs (["--enable-preview"]) + jvmArgs(["--enable-preview"]) } diff --git a/buildSrc/src/main/groovy/io.seqera.wave.groovy-common-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.groovy-common-conventions.gradle index 95ef3896f..915567a14 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.groovy-common-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.groovy-common-conventions.gradle @@ -22,7 +22,7 @@ compileJava { options.release.set(11) } -tasks.withType(GroovyCompile) { +tasks.withType(GroovyCompile).configureEach { sourceCompatibility = '17' targetCompatibility = '17' } diff --git a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle index 47fe466cc..ebc21f708 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle @@ -24,7 +24,7 @@ compileJava { options.release.set(11) } -tasks.withType(GroovyCompile) { +tasks.withType(GroovyCompile).configureEach { sourceCompatibility = '17' targetCompatibility = '17' } From 0f31d255af9316e3ebedc5318c613a20762f9ea2 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 28 May 2024 11:51:11 +0200 Subject: [PATCH 16/69] minor change --- .../groovy/io.seqera.wave.java-library-conventions.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle index ebc21f708..723e8587d 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle @@ -53,8 +53,8 @@ dependencies { testImplementation ('org.spockframework:spock-junit4:2.3-groovy-4.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } } -tasks.withType(Test) { - jvmArgs ([ +tasks.withType(Test).configureEach { + jvmArgs([ '--enable-preview', '--add-opens=java.base/java.lang=ALL-UNNAMED', '--add-opens=java.base/java.io=ALL-UNNAMED', From 8d79675c9c32eba5900ba4ddba99c69636fa31c2 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Wed, 5 Jun 2024 15:24:17 +0200 Subject: [PATCH 17/69] Bump MN 4.4.3 Signed-off-by: Paolo Di Tommaso --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 4d332f36a..a51745232 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,5 +16,5 @@ # along with this program. If not, see . # -micronautVersion=4.1.6 +micronautVersion=4.4.3 micronautEnvs=dev,h2,mail,aws-ses From 47680fee5d413de86696b8512af97a9190fc7339 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Wed, 5 Jun 2024 15:47:09 +0200 Subject: [PATCH 18/69] bump lib-mail@1.1.0 + wave-api@0.11.0 + wave-utils@0.13.0 Signed-off-by: Paolo Di Tommaso --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index 2681244b3..25d05c1a8 100644 --- a/build.gradle +++ b/build.gradle @@ -34,9 +34,9 @@ dependencies { compileOnly("io.micronaut:micronaut-inject-groovy") compileOnly("io.micronaut:micronaut-http-validation") implementation("jakarta.persistence:jakarta.persistence-api:3.0.0") - api 'io.seqera:lib-mail:1.0.0' - api 'io.seqera:wave-api:0.10.0' - api 'io.seqera:wave-utils:0.12.0' + api 'io.seqera:lib-mail:1.1.0' + api 'io.seqera:wave-api:0.11.0' + api 'io.seqera:wave-utils:0.13.0' implementation("io.micronaut:micronaut-http-client") implementation("io.micronaut:micronaut-jackson-databind") From cc90d46282ffb65d2cb7c0d01b8cac12173ca9dc Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 5 Jun 2024 17:11:37 +0200 Subject: [PATCH 19/69] fixed auth --- .../auth/BasicAuthenticationProvider.groovy | 33 ++++++++----------- .../controller/ContainerController.groovy | 3 +- .../service/account/AccountServiceImpl.groovy | 3 +- .../controller/BuildControllerTest.groovy | 2 +- 4 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy b/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy index ea85e8a71..cca846b0b 100644 --- a/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy +++ b/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy @@ -19,18 +19,17 @@ package io.seqera.wave.auth import groovy.util.logging.Slf4j +import io.micronaut.core.annotation.NonNull import io.micronaut.core.annotation.Nullable import io.micronaut.http.HttpRequest -import io.micronaut.security.authentication.AuthenticationProvider +import io.micronaut.security.authentication.AuthenticationFailureReason import io.micronaut.security.authentication.AuthenticationRequest import io.micronaut.security.authentication.AuthenticationResponse +import io.micronaut.security.authentication.provider.HttpRequestAuthenticationProvider import io.seqera.wave.service.account.AccountService import io.seqera.wave.util.StringUtils import jakarta.inject.Inject import jakarta.inject.Singleton -import org.reactivestreams.Publisher -import reactor.core.publisher.Flux -import reactor.core.publisher.FluxSink /** * Basic Authentication provider * @@ -38,25 +37,21 @@ import reactor.core.publisher.FluxSink */ @Slf4j @Singleton -class BasicAuthenticationProvider implements AuthenticationProvider { +class BasicAuthenticationProvider implements HttpRequestAuthenticationProvider { @Inject private AccountService accountService @Override - Publisher authenticate(@Nullable Object httpRequest, AuthenticationRequest authenticationRequest) { - Flux.create(emitter -> { - final user = authRequest.identity?.toString() - final pass = authRequest.secret?.toString() - if (accountService.isAuthorised(user, pass)) { - log.trace "Auth request OK - user '$user'; password: '${StringUtils.redact(pass)}'" - emitter.next(AuthenticationResponse.success((String) authRequest.identity)) - emitter.complete() - } - else { - log.trace "Auth request FAILED - user '$user'; password: '${StringUtils.redact(pass)}'" - emitter.error(AuthenticationResponse.exception()) - } - }, FluxSink.OverflowStrategy.ERROR) + AuthenticationResponse authenticate(@Nullable HttpRequest httpRequest, @NonNull AuthenticationRequest authRequest) { + final user = authRequest.identity?.toString() + final pass = authRequest.secret?.toString() + if (accountService.isAuthorised(user, pass)) { + log.trace "Auth request OK - user '$user'; password: '${StringUtils.redact(pass)}'" + return AuthenticationResponse.success(authRequest.identity) + } else { + log.trace "Auth request FAILED - user '$user'; password: '${StringUtils.redact(pass)}'" + return AuthenticationResponse.failure(AuthenticationFailureReason.CREDENTIALS_DO_NOT_MATCH) + } } } diff --git a/src/main/groovy/io/seqera/wave/controller/ContainerController.groovy b/src/main/groovy/io/seqera/wave/controller/ContainerController.groovy index ea3ade866..68dcac0c2 100644 --- a/src/main/groovy/io/seqera/wave/controller/ContainerController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/ContainerController.groovy @@ -155,7 +155,6 @@ class ContainerController { @Deprecated @Post('/container-token') - @ExecuteOn(TaskExecutors.IO) CompletableFuture> getToken(HttpRequest httpRequest, @Body SubmitContainerTokenRequest req) { return getContainerImpl(httpRequest, req, false) @@ -163,7 +162,7 @@ class ContainerController { @Post('/v1alpha2/container') @ExecuteOn(TaskExecutors.IO) - CompletableFuture> getTokenV2(HttpRequest httpRequest, SubmitContainerTokenRequest req) { + CompletableFuture> getTokenV2(HttpRequest httpRequest, @Body SubmitContainerTokenRequest req) { return getContainerImpl(httpRequest, req, true) } diff --git a/src/main/groovy/io/seqera/wave/service/account/AccountServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/account/AccountServiceImpl.groovy index 3cccda9ab..ec1b8df3f 100644 --- a/src/main/groovy/io/seqera/wave/service/account/AccountServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/account/AccountServiceImpl.groovy @@ -36,7 +36,7 @@ import jakarta.annotation.PostConstruct @ConfigurationProperties('wave') class AccountServiceImpl implements AccountService { - private Map accounts = Map.of() + Map accounts = Map.of() @PostConstruct private dumpAccounts() { @@ -45,6 +45,7 @@ class AccountServiceImpl implements AccountService { @Override boolean isAuthorised(String username, String password) { + log.info("accounts: $accounts") if( !username || !password ) return false if( !accounts.containsKey(username) ) diff --git a/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy index 9450c6065..d202a4a59 100644 --- a/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy @@ -125,7 +125,7 @@ class BuildControllerTest extends Specification { 1 * buildLogService.fetchLogStream(buildId) >> response and: res.code() == 200 - res.body == LOGS + res.body() == LOGS } def 'should get container status' () { From b3cb5e18cb44025c503254702a48fd49dd30894c Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 5 Jun 2024 18:33:52 +0200 Subject: [PATCH 20/69] fixed container and inspect tests --- .../groovy/io/seqera/wave/controller/InspectController.groovy | 3 ++- .../io/seqera/wave/controller/ContainerControllerTest.groovy | 4 +--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/controller/InspectController.groovy b/src/main/groovy/io/seqera/wave/controller/InspectController.groovy index 190a4ced5..4edf68d4d 100644 --- a/src/main/groovy/io/seqera/wave/controller/InspectController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/InspectController.groovy @@ -24,6 +24,7 @@ import groovy.transform.CompileStatic import groovy.util.logging.Slf4j import io.micronaut.context.annotation.Value import io.micronaut.http.HttpResponse +import io.micronaut.http.annotation.Body import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Post import io.micronaut.scheduling.TaskExecutors @@ -68,7 +69,7 @@ class InspectController { private String serverUrl @Post("/v1alpha1/inspect") - CompletableFuture> inspect(ContainerInspectRequest req) { + CompletableFuture> inspect(@Body ContainerInspectRequest req) { if( !req.containerImage ) throw new BadRequestException("Missing 'containerImage' attribute") diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy index 5d3e1ef0e..43d2fa208 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy @@ -126,9 +126,7 @@ class ContainerControllerTest extends Specification { def controller = Spy(new ContainerController(freezeService: freeze, inclusionService: Mock(ContainerInclusionService))) and: def target = 'docker.io/repo/ubuntu:latest' - def BUILD = Mock(BuildRequest) { - getTargetImage() >> target - } + def BUILD = new BuildRequest (targetImage: target) and: def req = new SubmitContainerTokenRequest(containerImage: 'ubuntu:latest', freeze: true, buildRepository: 'docker.io/foo/bar') From 55e668b13d2da37657db0787c9199c44668737c3 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 10 Jun 2024 17:43:30 +0200 Subject: [PATCH 21/69] Fixed ProxyClient and ValidateController --- .../wave/controller/BuildController.groovy | 2 +- .../wave/controller/ValidateController.groovy | 3 ++- .../io/seqera/wave/proxy/ProxyClient.groovy | 3 +++ .../wave/controller/BuildControllerTest.groovy | 3 ++- .../ratelimit/BuildServiceRateLimitTest.groovy | 17 ++++++----------- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/controller/BuildController.groovy b/src/main/groovy/io/seqera/wave/controller/BuildController.groovy index 28891d3d9..ff439f435 100644 --- a/src/main/groovy/io/seqera/wave/controller/BuildController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/BuildController.groovy @@ -67,7 +67,7 @@ class BuildController { throw new IllegalStateException("Build Logs service not configured") final logs = logService.fetchLogStream(buildId) return logs - ? HttpResponse.ok(logs) + ? HttpResponse.ok(logs).contentType(MediaType.TEXT_PLAIN_TYPE) : HttpResponse.notFound() } diff --git a/src/main/groovy/io/seqera/wave/controller/ValidateController.groovy b/src/main/groovy/io/seqera/wave/controller/ValidateController.groovy index 6f21be315..f12e794dd 100644 --- a/src/main/groovy/io/seqera/wave/controller/ValidateController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/ValidateController.groovy @@ -18,6 +18,7 @@ package io.seqera.wave.controller +import io.micronaut.http.annotation.Body import io.micronaut.http.annotation.Controller import io.micronaut.http.annotation.Post import io.micronaut.scheduling.TaskExecutors @@ -34,7 +35,7 @@ class ValidateController { @Inject RegistryAuthService loginService @Post - Mono validateCreds(@Valid ValidateRegistryCredsRequest request){ + Mono validateCreds(@Valid @Body ValidateRegistryCredsRequest request){ Mono.just( loginService.validateUser(request.registry, request.userName, request.password) ) diff --git a/src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy b/src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy index 222e0a7cc..a8ab06ac3 100644 --- a/src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy +++ b/src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy @@ -60,6 +60,9 @@ class ProxyClient { private ContainerPath route private HttpClientConfig httpConfig + //required for mocking in groovy tests + ProxyClient(){} + ProxyClient(HttpClient httpClient, HttpClientConfig httpConfig) { if( httpClient.followRedirects()!= HttpClient.Redirect.NEVER ) throw new IllegalStateException("HttpClient instance should not follow redirected because they are directly managed by the proxy") diff --git a/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy index d202a4a59..195428b46 100644 --- a/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy @@ -125,9 +125,10 @@ class BuildControllerTest extends Specification { 1 * buildLogService.fetchLogStream(buildId) >> response and: res.code() == 200 - res.body() == LOGS + new String(res.unpooledContent.array) == LOGS } + def 'should get container status' () { given: def build1 = new WaveBuildRecord( diff --git a/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy b/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy index 05d702d62..e08969651 100644 --- a/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy +++ b/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy @@ -24,6 +24,7 @@ import spock.lang.Specification import java.nio.file.Files import io.micronaut.context.ApplicationContext +import io.micronaut.test.extensions.spock.annotation.MicronautTest import io.seqera.wave.configuration.RateLimiterConfig import io.seqera.wave.core.ContainerPlatform import io.seqera.wave.exception.SlowDownException @@ -32,10 +33,13 @@ import io.seqera.wave.service.builder.BuildRequest import io.seqera.wave.service.builder.ContainerBuildServiceImpl import io.seqera.wave.tower.PlatformId import io.seqera.wave.util.ContainerHelper +import jakarta.inject.Inject + /** * @author : jorge * */ +@MicronautTest(environments = ["test", "rate-limit"]) class BuildServiceRateLimitTest extends Specification { @Shared @@ -44,21 +48,12 @@ class BuildServiceRateLimitTest extends Specification { @Shared String cacheRepo = 'quay.io/cache/name' - @Shared - ApplicationContext applicationContext - - @Shared + @Inject ContainerBuildServiceImpl containerBuildService - @Shared + @Inject RateLimiterConfig configuration - def setupSpec() { - applicationContext = ApplicationContext.run('test', 'rate-limit') - containerBuildService = applicationContext.getBean(ContainerBuildServiceImpl) - configuration = applicationContext.getBean(RateLimiterConfig) - } - def 'should not allow more auth builds than rate limit' () { given: From a235a248d9eea7290281c84abb919987e4b55a07 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 10 Jun 2024 18:05:44 +0200 Subject: [PATCH 22/69] added objenesis for mocking --- build.gradle | 2 ++ .../wave/controller/BuildController.groovy | 2 +- .../io/seqera/wave/proxy/ProxyClient.groovy | 3 --- .../ratelimit/BuildServiceRateLimitTest.groovy | 17 +++++++++++------ .../wave/service/CredentialsServiceTest.groovy | 2 -- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index 25d05c1a8..075e731dd 100644 --- a/build.gradle +++ b/build.gradle @@ -97,6 +97,8 @@ dependencies { implementation "io.micronaut:micronaut-management" //views implementation("io.micronaut.views:micronaut-views-handlebars") + + testImplementation('org.objenesis:objenesis:3.4') } application { diff --git a/src/main/groovy/io/seqera/wave/controller/BuildController.groovy b/src/main/groovy/io/seqera/wave/controller/BuildController.groovy index ff439f435..28891d3d9 100644 --- a/src/main/groovy/io/seqera/wave/controller/BuildController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/BuildController.groovy @@ -67,7 +67,7 @@ class BuildController { throw new IllegalStateException("Build Logs service not configured") final logs = logService.fetchLogStream(buildId) return logs - ? HttpResponse.ok(logs).contentType(MediaType.TEXT_PLAIN_TYPE) + ? HttpResponse.ok(logs) : HttpResponse.notFound() } diff --git a/src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy b/src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy index a8ab06ac3..222e0a7cc 100644 --- a/src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy +++ b/src/main/groovy/io/seqera/wave/proxy/ProxyClient.groovy @@ -60,9 +60,6 @@ class ProxyClient { private ContainerPath route private HttpClientConfig httpConfig - //required for mocking in groovy tests - ProxyClient(){} - ProxyClient(HttpClient httpClient, HttpClientConfig httpConfig) { if( httpClient.followRedirects()!= HttpClient.Redirect.NEVER ) throw new IllegalStateException("HttpClient instance should not follow redirected because they are directly managed by the proxy") diff --git a/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy b/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy index e08969651..05d702d62 100644 --- a/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy +++ b/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy @@ -24,7 +24,6 @@ import spock.lang.Specification import java.nio.file.Files import io.micronaut.context.ApplicationContext -import io.micronaut.test.extensions.spock.annotation.MicronautTest import io.seqera.wave.configuration.RateLimiterConfig import io.seqera.wave.core.ContainerPlatform import io.seqera.wave.exception.SlowDownException @@ -33,13 +32,10 @@ import io.seqera.wave.service.builder.BuildRequest import io.seqera.wave.service.builder.ContainerBuildServiceImpl import io.seqera.wave.tower.PlatformId import io.seqera.wave.util.ContainerHelper -import jakarta.inject.Inject - /** * @author : jorge * */ -@MicronautTest(environments = ["test", "rate-limit"]) class BuildServiceRateLimitTest extends Specification { @Shared @@ -48,12 +44,21 @@ class BuildServiceRateLimitTest extends Specification { @Shared String cacheRepo = 'quay.io/cache/name' - @Inject + @Shared + ApplicationContext applicationContext + + @Shared ContainerBuildServiceImpl containerBuildService - @Inject + @Shared RateLimiterConfig configuration + def setupSpec() { + applicationContext = ApplicationContext.run('test', 'rate-limit') + containerBuildService = applicationContext.getBean(ContainerBuildServiceImpl) + configuration = applicationContext.getBean(RateLimiterConfig) + } + def 'should not allow more auth builds than rate limit' () { given: diff --git a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy index e55df4766..cd4771ff0 100644 --- a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy @@ -49,11 +49,9 @@ class CredentialsServiceTest extends Specification { @Inject CredentialsService credentialsService - @MockBean(TowerClient) TowerClient towerClient = Mock(TowerClient) - @MockBean(PairingService) PairingService securityService = Mock(PairingService) From f64f9f6c722f2187a7275c3bc8ca85fc4bfeaf85 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 11 Jun 2024 12:42:45 +0200 Subject: [PATCH 23/69] minor changes --- .../io/seqera/wave/controller/ContainerControllerTest.groovy | 4 +++- .../io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy | 1 - 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy index 43d2fa208..5d3e1ef0e 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy @@ -126,7 +126,9 @@ class ContainerControllerTest extends Specification { def controller = Spy(new ContainerController(freezeService: freeze, inclusionService: Mock(ContainerInclusionService))) and: def target = 'docker.io/repo/ubuntu:latest' - def BUILD = new BuildRequest (targetImage: target) + def BUILD = Mock(BuildRequest) { + getTargetImage() >> target + } and: def req = new SubmitContainerTokenRequest(containerImage: 'ubuntu:latest', freeze: true, buildRepository: 'docker.io/foo/bar') diff --git a/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy b/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy index 05d702d62..ee625988d 100644 --- a/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy +++ b/src/test/groovy/io/seqera/wave/ratelimit/BuildServiceRateLimitTest.groovy @@ -59,7 +59,6 @@ class BuildServiceRateLimitTest extends Specification { configuration = applicationContext.getBean(RateLimiterConfig) } - def 'should not allow more auth builds than rate limit' () { given: def folder = Files.createTempDirectory('test') From af9c7516b556ffe70dbcc369080aabd4947c73e2 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 12 Jun 2024 10:41:28 +0200 Subject: [PATCH 24/69] fixed BuildControllerTest --- .../io/seqera/wave/controller/BuildControllerTest.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy index 195428b46..4f43de37b 100644 --- a/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy @@ -119,13 +119,13 @@ class BuildControllerTest extends Specification { when: def req = HttpRequest.GET("/v1alpha1/builds/${buildId}/logs") - def res = client.toBlocking().exchange(req, StreamedFile) + def res = client.toBlocking().exchange(req, String) then: 1 * buildLogService.fetchLogStream(buildId) >> response and: res.code() == 200 - new String(res.unpooledContent.array) == LOGS + res.body() == LOGS } From f681b5d4f9b4b4253cd2b6e114c43044d6de0892 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 12 Jun 2024 11:17:39 +0200 Subject: [PATCH 25/69] fixed Credentials and registry test --- .../controller/RegistryControllerLocalTest.groovy | 15 +++++++++------ .../wave/service/CredentialsServiceTest.groovy | 5 ++--- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy b/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy index 36a7eba9e..9d8c44996 100644 --- a/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy @@ -147,22 +147,25 @@ class RegistryControllerLocalTest extends Specification implements DockerRegistr h.add('Accept', it) } }) - HttpResponse response = client.toBlocking().exchange(request, Map) + HttpResponse response = client.toBlocking().exchange(request, String) then: response.status() == HttpStatus.OK when: - def list = response.body().manifests.collect{ - String type = it.mediaType.indexOf("manifest") ? "manifests" : "blobs" + def parsedBody = new JsonSlurper().parseText(response.body.get()) + + def list = parsedBody.manifests.collect { + String type = it.mediaType.contains("manifest") ? "manifests" : "blobs" "/v2/$IMAGE/$type/$it.digest" } - boolean fails = list.find{ url -> - HttpRequest requestGet = HttpRequest.GET(url).headers({ h -> + + boolean fails = list.find { url -> + HttpRequest requestGet = HttpRequest.GET(url).headers { h -> accept.each { h.add('Accept', it) } - }) + } HttpResponse responseGet = client.toBlocking().exchange(requestGet, String) responseGet.status() != HttpStatus.OK } diff --git a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy index cd4771ff0..34e76edd2 100644 --- a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy @@ -117,7 +117,6 @@ class CredentialsServiceTest extends Specification { noExceptionThrown() } - def 'should fail if keys where not registered for the tower endpoint'() { given: def identity = new PlatformId(new User(id:10), 10,"token",'endpoint') @@ -165,7 +164,7 @@ class CredentialsServiceTest extends Specification { registry: 'docker.io' ) and: - def identity = new PlatformId(new User(id:10), 10,"token",'tower.io') + def identity = new PlatformId(new User(id:11), 11,"token",'tower.io') def auth = JwtAuth.of(identity) when: @@ -181,7 +180,7 @@ class CredentialsServiceTest extends Specification { ) and: 'non matching credentials are listed' - 1 * towerClient.listCredentials('tower.io',auth,10) >> CompletableFuture.completedFuture(new ListCredentialsResponse( + 1 * towerClient.listCredentials('tower.io',auth,11) >> CompletableFuture.completedFuture(new ListCredentialsResponse( credentials: [nonContainerRegistryCredentials,otherRegistryCredentials] )) From 69ba612414bd711f930c418d34dfe243a4cce4b2 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 12 Jun 2024 13:01:12 +0200 Subject: [PATCH 26/69] removed @NotNull --- .../io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy b/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy index 4a606460a..e2c9eab60 100644 --- a/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy +++ b/src/main/groovy/io/seqera/wave/ratelimit/impl/SpillwayRateLimiter.groovy @@ -59,7 +59,7 @@ class SpillwayRateLimiter implements RateLimiterService { init(storage, config) } - protected void init(@NotNull LimitUsageStorage storage, @NotNull RateLimiterConfig config){ + protected void init(LimitUsageStorage storage, RateLimiterConfig config){ SpillwayFactory spillwayFactory = new SpillwayFactory(storage) initBuilds(spillwayFactory, config) initPulls(spillwayFactory, config) From f244bbcd156a466728c92676754f94f152b62bfa Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 12 Jun 2024 13:19:45 +0200 Subject: [PATCH 27/69] [release] test 1.9.0-A0 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 27f9cd322..788d0e2dd 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.8.0 +1.9.0-A0 From aa9f4140329e4b283afb264d3fbef7d23269a204 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 12 Jun 2024 14:10:02 +0200 Subject: [PATCH 28/69] update dependencies --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 075e731dd..efcbf49da 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ plugins { id 'java-library' id 'io.seqera.wave.groovy-application-conventions' id "com.github.johnrengelman.shadow" version "8.1.1" - id "io.micronaut.minimal.application" version "4.1.0" + id "io.micronaut.minimal.application" version "4.1.1" id "com.google.cloud.tools.jib" version "3.4.2" id 'org.asciidoctor.jvm.convert' version '3.3.2' } From 16d499df3da530e05110b41958e73525282112fe Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Mon, 17 Jun 2024 17:26:52 +0200 Subject: [PATCH 29/69] Fix MN redict issue with temporary hack Signed-off-by: Paolo Di Tommaso --- .../wave/controller/RegistryProxyController.groovy | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy b/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy index a687da7cd..b3c7de6d6 100644 --- a/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy @@ -304,6 +304,9 @@ class RegistryProxyController { HttpResponse .status(HttpStatus.TEMPORARY_REDIRECT) .headers(toMutableHeaders(Map.of(), override)) + // temporary workaround due to MN4 bug + // https://github.com/micronaut-projects/micronaut-core/issues/10917 + .body('') } MutableHttpResponse fromRedirectResponse(final DelegateResponse resp) { @@ -314,6 +317,9 @@ class RegistryProxyController { return HttpResponse .status(HttpStatus.valueOf(resp.statusCode)) .headers(toMutableHeaders(resp.headers, override)) + // temporary workaround due to MN4 bug + // https://github.com/micronaut-projects/micronaut-core/issues/10917 + .body('') } MutableHttpResponse fromDownloadResponse(final DelegateResponse resp, RoutePath route, Map> headers) { @@ -333,6 +339,9 @@ class RegistryProxyController { HttpResponse .status(HttpStatus.TEMPORARY_REDIRECT) .headers(toMutableHeaders(resp.headers, override)) + // temporary workaround due to MN4 bug + // https://github.com/micronaut-projects/micronaut-core/issues/10917 + .body('') } MutableHttpResponse fromStreamResponse(final DelegateResponse response, RoutePath route, Map> headers){ From 46b5209de282dff4e9e3cf668de295cb99729901 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 17 Jun 2024 17:35:45 +0200 Subject: [PATCH 30/69] bump micronaut@4.5.0 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index a51745232..cf7289ac2 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,5 +16,5 @@ # along with this program. If not, see . # -micronautVersion=4.4.3 +micronautVersion=4.5.0 micronautEnvs=dev,h2,mail,aws-ses From fbb51e4aa1dbf408ec0bf814d70b062ca82bcbcd Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 17 Jun 2024 23:46:39 +0200 Subject: [PATCH 31/69] fixed tests --- .../groovy/io.seqera.wave.java-library-conventions.gradle | 4 ++-- .../wave/service/pairing/socket/PairingWebSocket.groovy | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle index 723e8587d..dc85cc766 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle @@ -40,7 +40,7 @@ java { } dependencies { - implementation 'org.slf4j:slf4j-api:2.0.9' + implementation 'org.slf4j:slf4j-api:2.0.13' testImplementation 'ch.qos.logback:logback-core:1.4.11' testImplementation 'ch.qos.logback:logback-classic:1.4.11' @@ -48,7 +48,7 @@ dependencies { testImplementation 'org.apache.groovy:groovy-nio:4.0.15' testImplementation 'org.apache.groovy:groovy-test:4.0.15' testImplementation 'cglib:cglib-nodep:3.3.0' - testImplementation 'org.objenesis:objenesis:3.3' + testImplementation 'org.objenesis:objenesis:3.4' testImplementation ('org.spockframework:spock-core:2.3-groovy-4.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } testImplementation ('org.spockframework:spock-junit4:2.3-groovy-4.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } } diff --git a/src/main/groovy/io/seqera/wave/service/pairing/socket/PairingWebSocket.groovy b/src/main/groovy/io/seqera/wave/service/pairing/socket/PairingWebSocket.groovy index 1605e3b96..a4f7b0785 100644 --- a/src/main/groovy/io/seqera/wave/service/pairing/socket/PairingWebSocket.groovy +++ b/src/main/groovy/io/seqera/wave/service/pairing/socket/PairingWebSocket.groovy @@ -25,6 +25,8 @@ import groovy.util.logging.Slf4j import io.micronaut.context.annotation.Value import io.micronaut.core.annotation.Nullable import io.micronaut.http.client.exceptions.HttpClientResponseException +import io.micronaut.scheduling.TaskExecutors +import io.micronaut.scheduling.annotation.ExecuteOn import io.micronaut.websocket.CloseReason import io.micronaut.websocket.WebSocketSession import io.micronaut.websocket.annotation.OnClose @@ -47,6 +49,7 @@ import static io.seqera.wave.util.LongRndKey.rndHex @Slf4j @CompileStatic @Singleton +@ExecuteOn(TaskExecutors.IO) @ServerWebSocket("/pairing/{service}/token/{token}{?endpoint}") class PairingWebSocket { From 1b1493e54dbc9282aa79aad3db8c24a8f928ebbc Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 17 Jun 2024 23:48:41 +0200 Subject: [PATCH 32/69] fixed tests --- build.gradle | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index efcbf49da..54702e581 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ import java.time.OffsetDateTime import java.time.format.DateTimeFormatter plugins { - id 'java-library' + id 'io.seqera.wave.java-library-conventions' id 'io.seqera.wave.groovy-application-conventions' id "com.github.johnrengelman.shadow" version "8.1.1" id "io.micronaut.minimal.application" version "4.1.1" @@ -97,8 +97,6 @@ dependencies { implementation "io.micronaut:micronaut-management" //views implementation("io.micronaut.views:micronaut-views-handlebars") - - testImplementation('org.objenesis:objenesis:3.4') } application { From c9571424f802da1aac6932934e0ff4f5e9ed0af6 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 18 Jun 2024 10:45:57 +0200 Subject: [PATCH 33/69] fixed tests --- .../groovy/io.seqera.wave.java-library-conventions.gradle | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle index dc85cc766..89e27dc11 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle @@ -47,10 +47,9 @@ dependencies { testImplementation 'org.apache.groovy:groovy:4.0.15' testImplementation 'org.apache.groovy:groovy-nio:4.0.15' testImplementation 'org.apache.groovy:groovy-test:4.0.15' - testImplementation 'cglib:cglib-nodep:3.3.0' testImplementation 'org.objenesis:objenesis:3.4' - testImplementation ('org.spockframework:spock-core:2.3-groovy-4.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } - testImplementation ('org.spockframework:spock-junit4:2.3-groovy-4.0') { exclude group: 'org.codehaus.groovy'; exclude group: 'net.bytebuddy' } + testImplementation ('org.spockframework:spock-core:2.3-groovy-4.0') + testImplementation ('org.spockframework:spock-junit4:2.3-groovy-4.0') } tasks.withType(Test).configureEach { From 1b19d5b8cf3f8f3c66e5bd16732014c97fef478f Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 18 Jun 2024 11:09:29 +0200 Subject: [PATCH 34/69] fixed tests --- .../groovy/io.seqera.wave.java-library-conventions.gradle | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle index 89e27dc11..8a690aede 100644 --- a/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle +++ b/buildSrc/src/main/groovy/io.seqera.wave.java-library-conventions.gradle @@ -48,8 +48,9 @@ dependencies { testImplementation 'org.apache.groovy:groovy-nio:4.0.15' testImplementation 'org.apache.groovy:groovy-test:4.0.15' testImplementation 'org.objenesis:objenesis:3.4' - testImplementation ('org.spockframework:spock-core:2.3-groovy-4.0') - testImplementation ('org.spockframework:spock-junit4:2.3-groovy-4.0') + testImplementation 'net.bytebuddy:byte-buddy:1.14.17' + testImplementation 'org.spockframework:spock-core:2.3-groovy-4.0' + testImplementation 'org.spockframework:spock-junit4:2.3-groovy-4.0' } tasks.withType(Test).configureEach { From cbc81ef3046587866711c119539c57ca2f2d265b Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Mon, 1 Jul 2024 12:54:18 +0200 Subject: [PATCH 35/69] Fix failint test Signed-off-by: Paolo Di Tommaso --- .../io/seqera/wave/core/ContainerAugmenterTest.groovy | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/core/ContainerAugmenterTest.groovy b/src/test/groovy/io/seqera/wave/core/ContainerAugmenterTest.groovy index 9cc2400c9..6c0130f87 100644 --- a/src/test/groovy/io/seqera/wave/core/ContainerAugmenterTest.groovy +++ b/src/test/groovy/io/seqera/wave/core/ContainerAugmenterTest.groovy @@ -818,8 +818,8 @@ class ContainerAugmenterTest extends Specification { def 'should fetch container manifest for legacy image' () { given: def REGISTRY = 'quay.io' - def IMAGE = 'biocontainers/smina' - def TAG = '2017.11.9--0' + def IMAGE = 'biocontainers/kmerinshort' + def TAG = '1.0.1--0' def registry = lookupService.lookup(REGISTRY) def creds = credentialsProvider.getDefaultCredentials(REGISTRY) def httpClient = HttpClientFactory.neverRedirectsHttpClient() @@ -840,9 +840,9 @@ class ContainerAugmenterTest extends Specification { def spec = scanner.getContainerSpec(IMAGE, TAG, WaveDefault.ACCEPT_HEADERS) then: spec.registry == 'quay.io' - spec.imageName == 'biocontainers/smina' - spec.reference == '2017.11.9--0' - spec.digest == 'sha256:502e7be073c9ec35b996656a48e9560e05746ad6d98649c56f98af9a724875b4' + spec.imageName == 'biocontainers/kmerinshort' + spec.reference == '1.0.1--0' + spec.digest == 'sha256:056e3de6174c48a7b342c8f91541896c39d2e30a64e62d62e51ae43227c36278' and: spec.isV1() !spec.isV2() From bc6667aa186f3ae1955d7d91de73c037bd85dd6a Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Thu, 4 Jul 2024 18:48:30 +0200 Subject: [PATCH 36/69] updated dependencies Signed-off-by: munishchouhan --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 54702e581..93de6ff26 100644 --- a/build.gradle +++ b/build.gradle @@ -53,9 +53,9 @@ dependencies { implementation 'io.micronaut.reactor:micronaut-reactor' implementation 'io.micronaut.reactor:micronaut-reactor-http-client' implementation("io.seqera:tower-crypto:22.4.0-watson") { transitive = false } // to be replaced with 22.4.0 once released - implementation 'org.apache.commons:commons-compress:1.24.0' + implementation 'org.apache.commons:commons-compress:1.26.0' implementation 'org.apache.commons:commons-lang3:3.12.0' - implementation 'io.kubernetes:client-java:19.0.0' + implementation 'io.kubernetes:client-java:21.0.0' implementation 'io.kubernetes:client-java-api-fluent:18.0.1' implementation 'com.google.code.gson:gson:2.9.0' implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" From ef10122b612928b7368a87d42d4f34c7e0c3d796 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Thu, 4 Jul 2024 18:58:09 +0200 Subject: [PATCH 37/69] fix k8s errors Signed-off-by: munishchouhan --- .../wave/service/k8s/K8sServiceImpl.groovy | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy index 01d03dd98..7abb9b1f7 100644 --- a/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy @@ -188,7 +188,8 @@ class K8sServiceImpl implements K8sService { V1Job getJob(String name) { k8sClient .batchV1Api() - .readNamespacedJob(name, namespace, null) + .readNamespacedJob(name, namespace) + .execute() } /** @@ -201,7 +202,8 @@ class K8sServiceImpl implements K8sService { JobStatus getJobStatus(String name) { def job = k8sClient .batchV1Api() - .readNamespacedJob(name, namespace, null) + .readNamespacedJob(name, namespace) + .execute() if( !job ) return null if( job.status.succeeded==1 ) @@ -221,7 +223,8 @@ class K8sServiceImpl implements K8sService { V1Pod getPod(String name) { return k8sClient .coreV1Api() - .readNamespacedPod(name, namespace, null) + .readNamespacedPod(name, namespace) + .execute() } /** @@ -335,7 +338,8 @@ class K8sServiceImpl implements K8sService { final spec = buildSpec(name, containerImage, args, workDir, creds, spackConfig, nodeSelector) return k8sClient .coreV1Api() - .createNamespacedPod(namespace, spec, null, null, null,null) + .createNamespacedPod(namespace, spec) + .execute() } V1Pod buildSpec(String name, String containerImage, List args, Path workDir, Path credsFile, SpackConfig spackConfig, Map nodeSelector) { @@ -484,7 +488,7 @@ class K8sServiceImpl implements K8sService { void deletePod(String name) { k8sClient .coreV1Api() - .deleteNamespacedPod(name, namespace, (String)null, (String)null, (Integer)null, (Boolean)null, (String)null, (V1DeleteOptions)null) + .deleteNamespacedPod(name, namespace) } @Override @@ -492,7 +496,8 @@ class K8sServiceImpl implements K8sService { final spec = scanSpec(name, containerImage, args, workDir, creds, scanConfig, nodeSelector) return k8sClient .coreV1Api() - .createNamespacedPod(namespace, spec, null, null, null,null) + .createNamespacedPod(namespace, spec) + .execute() } V1Pod scanSpec(String name, String containerImage, List args, Path workDir, Path credsFile, ScanConfig scanConfig, Map nodeSelector) { @@ -551,7 +556,8 @@ class K8sServiceImpl implements K8sService { final spec = transferSpec(name, containerImage, args, blobConfig) return k8sClient .coreV1Api() - .createNamespacedPod(namespace, spec, null, null, null,null) + .createNamespacedPod(namespace, spec) + .execute() } V1Pod transferSpec(String name, String containerImage, List args, BlobCacheConfig blobConfig) { From 051911291d499d1e1e285bcdbf6e851714b9b60a Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Fri, 5 Jul 2024 12:31:36 +0200 Subject: [PATCH 38/69] Revert "updated dependencies" This reverts commit bc6667aa186f3ae1955d7d91de73c037bd85dd6a. --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 93de6ff26..54702e581 100644 --- a/build.gradle +++ b/build.gradle @@ -53,9 +53,9 @@ dependencies { implementation 'io.micronaut.reactor:micronaut-reactor' implementation 'io.micronaut.reactor:micronaut-reactor-http-client' implementation("io.seqera:tower-crypto:22.4.0-watson") { transitive = false } // to be replaced with 22.4.0 once released - implementation 'org.apache.commons:commons-compress:1.26.0' + implementation 'org.apache.commons:commons-compress:1.24.0' implementation 'org.apache.commons:commons-lang3:3.12.0' - implementation 'io.kubernetes:client-java:21.0.0' + implementation 'io.kubernetes:client-java:19.0.0' implementation 'io.kubernetes:client-java-api-fluent:18.0.1' implementation 'com.google.code.gson:gson:2.9.0' implementation "com.fasterxml.jackson.datatype:jackson-datatype-jsr310" From a8ae2cda080931dcb8fb3882e90d94c09ce041a3 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Fri, 5 Jul 2024 12:31:43 +0200 Subject: [PATCH 39/69] Revert "fix k8s errors" This reverts commit ef10122b612928b7368a87d42d4f34c7e0c3d796. --- .../wave/service/k8s/K8sServiceImpl.groovy | 20 +++++++------------ 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy index 7abb9b1f7..01d03dd98 100644 --- a/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/k8s/K8sServiceImpl.groovy @@ -188,8 +188,7 @@ class K8sServiceImpl implements K8sService { V1Job getJob(String name) { k8sClient .batchV1Api() - .readNamespacedJob(name, namespace) - .execute() + .readNamespacedJob(name, namespace, null) } /** @@ -202,8 +201,7 @@ class K8sServiceImpl implements K8sService { JobStatus getJobStatus(String name) { def job = k8sClient .batchV1Api() - .readNamespacedJob(name, namespace) - .execute() + .readNamespacedJob(name, namespace, null) if( !job ) return null if( job.status.succeeded==1 ) @@ -223,8 +221,7 @@ class K8sServiceImpl implements K8sService { V1Pod getPod(String name) { return k8sClient .coreV1Api() - .readNamespacedPod(name, namespace) - .execute() + .readNamespacedPod(name, namespace, null) } /** @@ -338,8 +335,7 @@ class K8sServiceImpl implements K8sService { final spec = buildSpec(name, containerImage, args, workDir, creds, spackConfig, nodeSelector) return k8sClient .coreV1Api() - .createNamespacedPod(namespace, spec) - .execute() + .createNamespacedPod(namespace, spec, null, null, null,null) } V1Pod buildSpec(String name, String containerImage, List args, Path workDir, Path credsFile, SpackConfig spackConfig, Map nodeSelector) { @@ -488,7 +484,7 @@ class K8sServiceImpl implements K8sService { void deletePod(String name) { k8sClient .coreV1Api() - .deleteNamespacedPod(name, namespace) + .deleteNamespacedPod(name, namespace, (String)null, (String)null, (Integer)null, (Boolean)null, (String)null, (V1DeleteOptions)null) } @Override @@ -496,8 +492,7 @@ class K8sServiceImpl implements K8sService { final spec = scanSpec(name, containerImage, args, workDir, creds, scanConfig, nodeSelector) return k8sClient .coreV1Api() - .createNamespacedPod(namespace, spec) - .execute() + .createNamespacedPod(namespace, spec, null, null, null,null) } V1Pod scanSpec(String name, String containerImage, List args, Path workDir, Path credsFile, ScanConfig scanConfig, Map nodeSelector) { @@ -556,8 +551,7 @@ class K8sServiceImpl implements K8sService { final spec = transferSpec(name, containerImage, args, blobConfig) return k8sClient .coreV1Api() - .createNamespacedPod(namespace, spec) - .execute() + .createNamespacedPod(namespace, spec, null, null, null,null) } V1Pod transferSpec(String name, String containerImage, List args, BlobCacheConfig blobConfig) { From 5beb8c039fa1a7a3d2973e3b5b549367c2be31d1 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Fri, 5 Jul 2024 12:38:34 +0200 Subject: [PATCH 40/69] updated commons-compress:1.26.0 Signed-off-by: munishchouhan --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 54702e581..638721cec 100644 --- a/build.gradle +++ b/build.gradle @@ -53,7 +53,7 @@ dependencies { implementation 'io.micronaut.reactor:micronaut-reactor' implementation 'io.micronaut.reactor:micronaut-reactor-http-client' implementation("io.seqera:tower-crypto:22.4.0-watson") { transitive = false } // to be replaced with 22.4.0 once released - implementation 'org.apache.commons:commons-compress:1.24.0' + implementation 'org.apache.commons:commons-compress:1.26.0' implementation 'org.apache.commons:commons-lang3:3.12.0' implementation 'io.kubernetes:client-java:19.0.0' implementation 'io.kubernetes:client-java-api-fluent:18.0.1' From a8d52acc88cf7af1c81c1045c56b93b231255105 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Fri, 12 Jul 2024 15:26:18 +0200 Subject: [PATCH 41/69] fixed tests Signed-off-by: munishchouhan --- .../io/seqera/wave/service/CredentialsServiceTest.groovy | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy index fa8f29162..9c20ae790 100644 --- a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy @@ -167,7 +167,7 @@ class CredentialsServiceTest extends Specification { ) and: - def identity = new PlatformId(new User(id:10), 10,"token",'tower.io', '101') + def identity = new PlatformId(new User(id:10), 11,"token",'tower.io', '101') def auth = JwtAuth.of(identity) when: @@ -220,8 +220,8 @@ class CredentialsServiceTest extends Specification { def 'should get registry creds from compute creds when not found in tower credentials'() { given: 'a tower user in a workspace on a specific instance with a valid token' - def userId = 10 - def workspaceId = 10 + def userId = 12 + def workspaceId = 12 def token = "valid-token" def towerEndpoint = "http://tower.io:9090" def workflowId = "id123" From 1a9238f2462c547dc0ae4ebab37927b8e2826cbb Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Mon, 22 Jul 2024 15:38:12 +0200 Subject: [PATCH 42/69] fixed error Signed-off-by: munishchouhan --- build.gradle | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index 1278707f9..98a7ef237 100644 --- a/build.gradle +++ b/build.gradle @@ -34,8 +34,8 @@ dependencies { compileOnly("io.micronaut:micronaut-inject-groovy") compileOnly("io.micronaut:micronaut-http-validation") implementation("jakarta.persistence:jakarta.persistence-api:3.0.0") - api 'io.seqera:lib-mail:1.0.0' - api 'io.seqera:wave-api:0.10.0' + api 'io.seqera:lib-mail:1.1.0' + api 'io.seqera:wave-api:0.11.0' api 'io.seqera:wave-utils:0.13.1' implementation("io.micronaut:micronaut-http-client") From d3896e61a4ace54aa1d673442c3064e0c07736c4 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Fri, 26 Jul 2024 16:32:31 +0200 Subject: [PATCH 43/69] Bump MN 4.5.1 Signed-off-by: Paolo Di Tommaso --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index cf7289ac2..9822542fb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,5 +16,5 @@ # along with this program. If not, see . # -micronautVersion=4.5.0 +micronautVersion=4.5.1 micronautEnvs=dev,h2,mail,aws-ses From b5a7e0c592bc2900b4179c4b6e60ab420547a3e6 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Fri, 26 Jul 2024 16:46:10 +0200 Subject: [PATCH 44/69] Remove empty body hack Signed-off-by: Paolo Di Tommaso --- .../wave/controller/RegistryProxyController.groovy | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy b/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy index b3c7de6d6..a687da7cd 100644 --- a/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/RegistryProxyController.groovy @@ -304,9 +304,6 @@ class RegistryProxyController { HttpResponse .status(HttpStatus.TEMPORARY_REDIRECT) .headers(toMutableHeaders(Map.of(), override)) - // temporary workaround due to MN4 bug - // https://github.com/micronaut-projects/micronaut-core/issues/10917 - .body('') } MutableHttpResponse fromRedirectResponse(final DelegateResponse resp) { @@ -317,9 +314,6 @@ class RegistryProxyController { return HttpResponse .status(HttpStatus.valueOf(resp.statusCode)) .headers(toMutableHeaders(resp.headers, override)) - // temporary workaround due to MN4 bug - // https://github.com/micronaut-projects/micronaut-core/issues/10917 - .body('') } MutableHttpResponse fromDownloadResponse(final DelegateResponse resp, RoutePath route, Map> headers) { @@ -339,9 +333,6 @@ class RegistryProxyController { HttpResponse .status(HttpStatus.TEMPORARY_REDIRECT) .headers(toMutableHeaders(resp.headers, override)) - // temporary workaround due to MN4 bug - // https://github.com/micronaut-projects/micronaut-core/issues/10917 - .body('') } MutableHttpResponse fromStreamResponse(final DelegateResponse response, RoutePath route, Map> headers){ From 4b305245ba8b7f95702c636cd511b95e13ce4c0e Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Tue, 3 Sep 2024 11:29:11 +0200 Subject: [PATCH 45/69] Bump Micronaut 4.6 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 9822542fb..06c283168 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,5 +16,5 @@ # along with this program. If not, see . # -micronautVersion=4.5.1 +micronautVersion=4.6.0 micronautEnvs=dev,h2,mail,aws-ses From a6d40bbd326d30fad0c50906355eee1e77e66bda Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Wed, 11 Sep 2024 11:21:43 +0200 Subject: [PATCH 46/69] Fix failing type checks Signed-off-by: Paolo Di Tommaso --- src/main/groovy/io/seqera/wave/WaveDefault.groovy | 2 +- .../seqera/wave/memstore/range/impl/RedisRangeProvider.groovy | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/WaveDefault.groovy b/src/main/groovy/io/seqera/wave/WaveDefault.groovy index c42a69187..ec8748a5a 100644 --- a/src/main/groovy/io/seqera/wave/WaveDefault.groovy +++ b/src/main/groovy/io/seqera/wave/WaveDefault.groovy @@ -41,7 +41,7 @@ interface WaveDefault { 'application/vnd.docker.distribution.manifest.list.v2+json' ) ) - final public static int[] HTTP_REDIRECT_CODES = List.of(301, 302, 303, 307, 308) + final public static List HTTP_REDIRECT_CODES = List.of(301, 302, 303, 307, 308) final public static List HTTP_SERVER_ERRORS = List.of(500, 502, 503, 504) diff --git a/src/main/groovy/io/seqera/wave/memstore/range/impl/RedisRangeProvider.groovy b/src/main/groovy/io/seqera/wave/memstore/range/impl/RedisRangeProvider.groovy index 070b12b93..22a5ede1a 100644 --- a/src/main/groovy/io/seqera/wave/memstore/range/impl/RedisRangeProvider.groovy +++ b/src/main/groovy/io/seqera/wave/memstore/range/impl/RedisRangeProvider.groovy @@ -62,7 +62,7 @@ class RedisRangeProvider implements RangeProvider { if( remove ) { final entries = conn.eval(SCRIPT, 1, key, min.toString(), max.toString(), '0', count.toString()) if( entries instanceof List ) - result.addAll(entries) + result.addAll((List) entries) } else { List found = conn.zrangeByScoreWithScores(key, min, max, 0, count) From 633f14117e353e1734d07eebb315e6718252acda Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 15:58:58 +0200 Subject: [PATCH 47/69] fixed getCacheDirectory() Signed-off-by: munishchouhan --- .../io/seqera/wave/configuration/ScanConfig.groovy | 11 ++++++++--- .../seqera/wave/service/k8s/K8sServiceImplTest.groovy | 8 -------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy index eee8e1d62..38daf9e1f 100644 --- a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy +++ b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy @@ -78,9 +78,14 @@ class ScanConfig { @Memoized Path getCacheDirectory() { - final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') - Files.createDirectories(result) - return result + try { + final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') + Files.createDirectories(result) + return result + } catch (Exception e) { + log.error("Failed to create cache directory: ${e.message}") + return null + } } String getRequestsCpu() { diff --git a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy index 5ce208064..3d31a0e6c 100644 --- a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy @@ -50,14 +50,6 @@ import io.seqera.wave.service.mirror.MirrorConfig @MicronautTest class K8sServiceImplTest extends Specification { - @Replaces(ScanConfig.class) - static class MockScanConfig extends ScanConfig { - @Override - Path getCacheDirectory() { - return Path.of('/build/scan/cache') - } - } - def 'should validate context OK ' () { when: def PROPS = [ From a88a8f977f563a99745ec048eb6eac49e0d63d2d Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 16:23:04 +0200 Subject: [PATCH 48/69] fixed tests Signed-off-by: munishchouhan --- .../io/seqera/wave/service/scan/DockerScanStrategyTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/io/seqera/wave/service/scan/DockerScanStrategyTest.groovy b/src/test/groovy/io/seqera/wave/service/scan/DockerScanStrategyTest.groovy index af9bf3c0a..439da0929 100644 --- a/src/test/groovy/io/seqera/wave/service/scan/DockerScanStrategyTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/scan/DockerScanStrategyTest.groovy @@ -56,7 +56,7 @@ class DockerScanStrategyTest extends Specification { '-v', '/some/scan/dir:/some/scan/dir:rw', '-v', - "/build/scan/cache:/root/.cache/:rw", + "$workspace/.trivy-cache:/root/.cache/:rw", '-v', '/user/test/build-workspace/config.json:/root/.docker/config.json:ro' ] From 592b727bbe182e141e970e062b8414bedeb2d562 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 16:56:12 +0200 Subject: [PATCH 49/69] reverted 633f141 Signed-off-by: munishchouhan --- .../io/seqera/wave/configuration/ScanConfig.groovy | 11 +++-------- .../seqera/wave/service/k8s/K8sServiceImplTest.groovy | 8 ++++++++ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy index 38daf9e1f..eee8e1d62 100644 --- a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy +++ b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy @@ -78,14 +78,9 @@ class ScanConfig { @Memoized Path getCacheDirectory() { - try { - final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') - Files.createDirectories(result) - return result - } catch (Exception e) { - log.error("Failed to create cache directory: ${e.message}") - return null - } + final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') + Files.createDirectories(result) + return result } String getRequestsCpu() { diff --git a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy index 3d31a0e6c..5ce208064 100644 --- a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy @@ -50,6 +50,14 @@ import io.seqera.wave.service.mirror.MirrorConfig @MicronautTest class K8sServiceImplTest extends Specification { + @Replaces(ScanConfig.class) + static class MockScanConfig extends ScanConfig { + @Override + Path getCacheDirectory() { + return Path.of('/build/scan/cache') + } + } + def 'should validate context OK ' () { when: def PROPS = [ From cf258446c40eda463c3f2c8aa92c457ddb5a7131 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 17:36:22 +0200 Subject: [PATCH 50/69] added 'wave.scan.cache.enabled' Signed-off-by: munishchouhan --- .../wave/configuration/ScanConfig.groovy | 12 +++- .../controller/ContainerControllerTest.groovy | 1 + .../service/k8s/K8sServiceImplTest.groovy | 57 +++++++++++++------ 3 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy index eee8e1d62..4e3fea445 100644 --- a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy +++ b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy @@ -72,15 +72,21 @@ class ScanConfig { @Value('${wave.scan.retry-attempts:1}') int retryAttempts + @Value('${wave.scan.cache.enabled:true}') + boolean enableCache + String getScanImage() { return scanImage } @Memoized Path getCacheDirectory() { - final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') - Files.createDirectories(result) - return result + if ( enableCache ){ + final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') + Files.createDirectories(result) + return result + } + return null } String getRequestsCpu() { diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy index 74ff3bf59..8dbf2d565 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy @@ -73,6 +73,7 @@ import jakarta.inject.Inject @Property(name='wave.build.workspace', value='/some/wsp') @Property(name='wave.build.repo', value='wave/build') @Property(name='wave.build.cache', value='wave/build/cache') +@Property(name='wave.scan.cache.enabled', value='false') class ContainerControllerTest extends Specification { @Inject diff --git a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy index 5ce208064..3d10cc0c5 100644 --- a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy @@ -38,6 +38,7 @@ import io.kubernetes.client.openapi.models.V1Pod import io.kubernetes.client.openapi.models.V1PodList import io.kubernetes.client.openapi.models.V1PodStatus import io.micronaut.context.ApplicationContext +import io.micronaut.context.annotation.Property import io.micronaut.context.annotation.Replaces import io.micronaut.test.extensions.spock.annotation.MicronautTest import io.seqera.wave.configuration.BlobCacheConfig @@ -66,7 +67,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.enabled': 'true'] + 'wave.scan.enabled': 'true', + 'wave.scan.cache.enabled': 'false'] and: def ctx = ApplicationContext.run(PROPS) ctx.getBean(K8sServiceImpl) @@ -96,7 +98,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': '/build', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -143,7 +146,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': '/build', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -171,7 +175,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': '/build', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -195,7 +200,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace' : 'my-ns', 'wave.build.k8s.configPath' : '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build'] + 'wave.build.k8s.storage.mountPath': '/build', + 'wave.scan.cache.enabled': 'false'] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -238,7 +244,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': '/build', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -285,7 +292,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': '/build', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -329,7 +337,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.k8s.labels': ['department': 'unit a','organization': 'org'] + 'wave.build.k8s.labels': ['department': 'unit a','organization': 'org'], + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -359,6 +368,7 @@ class K8sServiceImplTest extends Specification { ], 'wave.build.k8s.resources.requests.cpu': '2', 'wave.build.k8s.resources.requests.memory': '4Gi', + 'wave.scan.cache.enabled': 'false' ] as Map and: def ctx = ApplicationContext.run(PROPS) @@ -384,7 +394,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.k8s.service-account': 'theAdminAccount' + 'wave.build.k8s.service-account': 'theAdminAccount', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -406,7 +417,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build', ] + 'wave.build.k8s.storage.mountPath': '/build', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -451,7 +463,8 @@ class K8sServiceImplTest extends Specification { def PROPS = [ 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', - 'wave.build.k8s.configPath': '/home/kube.config' ] + 'wave.build.k8s.configPath': '/home/kube.config', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -487,7 +500,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.service-account': 'foo-sa', - 'wave.build.k8s.configPath': '/home/kube.config' ] + 'wave.build.k8s.configPath': '/home/kube.config', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -633,7 +647,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.retry-attempts': 3 + 'wave.build.retry-attempts': 3, + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -685,7 +700,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.retry-attempts': 3 + 'wave.build.retry-attempts': 3, + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -734,7 +750,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.k8s.service-account': 'theAdminAccount' + 'wave.build.k8s.service-account': 'theAdminAccount', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -778,7 +795,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.k8s.service-account': 'theAdminAccount' + 'wave.build.k8s.service-account': 'theAdminAccount', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -823,6 +841,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -869,7 +888,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', - 'wave.mirror.retry-attempts': 3 + 'wave.mirror.retry-attempts': 3, + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -928,7 +948,8 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', - 'wave.scan.retry-attempts': 3 + 'wave.scan.retry-attempts': 3, + 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) From 359cf86b0ae65878093f9612ecc570ddf47f5102 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 18:58:01 +0200 Subject: [PATCH 51/69] fixed tests Signed-off-by: munishchouhan --- .../io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy | 1 + 1 file changed, 1 insertion(+) diff --git a/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy b/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy index 5e79c4824..a85f9ec21 100644 --- a/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy @@ -45,6 +45,7 @@ import io.seqera.wave.util.ContainerHelper @Property(name="wave.build.k8s.storage.mountPath",value="/build") @Property(name='wave.build.k8s.node-selector[linux/amd64]',value="service=wave-build") @Property(name='wave.build.k8s.node-selector[linux/arm64]',value="service=wave-build-arm64") +@Property(name='wave.scan.cache.enabled', value='false') class KubeBuildStrategyTest extends Specification { @Inject From c049a0276dfdbefd4868e6b95183077624519a80 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 21:15:21 +0200 Subject: [PATCH 52/69] Revert "fixed tests" This reverts commit 359cf86b0ae65878093f9612ecc570ddf47f5102. --- .../io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy b/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy index a85f9ec21..5e79c4824 100644 --- a/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy @@ -45,7 +45,6 @@ import io.seqera.wave.util.ContainerHelper @Property(name="wave.build.k8s.storage.mountPath",value="/build") @Property(name='wave.build.k8s.node-selector[linux/amd64]',value="service=wave-build") @Property(name='wave.build.k8s.node-selector[linux/arm64]',value="service=wave-build-arm64") -@Property(name='wave.scan.cache.enabled', value='false') class KubeBuildStrategyTest extends Specification { @Inject From bda93245cbd2093740813d9f85e0152a19ea11fe Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 21:15:38 +0200 Subject: [PATCH 53/69] Revert "added 'wave.scan.cache.enabled'" This reverts commit cf258446c40eda463c3f2c8aa92c457ddb5a7131. --- .../wave/configuration/ScanConfig.groovy | 12 +--- .../controller/ContainerControllerTest.groovy | 1 - .../service/k8s/K8sServiceImplTest.groovy | 57 ++++++------------- 3 files changed, 21 insertions(+), 49 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy index 4e3fea445..eee8e1d62 100644 --- a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy +++ b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy @@ -72,21 +72,15 @@ class ScanConfig { @Value('${wave.scan.retry-attempts:1}') int retryAttempts - @Value('${wave.scan.cache.enabled:true}') - boolean enableCache - String getScanImage() { return scanImage } @Memoized Path getCacheDirectory() { - if ( enableCache ){ - final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') - Files.createDirectories(result) - return result - } - return null + final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') + Files.createDirectories(result) + return result } String getRequestsCpu() { diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy index 8dbf2d565..74ff3bf59 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy @@ -73,7 +73,6 @@ import jakarta.inject.Inject @Property(name='wave.build.workspace', value='/some/wsp') @Property(name='wave.build.repo', value='wave/build') @Property(name='wave.build.cache', value='wave/build/cache') -@Property(name='wave.scan.cache.enabled', value='false') class ContainerControllerTest extends Specification { @Inject diff --git a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy index 3d10cc0c5..5ce208064 100644 --- a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy @@ -38,7 +38,6 @@ import io.kubernetes.client.openapi.models.V1Pod import io.kubernetes.client.openapi.models.V1PodList import io.kubernetes.client.openapi.models.V1PodStatus import io.micronaut.context.ApplicationContext -import io.micronaut.context.annotation.Property import io.micronaut.context.annotation.Replaces import io.micronaut.test.extensions.spock.annotation.MicronautTest import io.seqera.wave.configuration.BlobCacheConfig @@ -67,8 +66,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.enabled': 'true', - 'wave.scan.cache.enabled': 'false'] + 'wave.scan.enabled': 'true'] and: def ctx = ApplicationContext.run(PROPS) ctx.getBean(K8sServiceImpl) @@ -98,8 +96,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.cache.enabled': 'false' ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -146,8 +143,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.cache.enabled': 'false' ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -175,8 +171,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.cache.enabled': 'false' ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -200,8 +195,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace' : 'my-ns', 'wave.build.k8s.configPath' : '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.cache.enabled': 'false'] + 'wave.build.k8s.storage.mountPath': '/build'] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -244,8 +238,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.cache.enabled': 'false' ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -292,8 +285,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.cache.enabled': 'false' ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -337,8 +329,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.k8s.labels': ['department': 'unit a','organization': 'org'], - 'wave.scan.cache.enabled': 'false' + 'wave.build.k8s.labels': ['department': 'unit a','organization': 'org'] ] and: def ctx = ApplicationContext.run(PROPS) @@ -368,7 +359,6 @@ class K8sServiceImplTest extends Specification { ], 'wave.build.k8s.resources.requests.cpu': '2', 'wave.build.k8s.resources.requests.memory': '4Gi', - 'wave.scan.cache.enabled': 'false' ] as Map and: def ctx = ApplicationContext.run(PROPS) @@ -394,8 +384,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.k8s.service-account': 'theAdminAccount', - 'wave.scan.cache.enabled': 'false' + 'wave.build.k8s.service-account': 'theAdminAccount' ] and: def ctx = ApplicationContext.run(PROPS) @@ -417,8 +406,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build', - 'wave.scan.cache.enabled': 'false' ] + 'wave.build.k8s.storage.mountPath': '/build', ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -463,8 +451,7 @@ class K8sServiceImplTest extends Specification { def PROPS = [ 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', - 'wave.build.k8s.configPath': '/home/kube.config', - 'wave.scan.cache.enabled': 'false' ] + 'wave.build.k8s.configPath': '/home/kube.config' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -500,8 +487,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.service-account': 'foo-sa', - 'wave.build.k8s.configPath': '/home/kube.config', - 'wave.scan.cache.enabled': 'false' ] + 'wave.build.k8s.configPath': '/home/kube.config' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -647,8 +633,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.retry-attempts': 3, - 'wave.scan.cache.enabled': 'false' + 'wave.build.retry-attempts': 3 ] and: def ctx = ApplicationContext.run(PROPS) @@ -700,8 +685,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.retry-attempts': 3, - 'wave.scan.cache.enabled': 'false' + 'wave.build.retry-attempts': 3 ] and: def ctx = ApplicationContext.run(PROPS) @@ -750,8 +734,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.k8s.service-account': 'theAdminAccount', - 'wave.scan.cache.enabled': 'false' + 'wave.build.k8s.service-account': 'theAdminAccount' ] and: def ctx = ApplicationContext.run(PROPS) @@ -795,8 +778,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', - 'wave.build.k8s.service-account': 'theAdminAccount', - 'wave.scan.cache.enabled': 'false' + 'wave.build.k8s.service-account': 'theAdminAccount' ] and: def ctx = ApplicationContext.run(PROPS) @@ -841,7 +823,6 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', - 'wave.scan.cache.enabled': 'false' ] and: def ctx = ApplicationContext.run(PROPS) @@ -888,8 +869,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', - 'wave.mirror.retry-attempts': 3, - 'wave.scan.cache.enabled': 'false' + 'wave.mirror.retry-attempts': 3 ] and: def ctx = ApplicationContext.run(PROPS) @@ -948,8 +928,7 @@ class K8sServiceImplTest extends Specification { 'wave.build.k8s.storage.claimName': 'bar', 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', - 'wave.scan.retry-attempts': 3, - 'wave.scan.cache.enabled': 'false' + 'wave.scan.retry-attempts': 3 ] and: def ctx = ApplicationContext.run(PROPS) From dd105e04284a01702eb6f7a1de3dfbea99df155d Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 22:23:58 +0200 Subject: [PATCH 54/69] fixed tests Signed-off-by: munishchouhan --- .../controller/ContainerControllerTest.groovy | 22 +++ .../service/k8s/K8sServiceImplTest.groovy | 142 +++++++++--------- 2 files changed, 96 insertions(+), 68 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy index 74ff3bf59..b539759fd 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy @@ -18,9 +18,12 @@ package io.seqera.wave.controller +import spock.lang.Shared import spock.lang.Specification import spock.lang.Unroll +import java.nio.file.Files +import java.nio.file.Path import java.time.Instant import java.time.temporal.ChronoUnit @@ -40,6 +43,7 @@ import io.seqera.wave.api.SubmitContainerTokenRequest import io.seqera.wave.api.SubmitContainerTokenResponse import io.seqera.wave.config.CondaOpts import io.seqera.wave.configuration.BuildConfig +import io.seqera.wave.configuration.ScanConfig import io.seqera.wave.core.ContainerPlatform import io.seqera.wave.core.RegistryProxyService import io.seqera.wave.exception.BadRequestException @@ -93,10 +97,28 @@ class ContainerControllerTest extends Specification { Mock(JobService) } + @MockBean(ScanConfig) + ScanConfig mockScanConfig() { + Mock(ScanConfig) { + getCacheDirectory() >> Path.of('/build/cache/dir') + } + } + def setup() { jwtAuthStore.clear() } + @Shared + Path workspace + + def setupSpec() { + workspace = Files.createTempDirectory('test') + } + + def cleanupSpec() { + workspace?.deleteDir() + } + def 'should create request data' () { given: def controller = new ContainerController(inclusionService: Mock(ContainerInclusionService)) diff --git a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy index 5ce208064..88b75fb39 100644 --- a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy @@ -18,9 +18,11 @@ package io.seqera.wave.service.k8s +import spock.lang.Shared import spock.lang.Specification import spock.lang.Unroll +import java.nio.file.Files import java.nio.file.Path import java.time.Duration import java.time.OffsetDateTime @@ -38,7 +40,6 @@ import io.kubernetes.client.openapi.models.V1Pod import io.kubernetes.client.openapi.models.V1PodList import io.kubernetes.client.openapi.models.V1PodStatus import io.micronaut.context.ApplicationContext -import io.micronaut.context.annotation.Replaces import io.micronaut.test.extensions.spock.annotation.MicronautTest import io.seqera.wave.configuration.BlobCacheConfig import io.seqera.wave.configuration.ScanConfig @@ -50,26 +51,30 @@ import io.seqera.wave.service.mirror.MirrorConfig @MicronautTest class K8sServiceImplTest extends Specification { - @Replaces(ScanConfig.class) - static class MockScanConfig extends ScanConfig { - @Override - Path getCacheDirectory() { - return Path.of('/build/scan/cache') - } + @Shared + Path workspace + + def setupSpec() { + workspace = Files.createTempDirectory('test') + } + + def cleanupSpec() { + workspace?.deleteDir() } def 'should validate context OK ' () { when: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.scan.enabled': 'true'] and: def ctx = ApplicationContext.run(PROPS) ctx.getBean(K8sServiceImpl) + then: noExceptionThrown() and: @@ -92,11 +97,11 @@ class K8sServiceImplTest extends Specification { def 'should get mount path' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': workspace.toString() ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -139,11 +144,11 @@ class K8sServiceImplTest extends Specification { def 'should create build vol' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': workspace.toString() ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -167,11 +172,11 @@ class K8sServiceImplTest extends Specification { def 'should get docker config vol' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': workspace.toString() ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -191,17 +196,17 @@ class K8sServiceImplTest extends Specification { def 'should create build pod for buildkit' () { given: def PROPS = [ - 'wave.build.workspace' : '/build/work', + 'wave.build.workspace' : workspace.toString(), 'wave.build.k8s.namespace' : 'my-ns', 'wave.build.k8s.configPath' : '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build'] + 'wave.build.k8s.storage.mountPath': workspace.toString()] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) when: - def result = k8sService.buildSpec('foo', 'my-image:latest', ['this', 'that'], Path.of('/build/work/xyz'), Path.of('/build/work/xyz/config.json'), Duration.ofSeconds(10), [:]) + def result = k8sService.buildSpec('foo', 'my-image:latest', ['this', 'that'], workspace.resolve('work/xyz'), workspace.resolve('work/xyz/config.json'), Duration.ofSeconds(10), [:]) then: result.metadata.name == 'foo' result.metadata.namespace == 'my-ns' @@ -218,9 +223,9 @@ class K8sServiceImplTest extends Specification { volumeMounts.size() == 2 volumeMounts.get(0).name == 'build-data' volumeMounts.get(0).mountPath == '/home/user/.docker/config.json' - volumeMounts.get(0).subPath == 'work/xyz/config.json' + volumeMounts.get(0).subPath == "work/xyz/config.json" volumeMounts.get(1).name == 'build-data' - volumeMounts.get(1).mountPath == '/build/work/xyz' + volumeMounts.get(1).mountPath == "${workspace.toString()}/work/xyz" volumeMounts.get(1).subPath == 'work/xyz' } and: @@ -234,15 +239,16 @@ class K8sServiceImplTest extends Specification { def 'should create build pod for singularity' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': workspace.toString() ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) - def workDir = Path.of('/build/work/xyz') + def workDir = workspace.resolve('work/xyz') + when: def result = k8sService.buildSpec('foo', 'singularity:latest', ['this','that'], workDir, workDir.resolve('config.json'), Duration.ofSeconds(10), [:]) then: @@ -265,7 +271,7 @@ class K8sServiceImplTest extends Specification { volumeMounts.get(1).mountPath == '/root/.singularity/remote.yaml' volumeMounts.get(1).subPath == 'work/xyz/singularity-remote.yaml' volumeMounts.get(2).name == 'build-data' - volumeMounts.get(2).mountPath == '/build/work/xyz' + volumeMounts.get(2).mountPath == "${workspace.toString()}/work/xyz" volumeMounts.get(2).subPath == 'work/xyz' getWorkingDir() == null getSecurityContext().privileged @@ -281,17 +287,17 @@ class K8sServiceImplTest extends Specification { def 'should create build pod without init container' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build' ] + 'wave.build.k8s.storage.mountPath': workspace.toString() ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) when: - def result = k8sService.buildSpec('foo', 'my-image:latest', ['this','that'], Path.of('/build/work/xyz'), null, Duration.ofSeconds(10), [:]) + def result = k8sService.buildSpec('foo', 'my-image:latest', ['this','that'], workspace.resolve('work/xyz'), null, Duration.ofSeconds(10), [:]) then: result.metadata.name == 'foo' @@ -309,7 +315,7 @@ class K8sServiceImplTest extends Specification { env.value == ['--oci-worker-no-process-sandbox'] volumeMounts.size() == 1 volumeMounts.get(0).name == 'build-data' - volumeMounts.get(0).mountPath == '/build/work/xyz' + volumeMounts.get(0).mountPath == "${workspace.toString()}/work/xyz" volumeMounts.get(0).subPath == 'work/xyz' } and: @@ -324,11 +330,11 @@ class K8sServiceImplTest extends Specification { def 'should add labels ' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.k8s.labels': ['department': 'unit a','organization': 'org'] ] and: @@ -348,11 +354,11 @@ class K8sServiceImplTest extends Specification { def 'should add nodeselector' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.k8s.node-selector': [ 'linux/amd64': 'service=wave-build', 'linux/arm64': 'service=wave-build-arm64' @@ -379,11 +385,11 @@ class K8sServiceImplTest extends Specification { def 'should add serviceAccount' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.k8s.service-account': 'theAdminAccount' ] and: @@ -402,21 +408,21 @@ class K8sServiceImplTest extends Specification { def 'should create scan pod' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build', ] + 'wave.build.k8s.storage.mountPath': workspace.toString() ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) def config = Mock(ScanConfig) { - getCacheDirectory() >> Path.of('/build/work/.trivy') + getCacheDirectory() >> workspace.resolve('work/.trivy') getTimeout() >> Duration.ofSeconds(10) } when: - def result = k8sService.scanSpec('foo', 'my-image:latest', ['this','that'], Path.of('/build/work/xyz'), Path.of('/build/work/xyz/config.json'), config, null ) + def result = k8sService.scanSpec('foo', 'my-image:latest', ['this','that'], workspace.resolve('work/xyz'), workspace.resolve('work/xyz/config.json'), config, null ) then: result.metadata.name == 'foo' result.metadata.namespace == 'my-ns' @@ -432,7 +438,7 @@ class K8sServiceImplTest extends Specification { volumeMounts.get(0).mountPath == '/root/.docker/config.json' volumeMounts.get(0).subPath == 'work/xyz/config.json' volumeMounts.get(1).name == 'build-data' - volumeMounts.get(1).mountPath == '/build/work/xyz' + volumeMounts.get(1).mountPath == "${workspace.toString()}/work/xyz" volumeMounts.get(1).subPath == 'work/xyz' volumeMounts.get(2).name == 'build-data' volumeMounts.get(2).mountPath == '/root/.cache/' @@ -449,7 +455,7 @@ class K8sServiceImplTest extends Specification { def 'should create transfer job spec with defaults' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config' ] and: @@ -484,7 +490,7 @@ class K8sServiceImplTest extends Specification { def 'should create transfer job spec with custom settings' () { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.service-account': 'foo-sa', 'wave.build.k8s.configPath': '/home/kube.config' ] @@ -628,11 +634,11 @@ class K8sServiceImplTest extends Specification { def 'buildJobSpec should create job with singularity image'() { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.retry-attempts': 3 ] and: @@ -641,7 +647,7 @@ class K8sServiceImplTest extends Specification { def name = 'the-job-name' def containerImage = 'singularity:latest' def args = ['singularity', '--this', '--that'] - def workDir = Path.of('/build/work/xyz') + def workDir = workspace.resolve('work/xyz') def credsFile = workDir.resolve('config.json') def timeout = Duration.ofMinutes(10) def nodeSelector = [key: 'value'] @@ -667,7 +673,7 @@ class K8sServiceImplTest extends Specification { job.spec.template.spec.containers.get(0).volumeMounts.get(1).subPath == 'work/xyz/singularity-remote.yaml' and: job.spec.template.spec.containers.get(0).volumeMounts.get(2).name == 'build-data' - job.spec.template.spec.containers.get(0).volumeMounts.get(2).mountPath == '/build/work/xyz' + job.spec.template.spec.containers.get(0).volumeMounts.get(2).mountPath == "${workspace.toString()}/work/xyz" job.spec.template.spec.containers.get(0).volumeMounts.get(2).subPath == 'work/xyz' and: job.spec.template.spec.volumes.get(0).name == 'build-data' @@ -680,11 +686,11 @@ class K8sServiceImplTest extends Specification { def 'buildJobSpec should create job with docker image'() { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.retry-attempts': 3 ] and: @@ -693,7 +699,7 @@ class K8sServiceImplTest extends Specification { def name = 'test-job' def containerImage = 'docker://test-image' def args = ['arg1', 'arg2'] - def workDir = Path.of('/build/work/xyz') + def workDir = workspace.resolve('work/xyz') def credsFile = workDir.resolve('config.json') def timeout = Duration.ofMinutes(10) def nodeSelector = [key: 'value'] @@ -716,7 +722,7 @@ class K8sServiceImplTest extends Specification { job.spec.template.spec.containers.get(0).volumeMounts.get(0).subPath == 'work/xyz/config.json' and: job.spec.template.spec.containers.get(0).volumeMounts.get(1).name == 'build-data' - job.spec.template.spec.containers.get(0).volumeMounts.get(1).mountPath == '/build/work/xyz' + job.spec.template.spec.containers.get(0).volumeMounts.get(1).mountPath == "$workspace/work/xyz" job.spec.template.spec.containers.get(0).volumeMounts.get(1).subPath == 'work/xyz' and: job.spec.template.spec.volumes.get(0).name == 'build-data' @@ -729,11 +735,11 @@ class K8sServiceImplTest extends Specification { def 'should create scan job spec with valid inputs'() { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.k8s.service-account': 'theAdminAccount' ] and: @@ -742,10 +748,10 @@ class K8sServiceImplTest extends Specification { def name = 'scan-job' def containerImage = 'scan-image:latest' def args = ['arg1', 'arg2'] - def workDir = Path.of('/work/dir') + def workDir = workspace.resolve('work/dir') def credsFile = Path.of('/creds/file') def scanConfig = Mock(ScanConfig) { - getCacheDirectory() >> Path.of('/build/cache/dir') + getCacheDirectory() >> workspace.resolve('cache/dir') getRequestsCpu() >> '2' getRequestsMemory() >> '4Gi' } @@ -773,11 +779,11 @@ class K8sServiceImplTest extends Specification { def 'should create scan job spec without creds file'() { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.k8s.service-account': 'theAdminAccount' ] and: @@ -789,7 +795,7 @@ class K8sServiceImplTest extends Specification { def workDir = Path.of('/work/dir') def credsFile = null def scanConfig = Mock(ScanConfig) { - getCacheDirectory() >> Path.of('/build/cache/dir') + getCacheDirectory() >> workspace.resolve('cache/dir') getRequestsCpu() >> '2' getRequestsMemory() >> '4Gi' } @@ -817,11 +823,11 @@ class K8sServiceImplTest extends Specification { def 'should create scan job spec without node selector'() { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.k8s.service-account': 'theAdminAccount', ] and: @@ -833,7 +839,7 @@ class K8sServiceImplTest extends Specification { def workDir = Path.of('/work/dir') def credsFile = Path.of('/creds/file') def scanConfig = Mock(ScanConfig) { - getCacheDirectory() >> Path.of('/build/cache/dir') + getCacheDirectory() >> workspace.resolve('cache/dir') getRequestsCpu() >> '2' getRequestsMemory() >> '4Gi' getRetryAttempts() >> 3 @@ -863,11 +869,11 @@ class K8sServiceImplTest extends Specification { def 'should create mirror job spec'() { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.k8s.service-account': 'theAdminAccount', 'wave.mirror.retry-attempts': 3 ] @@ -877,8 +883,8 @@ class K8sServiceImplTest extends Specification { def name = 'scan-job' def containerImage = 'scan-image:latest' def args = ['arg1', 'arg2'] - def workDir = Path.of('/build/work/dir') - def credsFile = Path.of('/build/work/dir/creds/file') + def workDir = workspace.resolve('work/dir') + def credsFile = workspace.resolve('work/dir/creds/file') def mirrorConfig = Mock(MirrorConfig) { getRequestsCpu() >> null getRequestsMemory() >> null @@ -906,7 +912,7 @@ class K8sServiceImplTest extends Specification { } and: with(job.spec.template.spec.containers[0].volumeMounts[1]) { - mountPath == '/build/work/dir' + mountPath == "$workspace/work/dir" readOnly == true subPath == 'work/dir' } @@ -922,11 +928,11 @@ class K8sServiceImplTest extends Specification { def 'should create scan job spec without resource requests'() { given: def PROPS = [ - 'wave.build.workspace': '/build/work', + 'wave.build.workspace': workspace.toString(), 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': '/build', + 'wave.build.k8s.storage.mountPath': workspace.toString(), 'wave.build.k8s.service-account': 'theAdminAccount', 'wave.scan.retry-attempts': 3 ] @@ -936,10 +942,10 @@ class K8sServiceImplTest extends Specification { def name = 'scan-job' def containerImage = 'scan-image:latest' def args = ['arg1', 'arg2'] - def workDir = Path.of('/work/dir') + def workDir = workspace.resolve('work/dir') def credsFile = Path.of('/creds/file') def scanConfig = Mock(ScanConfig) { - getCacheDirectory() >> Path.of('/build/cache/dir') + getCacheDirectory() >> workspace.resolve('cache/dir') getRequestsCpu() >> null getRequestsMemory() >> null getRetryAttempts() >> 3 From b59fca22f61a4395482baa5f13acf8c34640d696 Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Tue, 24 Sep 2024 22:28:58 +0200 Subject: [PATCH 55/69] fixed tests Signed-off-by: munishchouhan --- .../wave/controller/ContainerControllerTest.groovy | 13 ------------- .../service/builder/KubeBuildStrategyTest.groovy | 8 ++++++++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy index b539759fd..9db7cffb6 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy @@ -18,11 +18,9 @@ package io.seqera.wave.controller -import spock.lang.Shared import spock.lang.Specification import spock.lang.Unroll -import java.nio.file.Files import java.nio.file.Path import java.time.Instant import java.time.temporal.ChronoUnit @@ -108,17 +106,6 @@ class ContainerControllerTest extends Specification { jwtAuthStore.clear() } - @Shared - Path workspace - - def setupSpec() { - workspace = Files.createTempDirectory('test') - } - - def cleanupSpec() { - workspace?.deleteDir() - } - def 'should create request data' () { given: def controller = new ContainerController(inclusionService: Mock(ContainerInclusionService)) diff --git a/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy b/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy index 5e79c4824..6618fe4d0 100644 --- a/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/builder/KubeBuildStrategyTest.groovy @@ -21,11 +21,13 @@ package io.seqera.wave.service.builder import spock.lang.Specification import java.nio.file.Files +import java.nio.file.Path import java.time.Duration import io.micronaut.context.annotation.Property import io.micronaut.test.annotation.MockBean import io.micronaut.test.extensions.spock.annotation.MicronautTest +import io.seqera.wave.configuration.ScanConfig import io.seqera.wave.core.ContainerPlatform import io.seqera.wave.service.k8s.K8sService import io.seqera.wave.service.k8s.K8sServiceImpl @@ -58,6 +60,12 @@ class KubeBuildStrategyTest extends Specification { Mock(K8sService) } + @MockBean(ScanConfig) + ScanConfig mockScanConfig() { + Mock(ScanConfig) { + getCacheDirectory() >> Path.of('/build/cache/dir') + } + } def "request to build a container with right selector"(){ given: From 23f33237cc60c711b697b094f27f0525b67bb31a Mon Sep 17 00:00:00 2001 From: munishchouhan Date: Wed, 2 Oct 2024 16:26:53 +0200 Subject: [PATCH 56/69] fixed tests Signed-off-by: munishchouhan --- .../groovy/io/seqera/wave/controller/InspectController.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/groovy/io/seqera/wave/controller/InspectController.groovy b/src/main/groovy/io/seqera/wave/controller/InspectController.groovy index 6a413c3ca..da4a17116 100644 --- a/src/main/groovy/io/seqera/wave/controller/InspectController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/InspectController.groovy @@ -71,7 +71,7 @@ class InspectController { private String serverUrl @Post("/v1alpha1/inspect") - CompletableFuture> inspect(ContainerInspectRequest req, @Nullable @QueryValue String platform) { + CompletableFuture> inspect(@Body ContainerInspectRequest req, @Nullable @QueryValue String platform) { if( !req.containerImage ) throw new BadRequestException("Missing 'containerImage' attribute") From b56e04f299f5328dce6aabfb67837af485eeed9e Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 12:02:32 +0100 Subject: [PATCH 57/69] Update src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy [ci skip] --- .../groovy/io/seqera/wave/controller/BuildControllerTest.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy index a1539255f..7d6652fcd 100644 --- a/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/BuildControllerTest.groovy @@ -122,7 +122,6 @@ class BuildControllerTest extends Specification { res.body() == LOGS } - def 'should get container status' () { given: def build1 = new WaveBuildRecord( From fd70ad1ac0cd8d68bc82cdc8181e7876545a3c8c Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 12:04:01 +0100 Subject: [PATCH 58/69] Bump MN 4.6.3 --- gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle.properties b/gradle.properties index 06c283168..54b62b375 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,5 +16,5 @@ # along with this program. If not, see . # -micronautVersion=4.6.0 +micronautVersion=4.6.3 micronautEnvs=dev,h2,mail,aws-ses From 318f589538ffa809fe9299ce31ce68293dd17727 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 12:12:09 +0100 Subject: [PATCH 59/69] Minor changes Signed-off-by: Paolo Di Tommaso --- .../io/seqera/wave/controller/InspectController.groovy | 1 + .../wave/service/account/AccountServiceImpl.groovy | 1 - .../wave/controller/RegistryControllerLocalTest.groovy | 10 +++++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/controller/InspectController.groovy b/src/main/groovy/io/seqera/wave/controller/InspectController.groovy index da4a17116..35e50bc58 100644 --- a/src/main/groovy/io/seqera/wave/controller/InspectController.groovy +++ b/src/main/groovy/io/seqera/wave/controller/InspectController.groovy @@ -72,6 +72,7 @@ class InspectController { @Post("/v1alpha1/inspect") CompletableFuture> inspect(@Body ContainerInspectRequest req, @Nullable @QueryValue String platform) { + if( !req.containerImage ) throw new BadRequestException("Missing 'containerImage' attribute") diff --git a/src/main/groovy/io/seqera/wave/service/account/AccountServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/account/AccountServiceImpl.groovy index ec1b8df3f..f8d6bb4f1 100644 --- a/src/main/groovy/io/seqera/wave/service/account/AccountServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/account/AccountServiceImpl.groovy @@ -45,7 +45,6 @@ class AccountServiceImpl implements AccountService { @Override boolean isAuthorised(String username, String password) { - log.info("accounts: $accounts") if( !username || !password ) return false if( !accounts.containsKey(username) ) diff --git a/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy b/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy index f582a1f14..bde48c21f 100644 --- a/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy @@ -149,18 +149,18 @@ class RegistryControllerLocalTest extends Specification implements DockerRegistr when: def parsedBody = new JsonSlurper().parseText(response.body.get()) - + and: def list = parsedBody.manifests.collect { String type = it.mediaType.contains("manifest") ? "manifests" : "blobs" "/v2/$IMAGE/$type/$it.digest" } - - boolean fails = list.find { url -> - HttpRequest requestGet = HttpRequest.GET(url).headers { h -> + and: + boolean fails = list.find{ url -> + HttpRequest requestGet = HttpRequest.GET(url).headers({ h -> accept.each { h.add('Accept', it) } - } + }) HttpResponse responseGet = client.toBlocking().exchange(requestGet, String) responseGet.status() != HttpStatus.OK } From 45f3c89a518898232d4e51a78f801af8776d7d63 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 13:42:40 +0100 Subject: [PATCH 60/69] Cleanup tests Signed-off-by: Paolo Di Tommaso --- .../wave/controller/ContainerControllerTest.groovy | 10 ---------- .../wave/controller/RegistryControllerLocalTest.groovy | 6 +++--- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy index 7f154d374..d582316b8 100644 --- a/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/ContainerControllerTest.groovy @@ -21,7 +21,6 @@ package io.seqera.wave.controller import spock.lang.Specification import spock.lang.Unroll -import java.nio.file.Path import java.time.Instant import java.time.temporal.ChronoUnit @@ -42,7 +41,6 @@ import io.seqera.wave.api.SubmitContainerTokenRequest import io.seqera.wave.api.SubmitContainerTokenResponse import io.seqera.wave.config.CondaOpts import io.seqera.wave.configuration.BuildConfig -import io.seqera.wave.configuration.ScanConfig import io.seqera.wave.core.ContainerPlatform import io.seqera.wave.core.RegistryProxyService import io.seqera.wave.exception.BadRequestException @@ -74,7 +72,6 @@ import jakarta.inject.Inject * @author Paolo Di Tommaso */ @MicronautTest -@Property(name='wave.build.workspace', value='/some/wsp') @Property(name='wave.build.repo', value='wave/build') @Property(name='wave.build.cache', value='wave/build/cache') class ContainerControllerTest extends Specification { @@ -103,13 +100,6 @@ class ContainerControllerTest extends Specification { Mock(JobService) } - @MockBean(ScanConfig) - ScanConfig mockScanConfig() { - Mock(ScanConfig) { - getCacheDirectory() >> Path.of('/build/cache/dir') - } - } - @MockBean(RegistryProxyService) RegistryProxyService mockProxy() { Mock(RegistryProxyService) { diff --git a/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy b/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy index bde48c21f..9057ac53e 100644 --- a/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy +++ b/src/test/groovy/io/seqera/wave/controller/RegistryControllerLocalTest.groovy @@ -142,17 +142,17 @@ class RegistryControllerLocalTest extends Specification implements DockerRegistr h.add('Accept', it) } }) - HttpResponse response = client.toBlocking().exchange(request, String) + HttpResponse response = client.toBlocking().exchange(request, String) then: response.status() == HttpStatus.OK when: - def parsedBody = new JsonSlurper().parseText(response.body.get()) + def parsedBody = new JsonSlurper().parseText(response.body.get()) as Map and: def list = parsedBody.manifests.collect { String type = it.mediaType.contains("manifest") ? "manifests" : "blobs" - "/v2/$IMAGE/$type/$it.digest" + return "/v2/$IMAGE/$type/$it.digest" as String } and: boolean fails = list.find{ url -> From d9b9bf0a2c4c52c6fc44b3645b7867fdfa99a0a7 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 14:18:42 +0100 Subject: [PATCH 61/69] Fix tests Signed-off-by: Paolo Di Tommaso --- .../wave/configuration/ScanConfig.groovy | 6 ++--- .../scan/ContainerScanServiceImpl.groovy | 11 ++++++++++ .../builder/KubeBuildStrategyTest.groovy | 10 --------- .../scan/DockerScanStrategyTest.groovy | 22 ++++++++----------- 4 files changed, 22 insertions(+), 27 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy index baef40d75..1a3d5a285 100644 --- a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy +++ b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy @@ -18,7 +18,7 @@ package io.seqera.wave.configuration -import java.nio.file.Files + import java.nio.file.Path import java.time.Duration import javax.annotation.PostConstruct @@ -94,9 +94,7 @@ class ScanConfig { @Memoized Path getCacheDirectory() { - final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') - Files.createDirectories(result) - return result + return Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') } @Memoized diff --git a/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy index d0e3d7511..5a8432e13 100644 --- a/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy @@ -18,10 +18,12 @@ package io.seqera.wave.service.scan +import java.nio.file.Files import java.nio.file.NoSuchFileException import java.time.Instant import java.util.concurrent.CompletableFuture import java.util.concurrent.ExecutorService +import javax.annotation.PostConstruct import groovy.transform.CompileStatic import groovy.util.logging.Slf4j @@ -90,6 +92,15 @@ class ContainerScanServiceImpl implements ContainerScanService, JobHandler */ @MicronautTest -@Property(name="wave.build.workspace",value="/build/work") @Property(name="wave.build.k8s.namespace",value="foo") @Property(name="wave.build.k8s.configPath",value="/home/kube.config") @Property(name="wave.build.k8s.storage.claimName",value="bar") -@Property(name="wave.build.k8s.storage.mountPath",value="/build") @Property(name='wave.build.k8s.node-selector[linux/amd64]',value="service=wave-build") @Property(name='wave.build.k8s.node-selector[linux/arm64]',value="service=wave-build-arm64") class KubeBuildStrategyTest extends Specification { @@ -60,12 +56,6 @@ class KubeBuildStrategyTest extends Specification { Mock(K8sService) } - @MockBean(ScanConfig) - ScanConfig mockScanConfig() { - Mock(ScanConfig) { - getCacheDirectory() >> Path.of('/build/cache/dir') - } - } def "request to build a container with right selector"(){ given: diff --git a/src/test/groovy/io/seqera/wave/service/scan/DockerScanStrategyTest.groovy b/src/test/groovy/io/seqera/wave/service/scan/DockerScanStrategyTest.groovy index bd21291c8..021f80af4 100644 --- a/src/test/groovy/io/seqera/wave/service/scan/DockerScanStrategyTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/scan/DockerScanStrategyTest.groovy @@ -20,24 +20,23 @@ package io.seqera.wave.service.scan import spock.lang.Specification -import java.nio.file.Files import java.nio.file.Path -import io.micronaut.context.ApplicationContext +import io.micronaut.context.annotation.Property +import io.micronaut.test.extensions.spock.annotation.MicronautTest +import jakarta.inject.Inject /** * * @author Munish Chouhan */ +@MicronautTest +@Property(name="wave.build.workspace",value="/some/build/dir") class DockerScanStrategyTest extends Specification { + @Inject + DockerScanStrategy dockerContainerStrategy + def 'should get docker command' () { - given: - def workspace = Files.createTempDirectory('test') - def props = ['wave.build.workspace': workspace.toString()] - and: - def ctx = ApplicationContext.run(props) - and: - def dockerContainerStrategy = ctx.getBean(DockerScanStrategy) when: def scanDir = Path.of('/some/scan/dir') @@ -56,7 +55,7 @@ class DockerScanStrategyTest extends Specification { '-v', '/some/scan/dir:/some/scan/dir:rw', '-v', - "$workspace/.trivy-cache:/root/.cache/:rw", + '/some/build/dir/.trivy-cache:/root/.cache/:rw', '-v', '/user/test/build-workspace/config.json:/root/.docker/config.json:ro', '-e', @@ -65,8 +64,5 @@ class DockerScanStrategyTest extends Specification { 'BAR=2' ] - cleanup: - ctx.close() - workspace?.deleteDir() } } From cfa4e23a8bfd73ad33b794c12e65597d96a5b7c6 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 14:23:54 +0100 Subject: [PATCH 62/69] Fix tests Signed-off-by: Paolo Di Tommaso --- .../io/seqera/wave/configuration/ScanConfig.groovy | 10 ++++++++-- .../service/scan/ContainerScanServiceImpl.groovy | 12 +----------- .../wave/service/scan/DockerScanStrategyTest.groovy | 13 ++++++++++--- 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy index 1a3d5a285..5a5ac6006 100644 --- a/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy +++ b/src/main/groovy/io/seqera/wave/configuration/ScanConfig.groovy @@ -18,7 +18,7 @@ package io.seqera.wave.configuration - +import java.nio.file.Files import java.nio.file.Path import java.time.Duration import javax.annotation.PostConstruct @@ -94,7 +94,13 @@ class ScanConfig { @Memoized Path getCacheDirectory() { - return Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') + final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache') + try { + Files.createDirectories(result) + } catch (IOException e) { + log.error "Unable to create scan cache directory=${result} - cause: ${e.message}" + } + return result } @Memoized diff --git a/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy index 5a8432e13..ff313413b 100644 --- a/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy @@ -18,12 +18,11 @@ package io.seqera.wave.service.scan -import java.nio.file.Files + import java.nio.file.NoSuchFileException import java.time.Instant import java.util.concurrent.CompletableFuture import java.util.concurrent.ExecutorService -import javax.annotation.PostConstruct import groovy.transform.CompileStatic import groovy.util.logging.Slf4j @@ -92,15 +91,6 @@ class ContainerScanServiceImpl implements ContainerScanService, JobHandler */ @MicronautTest -@Property(name="wave.build.workspace",value="/some/build/dir") class DockerScanStrategyTest extends Specification { @Inject DockerScanStrategy dockerContainerStrategy + @MockBean(ScanConfig) + ScanConfig mockConfig() { + Mock(ScanConfig) { + getCacheDirectory() >> Path.of('/some/scan/cache') + } + } + def 'should get docker command' () { when: @@ -55,7 +62,7 @@ class DockerScanStrategyTest extends Specification { '-v', '/some/scan/dir:/some/scan/dir:rw', '-v', - '/some/build/dir/.trivy-cache:/root/.cache/:rw', + '/some/scan/cache:/root/.cache/:rw', '-v', '/user/test/build-workspace/config.json:/root/.docker/config.json:ro', '-e', From 2e5fb96a8e037b40430ab2d695051e8729963fcf Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 14:35:19 +0100 Subject: [PATCH 63/69] Improve tests Signed-off-by: Paolo Di Tommaso --- .../io/seqera/wave/service/CredentialsServiceTest.groovy | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy index 9c20ae790..5a3c4bbaa 100644 --- a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy @@ -166,8 +166,7 @@ class CredentialsServiceTest extends Specification { registry: 'docker.io' ) and: - - def identity = new PlatformId(new User(id:10), 11,"token",'tower.io', '101') + def identity = new PlatformId(new User(id:10), 100,"token",'tower.io', '101') def auth = JwtAuth.of(identity) when: @@ -183,7 +182,7 @@ class CredentialsServiceTest extends Specification { ) and: 'non matching credentials are listed' - 1 * towerClient.listCredentials('tower.io',auth,11) >> CompletableFuture.completedFuture(new ListCredentialsResponse( + 1 * towerClient.listCredentials('tower.io',auth,100) >> CompletableFuture.completedFuture(new ListCredentialsResponse( credentials: [nonContainerRegistryCredentials,otherRegistryCredentials] )) @@ -220,8 +219,8 @@ class CredentialsServiceTest extends Specification { def 'should get registry creds from compute creds when not found in tower credentials'() { given: 'a tower user in a workspace on a specific instance with a valid token' - def userId = 12 - def workspaceId = 12 + def userId = 10 + def workspaceId = 100 def token = "valid-token" def towerEndpoint = "http://tower.io:9090" def workflowId = "id123" From f2ca95d94aa6bdf0d7c57da29f888419766020c7 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 14:43:03 +0100 Subject: [PATCH 64/69] Improve tests Signed-off-by: Paolo Di Tommaso --- .../service/k8s/K8sServiceImplTest.groovy | 141 ++++++++---------- 1 file changed, 62 insertions(+), 79 deletions(-) diff --git a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy index e0dd8e580..626f82679 100644 --- a/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/k8s/K8sServiceImplTest.groovy @@ -18,11 +18,9 @@ package io.seqera.wave.service.k8s -import spock.lang.Shared import spock.lang.Specification import spock.lang.Unroll -import java.nio.file.Files import java.nio.file.Path import java.time.Duration import java.time.OffsetDateTime @@ -40,41 +38,27 @@ import io.kubernetes.client.openapi.models.V1Pod import io.kubernetes.client.openapi.models.V1PodList import io.kubernetes.client.openapi.models.V1PodStatus import io.micronaut.context.ApplicationContext -import io.micronaut.test.extensions.spock.annotation.MicronautTest import io.seqera.wave.configuration.BlobCacheConfig -import io.seqera.wave.configuration.ScanConfig import io.seqera.wave.configuration.MirrorConfig +import io.seqera.wave.configuration.ScanConfig /** * * @author Paolo Di Tommaso */ -@MicronautTest class K8sServiceImplTest extends Specification { - @Shared - Path workspace - - def setupSpec() { - workspace = Files.createTempDirectory('test') - } - - def cleanupSpec() { - workspace?.deleteDir() - } - def 'should validate context OK ' () { when: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.scan.enabled': 'true'] and: def ctx = ApplicationContext.run(PROPS) ctx.getBean(K8sServiceImpl) - then: noExceptionThrown() and: @@ -97,11 +81,11 @@ class K8sServiceImplTest extends Specification { def 'should get mount path' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString() ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -144,11 +128,11 @@ class K8sServiceImplTest extends Specification { def 'should create build vol' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString() ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -172,11 +156,11 @@ class K8sServiceImplTest extends Specification { def 'should get docker config vol' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString() ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) @@ -196,17 +180,17 @@ class K8sServiceImplTest extends Specification { def 'should create build pod for buildkit' () { given: def PROPS = [ - 'wave.build.workspace' : workspace.toString(), + 'wave.build.workspace' : '/build/work', 'wave.build.k8s.namespace' : 'my-ns', 'wave.build.k8s.configPath' : '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': workspace.toString()] + 'wave.build.k8s.storage.mountPath': '/build'] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) when: - def result = k8sService.buildSpec('foo', 'my-image:latest', ['this', 'that'], workspace.resolve('work/xyz'), workspace.resolve('work/xyz/config.json'), Duration.ofSeconds(10), [:]) + def result = k8sService.buildSpec('foo', 'my-image:latest', ['this', 'that'], Path.of('/build/work/xyz'), Path.of('/build/work/xyz/config.json'), Duration.ofSeconds(10), [:]) then: result.metadata.name == 'foo' result.metadata.namespace == 'my-ns' @@ -223,9 +207,9 @@ class K8sServiceImplTest extends Specification { volumeMounts.size() == 2 volumeMounts.get(0).name == 'build-data' volumeMounts.get(0).mountPath == '/home/user/.docker/config.json' - volumeMounts.get(0).subPath == "work/xyz/config.json" + volumeMounts.get(0).subPath == 'work/xyz/config.json' volumeMounts.get(1).name == 'build-data' - volumeMounts.get(1).mountPath == "${workspace.toString()}/work/xyz" + volumeMounts.get(1).mountPath == '/build/work/xyz' volumeMounts.get(1).subPath == 'work/xyz' } and: @@ -239,16 +223,15 @@ class K8sServiceImplTest extends Specification { def 'should create build pod for singularity' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': workspace.toString() ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) - def workDir = workspace.resolve('work/xyz') - + def workDir = Path.of('/build/work/xyz') when: def result = k8sService.buildSpec('foo', 'singularity:latest', ['this','that'], workDir, workDir.resolve('config.json'), Duration.ofSeconds(10), [:]) then: @@ -271,7 +254,7 @@ class K8sServiceImplTest extends Specification { volumeMounts.get(1).mountPath == '/root/.singularity/remote.yaml' volumeMounts.get(1).subPath == 'work/xyz/singularity-remote.yaml' volumeMounts.get(2).name == 'build-data' - volumeMounts.get(2).mountPath == "${workspace.toString()}/work/xyz" + volumeMounts.get(2).mountPath == '/build/work/xyz' volumeMounts.get(2).subPath == 'work/xyz' getWorkingDir() == null getSecurityContext().privileged @@ -287,17 +270,17 @@ class K8sServiceImplTest extends Specification { def 'should create build pod without init container' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': workspace.toString() ] + 'wave.build.k8s.storage.mountPath': '/build' ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) when: - def result = k8sService.buildSpec('foo', 'my-image:latest', ['this','that'], workspace.resolve('work/xyz'), null, Duration.ofSeconds(10), [:]) + def result = k8sService.buildSpec('foo', 'my-image:latest', ['this','that'], Path.of('/build/work/xyz'), null, Duration.ofSeconds(10), [:]) then: result.metadata.name == 'foo' @@ -315,7 +298,7 @@ class K8sServiceImplTest extends Specification { env.value == ['--oci-worker-no-process-sandbox'] volumeMounts.size() == 1 volumeMounts.get(0).name == 'build-data' - volumeMounts.get(0).mountPath == "${workspace.toString()}/work/xyz" + volumeMounts.get(0).mountPath == '/build/work/xyz' volumeMounts.get(0).subPath == 'work/xyz' } and: @@ -330,11 +313,11 @@ class K8sServiceImplTest extends Specification { def 'should add labels ' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.labels': ['department': 'unit a','organization': 'org'] ] and: @@ -354,11 +337,11 @@ class K8sServiceImplTest extends Specification { def 'should add nodeselector' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.node-selector': [ 'linux/amd64': 'service=wave-build', 'linux/arm64': 'service=wave-build-arm64' @@ -385,11 +368,11 @@ class K8sServiceImplTest extends Specification { def 'should add serviceAccount' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount' ] and: @@ -408,21 +391,21 @@ class K8sServiceImplTest extends Specification { def 'should create scan pod' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': workspace.toString() ] + 'wave.build.k8s.storage.mountPath': '/build', ] and: def ctx = ApplicationContext.run(PROPS) def k8sService = ctx.getBean(K8sServiceImpl) def config = Mock(ScanConfig) { - getCacheDirectory() >> workspace.resolve('work/.trivy') + getCacheDirectory() >> Path.of('/build/work/.trivy') getTimeout() >> Duration.ofSeconds(10) } when: - def result = k8sService.scanSpec('foo', 'my-image:latest', ['this','that'], workspace.resolve('work/xyz'), workspace.resolve('work/xyz/config.json'), config, null ) + def result = k8sService.scanSpec('foo', 'my-image:latest', ['this','that'], Path.of('/build/work/xyz'), Path.of('/build/work/xyz/config.json'), config, null ) then: result.metadata.name == 'foo' result.metadata.namespace == 'my-ns' @@ -438,7 +421,7 @@ class K8sServiceImplTest extends Specification { volumeMounts.get(0).mountPath == '/root/.docker/config.json' volumeMounts.get(0).subPath == 'work/xyz/config.json' volumeMounts.get(1).name == 'build-data' - volumeMounts.get(1).mountPath == "${workspace.toString()}/work/xyz" + volumeMounts.get(1).mountPath == '/build/work/xyz' volumeMounts.get(1).subPath == 'work/xyz' volumeMounts.get(2).name == 'build-data' volumeMounts.get(2).mountPath == '/root/.cache/' @@ -455,7 +438,7 @@ class K8sServiceImplTest extends Specification { def 'should create transfer job spec with defaults' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config' ] and: @@ -490,7 +473,7 @@ class K8sServiceImplTest extends Specification { def 'should create transfer job spec with custom settings' () { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.service-account': 'foo-sa', 'wave.build.k8s.configPath': '/home/kube.config' ] @@ -634,11 +617,11 @@ class K8sServiceImplTest extends Specification { def 'buildJobSpec should create job with singularity image'() { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.retry-attempts': 3 ] and: @@ -647,7 +630,7 @@ class K8sServiceImplTest extends Specification { def name = 'the-job-name' def containerImage = 'singularity:latest' def args = ['singularity', '--this', '--that'] - def workDir = workspace.resolve('work/xyz') + def workDir = Path.of('/build/work/xyz') def credsFile = workDir.resolve('config.json') def timeout = Duration.ofMinutes(10) def nodeSelector = [key: 'value'] @@ -673,7 +656,7 @@ class K8sServiceImplTest extends Specification { job.spec.template.spec.containers.get(0).volumeMounts.get(1).subPath == 'work/xyz/singularity-remote.yaml' and: job.spec.template.spec.containers.get(0).volumeMounts.get(2).name == 'build-data' - job.spec.template.spec.containers.get(0).volumeMounts.get(2).mountPath == "${workspace.toString()}/work/xyz" + job.spec.template.spec.containers.get(0).volumeMounts.get(2).mountPath == '/build/work/xyz' job.spec.template.spec.containers.get(0).volumeMounts.get(2).subPath == 'work/xyz' and: job.spec.template.spec.volumes.get(0).name == 'build-data' @@ -686,11 +669,11 @@ class K8sServiceImplTest extends Specification { def 'buildJobSpec should create job with docker image'() { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'my-ns', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'build-claim', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.retry-attempts': 3 ] and: @@ -699,7 +682,7 @@ class K8sServiceImplTest extends Specification { def name = 'test-job' def containerImage = 'docker://test-image' def args = ['arg1', 'arg2'] - def workDir = workspace.resolve('work/xyz') + def workDir = Path.of('/build/work/xyz') def credsFile = workDir.resolve('config.json') def timeout = Duration.ofMinutes(10) def nodeSelector = [key: 'value'] @@ -722,7 +705,7 @@ class K8sServiceImplTest extends Specification { job.spec.template.spec.containers.get(0).volumeMounts.get(0).subPath == 'work/xyz/config.json' and: job.spec.template.spec.containers.get(0).volumeMounts.get(1).name == 'build-data' - job.spec.template.spec.containers.get(0).volumeMounts.get(1).mountPath == "$workspace/work/xyz" + job.spec.template.spec.containers.get(0).volumeMounts.get(1).mountPath == '/build/work/xyz' job.spec.template.spec.containers.get(0).volumeMounts.get(1).subPath == 'work/xyz' and: job.spec.template.spec.volumes.get(0).name == 'build-data' @@ -735,11 +718,11 @@ class K8sServiceImplTest extends Specification { def 'should create scan job spec with valid inputs'() { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount' ] and: @@ -748,10 +731,10 @@ class K8sServiceImplTest extends Specification { def name = 'scan-job' def containerImage = 'scan-image:latest' def args = ['arg1', 'arg2'] - def workDir = workspace.resolve('work/dir') + def workDir = Path.of('/work/dir') def credsFile = Path.of('/creds/file') def scanConfig = Mock(ScanConfig) { - getCacheDirectory() >> workspace.resolve('cache/dir') + getCacheDirectory() >> Path.of('/build/cache/dir') getRequestsCpu() >> '2' getRequestsMemory() >> '4Gi' getEnvironmentAsTuples() >> [new Tuple2('GITHUB_TOKEN', '123abc')] @@ -779,11 +762,11 @@ class K8sServiceImplTest extends Specification { def 'should create scan job spec without creds file'() { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount' ] and: @@ -795,7 +778,7 @@ class K8sServiceImplTest extends Specification { def workDir = Path.of('/work/dir') def credsFile = null def scanConfig = Mock(ScanConfig) { - getCacheDirectory() >> workspace.resolve('cache/dir') + getCacheDirectory() >> Path.of('/build/cache/dir') getRequestsCpu() >> '2' getRequestsMemory() >> '4Gi' } @@ -821,11 +804,11 @@ class K8sServiceImplTest extends Specification { def 'should create scan job spec without node selector'() { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', ] and: @@ -837,7 +820,7 @@ class K8sServiceImplTest extends Specification { def workDir = Path.of('/work/dir') def credsFile = Path.of('/creds/file') def scanConfig = Mock(ScanConfig) { - getCacheDirectory() >> workspace.resolve('cache/dir') + getCacheDirectory() >> Path.of('/build/cache/dir') getRequestsCpu() >> '2' getRequestsMemory() >> '4Gi' getRetryAttempts() >> 3 @@ -865,11 +848,11 @@ class K8sServiceImplTest extends Specification { def 'should create mirror job spec'() { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', 'wave.mirror.retry-attempts': 3 ] @@ -879,8 +862,8 @@ class K8sServiceImplTest extends Specification { def name = 'scan-job' def containerImage = 'scan-image:latest' def args = ['arg1', 'arg2'] - def workDir = workspace.resolve('work/dir') - def credsFile = workspace.resolve('work/dir/creds/file') + def workDir = Path.of('/build/work/dir') + def credsFile = Path.of('/build/work/dir/creds/file') def mirrorConfig = Mock(MirrorConfig) { getRequestsCpu() >> null getRequestsMemory() >> null @@ -908,7 +891,7 @@ class K8sServiceImplTest extends Specification { } and: with(job.spec.template.spec.containers[0].volumeMounts[1]) { - mountPath == "$workspace/work/dir" + mountPath == '/build/work/dir' readOnly == true subPath == 'work/dir' } @@ -924,11 +907,11 @@ class K8sServiceImplTest extends Specification { def 'should create scan job spec without resource requests'() { given: def PROPS = [ - 'wave.build.workspace': workspace.toString(), + 'wave.build.workspace': '/build/work', 'wave.build.k8s.namespace': 'foo', 'wave.build.k8s.configPath': '/home/kube.config', 'wave.build.k8s.storage.claimName': 'bar', - 'wave.build.k8s.storage.mountPath': workspace.toString(), + 'wave.build.k8s.storage.mountPath': '/build', 'wave.build.k8s.service-account': 'theAdminAccount', 'wave.scan.retry-attempts': 3 ] @@ -938,10 +921,10 @@ class K8sServiceImplTest extends Specification { def name = 'scan-job' def containerImage = 'scan-image:latest' def args = ['arg1', 'arg2'] - def workDir = workspace.resolve('work/dir') + def workDir = Path.of('/work/dir') def credsFile = Path.of('/creds/file') def scanConfig = Mock(ScanConfig) { - getCacheDirectory() >> workspace.resolve('cache/dir') + getCacheDirectory() >> Path.of('/build/cache/dir') getRequestsCpu() >> null getRequestsMemory() >> null getRetryAttempts() >> 3 From 8335ccdd94144eec39aff76f49ec3486a9af2277 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 14:46:08 +0100 Subject: [PATCH 65/69] Remove blank [ci skip] Signed-off-by: Paolo Di Tommaso --- .../io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy b/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy index ff313413b..d0e3d7511 100644 --- a/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy +++ b/src/main/groovy/io/seqera/wave/service/scan/ContainerScanServiceImpl.groovy @@ -18,7 +18,6 @@ package io.seqera.wave.service.scan - import java.nio.file.NoSuchFileException import java.time.Instant import java.util.concurrent.CompletableFuture From d7403cf69f749f26c56fead1ae5e16f0636fba60 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 15:32:43 +0100 Subject: [PATCH 66/69] Minor change [ci skip] Signed-off-by: Paolo Di Tommaso --- .../io/seqera/wave/auth/BasicAuthenticationProvider.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy b/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy index cca846b0b..d76ff89ee 100644 --- a/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy +++ b/src/main/groovy/io/seqera/wave/auth/BasicAuthenticationProvider.groovy @@ -49,7 +49,8 @@ class BasicAuthenticationProvider implements HttpRequestAuthenticationProvide if (accountService.isAuthorised(user, pass)) { log.trace "Auth request OK - user '$user'; password: '${StringUtils.redact(pass)}'" return AuthenticationResponse.success(authRequest.identity) - } else { + } + else { log.trace "Auth request FAILED - user '$user'; password: '${StringUtils.redact(pass)}'" return AuthenticationResponse.failure(AuthenticationFailureReason.CREDENTIALS_DO_NOT_MATCH) } From 383b2498dbdcfa02ff63b04415801bd9408eb9ed Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Sat, 2 Nov 2024 16:14:52 +0100 Subject: [PATCH 67/69] [release] bump version 1.14.0-B1 Signed-off-by: Paolo Di Tommaso --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 66fae2a63..0d47eaa23 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.13.11 +1.14.0-B1 From fba684c27a449311b8c64131929fdbbea41d56cc Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Tue, 5 Nov 2024 18:34:36 +0100 Subject: [PATCH 68/69] Update VERSION [ci skipped] --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 0d47eaa23..66fae2a63 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.14.0-B1 +1.13.11 From a66456568c0e3283db9607b32bba0f6d096bb271 Mon Sep 17 00:00:00 2001 From: Paolo Di Tommaso Date: Wed, 6 Nov 2024 00:08:31 +0100 Subject: [PATCH 69/69] Update src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy [ci skip] --- .../groovy/io/seqera/wave/service/CredentialsServiceTest.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy index 5a3c4bbaa..66b2012b2 100644 --- a/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy +++ b/src/test/groovy/io/seqera/wave/service/CredentialsServiceTest.groovy @@ -166,7 +166,7 @@ class CredentialsServiceTest extends Specification { registry: 'docker.io' ) and: - def identity = new PlatformId(new User(id:10), 100,"token",'tower.io', '101') + def identity = new PlatformId(new User(id:10), 100, 'token', 'tower.io', '101') def auth = JwtAuth.of(identity) when: