This repository has been archived by the owner on Feb 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to get the status of a compute job
- Added tests
- Loading branch information
Showing
9 changed files
with
210 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/main/java/io/keyko/nevermined/models/gateway/ComputeStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.keyko.nevermined.models.gateway; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.keyko.nevermined.models.AbstractModel; | ||
import io.keyko.nevermined.models.DID; | ||
import io.keyko.nevermined.models.FromJsonToModel; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class ComputeStatus extends AbstractModel implements FromJsonToModel { | ||
@JsonProperty | ||
public String startedAt; | ||
|
||
@JsonProperty | ||
public String finishedAt; | ||
|
||
@JsonProperty | ||
public String status; | ||
|
||
@JsonProperty | ||
public DID did; | ||
|
||
@JsonProperty | ||
public List<PodStatus> pods; | ||
} |
21 changes: 21 additions & 0 deletions
21
src/main/java/io/keyko/nevermined/models/gateway/PodStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package io.keyko.nevermined.models.gateway; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
import com.fasterxml.jackson.annotation.JsonProperty; | ||
import io.keyko.nevermined.models.AbstractModel; | ||
import io.keyko.nevermined.models.FromJsonToModel; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class PodStatus extends AbstractModel implements FromJsonToModel { | ||
@JsonProperty | ||
public String startedAt; | ||
|
||
@JsonProperty | ||
public String finishedAt; | ||
|
||
@JsonProperty | ||
public String podName; | ||
|
||
@JsonProperty | ||
public String status; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
src/test/java/io/keyko/nevermined/models/ComputeStatusTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package io.keyko.nevermined.models; | ||
|
||
import com.fasterxml.jackson.core.type.TypeReference; | ||
import io.keyko.nevermined.models.gateway.ComputeStatus; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class ComputeStatusTest { | ||
|
||
private static String COMPUTE_STATUS_SAMPLE = "src/test/resources/examples/compute-status.json"; | ||
private static String COMPUTE_STATUS_CONTENT; | ||
|
||
@BeforeClass | ||
public static void setUp() throws Exception { | ||
COMPUTE_STATUS_CONTENT = new String(Files.readAllBytes(Paths.get(COMPUTE_STATUS_SAMPLE))); | ||
} | ||
@Test | ||
public void fromJsonTest() throws Exception { | ||
ComputeStatus computeStatus = ComputeStatus.fromJSON(new TypeReference<>() {}, COMPUTE_STATUS_CONTENT); | ||
|
||
assertEquals("did:nv:7ce18efb179b65a1ca4b1598ad4d1fb4107c4fe51336e2871d3f7ae208873fd4", | ||
computeStatus.did.getDid()); | ||
assertEquals("2020-09-18T12:24:33+00:00Z", computeStatus.startedAt); | ||
assertEquals("2020-09-18T12:24:50+00:00Z", computeStatus.finishedAt); | ||
assertEquals("Succeeded", computeStatus.status); | ||
assertEquals(3, computeStatus.pods.size()); | ||
|
||
assertEquals("2020-09-18T12:24:49+00:00Z", computeStatus.pods.get(0).finishedAt); | ||
assertEquals("2020-09-18T12:24:44+00:00Z", computeStatus.pods.get(0).startedAt); | ||
assertEquals("publishing", computeStatus.pods.get(0).podName); | ||
assertEquals("Succeeded", computeStatus.pods.get(0).status); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
{ | ||
"did": "did:nv:7ce18efb179b65a1ca4b1598ad4d1fb4107c4fe51336e2871d3f7ae208873fd4", | ||
"finishedAt": "2020-09-18T12:24:50+00:00Z", | ||
"pods": [ | ||
{ | ||
"finishedAt": "2020-09-18T12:24:49+00:00Z", | ||
"podName": "publishing", | ||
"startedAt": "2020-09-18T12:24:44+00:00Z", | ||
"status": "Succeeded" | ||
}, | ||
{ | ||
"finishedAt": "2020-09-18T12:24:42+00:00Z", | ||
"podName": "transformation", | ||
"startedAt": "2020-09-18T12:24:39+00:00Z", | ||
"status": "Succeeded" | ||
}, | ||
{ | ||
"finishedAt": "2020-09-18T12:24:38+00:00Z", | ||
"podName": "configurator", | ||
"startedAt": "2020-09-18T12:24:33+00:00Z", | ||
"status": "Succeeded" | ||
} | ||
], | ||
"startedAt": "2020-09-18T12:24:33+00:00Z", | ||
"status": "Succeeded" | ||
} |