Skip to content

Commit b1dbd41

Browse files
authored
Use @DataMongoTest and @Testcontainers annotations in WorkerServiceTests (#665)
1 parent a202961 commit b1dbd41

File tree

7 files changed

+236
-302
lines changed

7 files changed

+236
-302
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ All notable changes to this project will be documented in this file.
1616

1717
### Quality
1818

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

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

src/main/java/com/iexec/core/worker/Worker.java

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -23,14 +23,13 @@
2323
import org.springframework.data.mongodb.core.index.Indexed;
2424
import org.springframework.data.mongodb.core.mapping.Document;
2525

26-
import java.util.ArrayList;
2726
import java.util.Date;
2827
import java.util.List;
2928

30-
@Data
3129
@Document
32-
@AllArgsConstructor
30+
@Data
3331
@Builder
32+
@AllArgsConstructor
3433
public class Worker {
3534

3635
@Id
@@ -47,18 +46,15 @@ public class Worker {
4746
private int memorySize;
4847
private boolean teeEnabled;
4948
private boolean gpuEnabled;
50-
private List<String> participatingChainTaskIds;
51-
private List<String> computingChainTaskIds;
49+
@Builder.Default
50+
private List<String> participatingChainTaskIds = List.of();
51+
@Builder.Default
52+
private List<String> computingChainTaskIds = List.of();
5253

5354
// TODO remove it cleanly in a release
5455
private Date lastAliveDate;
5556
private Date lastReplicateDemandDate;
5657

57-
public Worker() {
58-
participatingChainTaskIds = new ArrayList<>();
59-
computingChainTaskIds = new ArrayList<>();
60-
}
61-
6258
void addChainTaskId(String chainTaskId) {
6359
participatingChainTaskIds.add(chainTaskId);
6460
computingChainTaskIds.add(chainTaskId);

src/main/java/com/iexec/core/worker/WorkerService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

src/test/java/com/iexec/core/metric/MetricServiceTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020 IEXEC BLOCKCHAIN TECH
2+
* Copyright 2020-2024 IEXEC BLOCKCHAIN TECH
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ void init() {
5454
void shouldGetPlatformMetrics() {
5555
final LinkedHashMap<TaskStatus, Long> expectedCurrentTaskStatusesCount = createExpectedCurrentTaskStatusesCount();
5656

57-
List<Worker> aliveWorkers = List.of(new Worker());
57+
List<Worker> aliveWorkers = List.of(Worker.builder().build());
5858
when(workerService.getAliveWorkers()).thenReturn(aliveWorkers);
5959
when(workerService.getAliveTotalCpu()).thenReturn(1);
6060
when(workerService.getAliveAvailableCpu()).thenReturn(1);

src/test/java/com/iexec/core/task/TaskServiceTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ void shouldAddTask() {
136136
assertThat(saved)
137137
.usingRecursiveComparison()
138138
.ignoringFields("value.id", "value.version")
139+
.ignoringFieldsMatchingRegexes("value.dateStatusList.*")
139140
.isEqualTo(Optional.of(task));
140141
}
141142

src/test/java/com/iexec/core/worker/WorkerServiceRealRepositoryTests.java

Lines changed: 0 additions & 192 deletions
This file was deleted.

0 commit comments

Comments
 (0)