Skip to content

Commit

Permalink
Use @DataMongoTest and @Testcontainers annotations in `WorkerServ…
Browse files Browse the repository at this point in the history
…iceTests` (#665)
  • Loading branch information
jbern0rd authored Feb 20, 2024
1 parent a202961 commit b1dbd41
Show file tree
Hide file tree
Showing 7 changed files with 236 additions and 302 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ All notable changes to this project will be documented in this file.

### Quality

- Use `@DataMongoTest` and `@Testcontainers` annotations in replicates, compute logs and tasks tests. (#662 #664)
- Use `@DataMongoTest` and `@Testcontainers` annotations in replicates, compute logs and tasks tests. (#662 #664 #665)

## [[8.3.0]](https://github.com/iExecBlockchainComputing/iexec-core/releases/tag/v8.3.0) 2024-01-11

Expand Down
18 changes: 7 additions & 11 deletions src/main/java/com/iexec/core/worker/Worker.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 IEXEC BLOCKCHAIN TECH
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -23,14 +23,13 @@
import org.springframework.data.mongodb.core.index.Indexed;
import org.springframework.data.mongodb.core.mapping.Document;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Data
@Document
@AllArgsConstructor
@Data
@Builder
@AllArgsConstructor
public class Worker {

@Id
Expand All @@ -47,18 +46,15 @@ public class Worker {
private int memorySize;
private boolean teeEnabled;
private boolean gpuEnabled;
private List<String> participatingChainTaskIds;
private List<String> computingChainTaskIds;
@Builder.Default
private List<String> participatingChainTaskIds = List.of();
@Builder.Default
private List<String> computingChainTaskIds = List.of();

// TODO remove it cleanly in a release
private Date lastAliveDate;
private Date lastReplicateDemandDate;

public Worker() {
participatingChainTaskIds = new ArrayList<>();
computingChainTaskIds = new ArrayList<>();
}

void addChainTaskId(String chainTaskId) {
participatingChainTaskIds.add(chainTaskId);
computingChainTaskIds.add(chainTaskId);
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/iexec/core/worker/WorkerService.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 IEXEC BLOCKCHAIN TECH
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/com/iexec/core/metric/MetricServiceTests.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 IEXEC BLOCKCHAIN TECH
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -54,7 +54,7 @@ void init() {
void shouldGetPlatformMetrics() {
final LinkedHashMap<TaskStatus, Long> expectedCurrentTaskStatusesCount = createExpectedCurrentTaskStatusesCount();

List<Worker> aliveWorkers = List.of(new Worker());
List<Worker> aliveWorkers = List.of(Worker.builder().build());
when(workerService.getAliveWorkers()).thenReturn(aliveWorkers);
when(workerService.getAliveTotalCpu()).thenReturn(1);
when(workerService.getAliveAvailableCpu()).thenReturn(1);
Expand Down
1 change: 1 addition & 0 deletions src/test/java/com/iexec/core/task/TaskServiceTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ void shouldAddTask() {
assertThat(saved)
.usingRecursiveComparison()
.ignoringFields("value.id", "value.version")
.ignoringFieldsMatchingRegexes("value.dateStatusList.*")
.isEqualTo(Optional.of(task));
}

Expand Down

This file was deleted.

Loading

0 comments on commit b1dbd41

Please sign in to comment.