Skip to content

Commit

Permalink
Merge pull request #733 from seqeralabs/mn-4.6
Browse files Browse the repository at this point in the history
Upgrade to Micronaut 4.6
  • Loading branch information
pditommaso authored Nov 2, 2024
2 parents 318f589 + 8335ccd commit d3efe1b
Show file tree
Hide file tree
Showing 7 changed files with 90 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,11 @@ class ScanConfig {
@Memoized
Path getCacheDirectory() {
final result = Path.of(buildDirectory).toAbsolutePath().resolve('.trivy-cache')
Files.createDirectories(result)
try {
Files.createDirectories(result)
} catch (IOException e) {
log.error "Unable to create scan cache directory=${result} - cause: ${e.message}"
}
return result
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
Expand Down Expand Up @@ -74,7 +72,6 @@ import jakarta.inject.Inject
* @author Paolo Di Tommaso <[email protected]>
*/
@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 {
Expand Down Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,17 @@ class RegistryControllerLocalTest extends Specification implements DockerRegistr
h.add('Accept', it)
}
})
HttpResponse<Map> response = client.toBlocking().exchange(request, String)
HttpResponse<String> 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 ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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]
))

Expand Down Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,11 @@ 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
Expand All @@ -40,11 +38,9 @@ import jakarta.inject.Inject
* @author Paolo Di Tommaso <[email protected]>
*/
@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 {
Expand All @@ -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:
Expand Down
Loading

0 comments on commit d3efe1b

Please sign in to comment.