This is an automated email from the ASF dual-hosted git repository.
mpochatkin pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/ignite-3.git
The following commit(s) were added to refs/heads/main by this push:
new 17ca7cb1cdb IGNITE-26642 Fix flaky DeploymentManagementControllerTest
(#6718)
17ca7cb1cdb is described below
commit 17ca7cb1cdb53d7526c2b765d4689b7cf6e1a6ab
Author: Mikhail <[email protected]>
AuthorDate: Thu Oct 9 08:18:29 2025 +0300
IGNITE-26642 Fix flaky DeploymentManagementControllerTest (#6718)
---
.../rest/api/deployment/UnitVersionStatus.java | 6 +++
.../DeploymentManagementControllerTest.java | 63 +++++++++++-----------
2 files changed, 39 insertions(+), 30 deletions(-)
diff --git
a/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/UnitVersionStatus.java
b/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/UnitVersionStatus.java
index e15b3de01fa..0ffea704120 100644
---
a/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/UnitVersionStatus.java
+++
b/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/UnitVersionStatus.java
@@ -22,6 +22,7 @@ import com.fasterxml.jackson.annotation.JsonGetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
+import org.apache.ignite.internal.tostring.S;
/**
* DTO of unit version and status.
@@ -73,4 +74,9 @@ public class UnitVersionStatus {
result = 31 * result + (status != null ? status.hashCode() : 0);
return result;
}
+
+ @Override
+ public String toString() {
+ return S.toString(this);
+ }
}
diff --git
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/deployment/DeploymentManagementControllerTest.java
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/deployment/DeploymentManagementControllerTest.java
index cef7cb10220..1685c2b05e6 100644
---
a/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/deployment/DeploymentManagementControllerTest.java
+++
b/modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/deployment/DeploymentManagementControllerTest.java
@@ -27,7 +27,7 @@ import static
org.apache.ignite.internal.testframework.IgniteTestUtils.createZip
import static
org.apache.ignite.internal.testframework.IgniteTestUtils.fillDummyFile;
import static org.awaitility.Awaitility.await;
import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.contains;
+import static org.hamcrest.Matchers.containsInAnyOrder;
import static org.hamcrest.Matchers.empty;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.is;
@@ -51,6 +51,7 @@ import jakarta.inject.Inject;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
+import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -142,13 +143,7 @@ public class DeploymentManagementControllerTest extends
ClusterPerClassIntegrati
assertThat(response.code(), is(OK.code()));
- await().untilAsserted(() -> {
- MutableHttpRequest<Object> get = HttpRequest.GET("cluster/units");
- UnitStatus status = client.toBlocking().retrieve(get,
UnitStatus.class);
-
- assertThat(status.id(), is(id));
- assertThat(status.versionToStatus(), equalTo(List.of(new
UnitVersionStatus(version, DEPLOYED))));
- });
+ awaitDeployedStatus(id, version);
}
@Test
@@ -159,13 +154,7 @@ public class DeploymentManagementControllerTest extends
ClusterPerClassIntegrati
assertThat(response.code(), is(OK.code()));
- await().untilAsserted(() -> {
- MutableHttpRequest<Object> get = HttpRequest.GET("cluster/units");
- UnitStatus status = client.toBlocking().retrieve(get,
UnitStatus.class);
-
- assertThat(status.id(), is(id));
- assertThat(status.versionToStatus(), equalTo(List.of(new
UnitVersionStatus(version, DEPLOYED))));
- });
+ awaitDeployedStatus(id, version);
}
@Test
@@ -190,6 +179,8 @@ public class DeploymentManagementControllerTest extends
ClusterPerClassIntegrati
HttpClientResponseException.class,
() -> deploy(id, version));
assertThat(e.getResponse().code(), is(CONFLICT.code()));
+
+ awaitDeployedStatus(id, version);
}
@Test
@@ -201,6 +192,8 @@ public class DeploymentManagementControllerTest extends
ClusterPerClassIntegrati
assertThat(response.code(), is(OK.code()));
+ awaitDeployedStatus(id, version);
+
response = undeploy(id, version);
assertThat(response.code(), is(OK.code()));
}
@@ -223,19 +216,19 @@ public class DeploymentManagementControllerTest extends
ClusterPerClassIntegrati
@Test
public void testList() {
String id = UNIT_ID;
- deploy(id, "1.1.1");
- deploy(id, "1.1.2");
- deploy(id, "1.2.1");
- deploy(id, "2.0");
- deploy(id, "1.0.0");
- deploy(id, "1.0.1");
+ String[] versions = { "1.1.1", "1.1.2", "1.2.1", "2.0.0", "1.0.0",
"1.0.1" };
+ for (String version : versions) {
+ deploy(id, version);
+ }
+
+ awaitDeployedStatus(id, versions);
List<UnitStatus> list = list(id);
- List<String> versions = list.stream()
+ List<String> actualVersions = list.stream()
.flatMap(unitStatus ->
unitStatus.versionToStatus().stream().map(UnitVersionStatus::getVersion))
.collect(Collectors.toList());
- assertThat(versions, contains("1.0.0", "1.0.1", "1.1.1", "1.1.2",
"1.2.1", "2.0.0"));
+ assertThat(actualVersions, containsInAnyOrder(versions));
}
@Test
@@ -246,13 +239,7 @@ public class DeploymentManagementControllerTest extends
ClusterPerClassIntegrati
assertThat(response.code(), is(OK.code()));
- await().untilAsserted(() -> {
- MutableHttpRequest<Object> get = HttpRequest.GET("cluster/units");
- UnitStatus status = client.toBlocking().retrieve(get,
UnitStatus.class);
-
- assertThat(status.id(), is(id));
- assertThat(status.versionToStatus(), equalTo(List.of(new
UnitVersionStatus(version, DEPLOYED))));
- });
+ awaitDeployedStatus(id, version);
Path workDir0 = CLUSTER.nodeWorkDir(0);
Path nodeUnitDirectory =
workDir0.resolve("deployment").resolve(id).resolve(version);
@@ -275,6 +262,8 @@ public class DeploymentManagementControllerTest extends
ClusterPerClassIntegrati
assertThat(response.code(), is(OK.code()));
+ awaitDeployedStatus(id, version);
+
await().untilAsserted(() -> {
MutableHttpRequest<Object> get = HttpRequest.GET("cluster/units");
UnitStatus status = client.toBlocking().retrieve(get,
UnitStatus.class);
@@ -307,6 +296,20 @@ public class DeploymentManagementControllerTest extends
ClusterPerClassIntegrati
);
}
+ private void awaitDeployedStatus(String id, String... versions) {
+ await().untilAsserted(() -> {
+ MutableHttpRequest<Object> get = HttpRequest.GET("cluster/units");
+ UnitStatus status = client.toBlocking().retrieve(get,
UnitStatus.class);
+
+ assertThat(status.id(), is(id));
+ UnitVersionStatus[] statuses = Arrays.stream(versions)
+ .map(version -> new UnitVersionStatus(version, DEPLOYED))
+ .toArray(UnitVersionStatus[]::new);
+
+ assertThat(status.versionToStatus(), containsInAnyOrder(statuses));
+ });
+ }
+
private HttpResponse<Object> deployZip(String id, String version) {
return deploy(id, version, true, zipFile);
}