Skip to content

Commit

Permalink
Fix failing tests
Browse files Browse the repository at this point in the history
Signed-off-by: Paolo Di Tommaso <[email protected]>
  • Loading branch information
pditommaso committed Sep 25, 2024
1 parent c426137 commit df2b4ac
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 74 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,4 +122,15 @@ class BuildCacheStore extends AbstractCacheStore<BuildStoreEntry> implements Bui
}
}
}

/**
* Load a build entry via the record id
*
* @param recordId The ID of the record to be loaded
* @return The {@link BuildStoreEntry} with with corresponding Id of {@code null} if it cannot be found
*/
@Override
BuildStoreEntry getByRecordId(String recordId) {
super.getByRecordId(recordId)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,11 @@ interface BuildStore {
*/
CompletableFuture<BuildResult> awaitBuild(String imageName)

/**
* Load a build entry via the record id
*
* @param recordId The ID of the record to be loaded
* @return The {@link BuildStoreEntry} with with corresponding Id of {@code null} if it cannot be found
*/
BuildStoreEntry getByRecordId(String recordId)
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class ContainerBuildServiceImpl implements ContainerBuildService, JobHandler<Bui
private ApplicationEventPublisher<BuildEvent> eventPublisher

@Inject
private BuildCacheStore buildStore
private BuildStore buildStore

@Inject
@Named(TaskExecutors.IO)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import io.seqera.wave.service.job.JobService
import io.seqera.wave.service.job.JobSpec
import io.seqera.wave.service.job.JobState
import io.seqera.wave.service.persistence.PersistenceService
import io.seqera.wave.service.persistence.WaveBuildRecord
import io.seqera.wave.service.scan.ScanRequest
import io.seqera.wave.service.scan.ScanStrategy
import io.seqera.wave.test.TestHelper
Expand Down Expand Up @@ -332,78 +331,6 @@ class ContainerBuildServiceTest extends Specification {
record.digest == 'abc123'
}

void "should create build record in redis"() {
given:
final request =
new BuildRequest(
containerId: 'container1234',
containerFile:'test',
condaFile: 'test',
workspace: Path.of("."),
targetImage: 'docker.io/my/repo:container1234',
identity: PlatformId.NULL,
platform: ContainerPlatform.of('amd64'),
cacheRepository: 'docker.io/my/cache',
ip: '127.0.0.1',
configJson: '{"config":"json"}',
scanId: 'scan12345',
format: BuildFormat.DOCKER,
startTime: Instant.now()
)
.withBuildId('123')

and:
def result = BuildResult.completed(request.buildId, 1, 'Hello', Instant.now().minusSeconds(60), 'xyz')

and:
def build = WaveBuildRecord.fromEvent(new BuildEvent(request, result))

when:
service.createBuildRecord(build.buildId, build)

then:
def record = buildRecordStore.getBuildRecord(request.buildId)
record.buildId == request.buildId
record.digest == 'xyz'
}

void "should save build record in redis and surrealdb"() {
given:
final request =
new BuildRequest(
containerId: 'container1234',
containerFile: 'test',
condaFile: 'test',
workspace: Path.of("."),
targetImage: 'docker.io/my/repo:container1234',
identity: PlatformId.NULL,
platform: ContainerPlatform.of('amd64'),
cacheRepository: 'docker.io/my/cache',
ip: '127.0.0.1',
configJson: '{"config":"json"}',
scanId: 'scan12345',
format: BuildFormat.DOCKER
)
.withBuildId('123')

and:
def result = new BuildResult(request.buildId, 0, "content", Instant.now(), Duration.ofSeconds(1), 'abc123')
def event = new BuildEvent(request, result)

when:
service.saveBuildRecord(event)

then:
def record = persistenceService.loadBuild(request.buildId)
record.buildId == request.buildId
record.digest == 'abc123'

and:
def record2 = buildRecordStore.getBuildRecord(request.buildId)
record2.buildId == request.buildId
record2.digest == 'abc123'
}

def 'should return only the host name' () {
expect:
ContainerInspectServiceImpl.host0(CONTAINER) == EXPECTED
Expand Down

0 comments on commit df2b4ac

Please sign in to comment.