Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use @DataMongoTest and @Testcontainers annotations in WorkerServiceTests #665

Merged
merged 3 commits into from
Feb 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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