valepakh commented on code in PR #6625:
URL: https://github.com/apache/ignite-3/pull/6625#discussion_r2375938590


##########
modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/DeploymentCodeApi.java:
##########
@@ -80,6 +81,36 @@ CompletableFuture<Boolean> deploy(
             Optional<List<String>> initialNodes
     );
 
+    /**
+     * Deploy unit REST method.
+     */
+    @Operation(operationId = "deployUnit", summary = "Deploy unit", 
description = "Deploys provided unit to the cluster.")

Review Comment:
   operationId should be different I think?



##########
modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/DeploymentCodeApi.java:
##########
@@ -80,6 +81,36 @@ CompletableFuture<Boolean> deploy(
             Optional<List<String>> initialNodes
     );
 
+    /**
+     * Deploy unit REST method.

Review Comment:
   ```suggestion
        * Deploy a single zip file unit REST method.
   ```



##########
modules/rest/src/integrationTest/java/org/apache/ignite/internal/rest/deployment/DeploymentManagementControllerTest.java:
##########
@@ -43,55 +47,94 @@
 import io.micronaut.http.client.multipart.MultipartBody.Builder;
 import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
 import jakarta.inject.Inject;
-import java.io.File;
 import java.io.IOException;
 import java.nio.file.Files;
 import java.nio.file.Path;
+import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 import java.util.stream.Collectors;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipInputStream;
 import org.apache.ignite.internal.ClusterConfiguration;
-import org.apache.ignite.internal.ClusterPerTestIntegrationTest;
+import org.apache.ignite.internal.ClusterPerClassIntegrationTest;
 import org.apache.ignite.internal.rest.api.deployment.UnitStatus;
 import org.apache.ignite.internal.rest.api.deployment.UnitVersionStatus;
-import org.apache.ignite.internal.testframework.IgniteTestUtils;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 /**
  * Integration test for REST controller {@link DeploymentManagementController}.
  */
 @MicronautTest(rebuildContext = true)
-public class DeploymentManagementControllerTest extends 
ClusterPerTestIntegrationTest {
+public class DeploymentManagementControllerTest extends 
ClusterPerClassIntegrationTest {
     private static final String NODE_URL = "http://localhost:"; + 
ClusterConfiguration.DEFAULT_BASE_HTTP_PORT;
 
     private Path smallFile;
 
     private Path bigFile;
 
+    private Path zipFile;
+
     private static final long SIZE_IN_BYTES = 1024L;
 
     private static final long BIG_IN_BYTES = 100 * 1024L * 1024L;  // 100 MiB
 
+    private static final String UNIT_ID = "unitId";
+
     @Inject
     @Client(NODE_URL + "/management/v1/deployment")
     HttpClient client;
 
     @BeforeEach
     public void setup() throws IOException {
-        smallFile = workDir.resolve("small.txt");
-        bigFile = workDir.resolve("big.txt");
+        smallFile = WORK_DIR.resolve("small.txt");
+        bigFile = WORK_DIR.resolve("big.txt");
+        zipFile = WORK_DIR.resolve("zip.zip");
 
         if (!Files.exists(smallFile)) {
-            IgniteTestUtils.fillDummyFile(smallFile, SIZE_IN_BYTES);
+            fillDummyFile(smallFile, SIZE_IN_BYTES);
         }
         if (!Files.exists(bigFile)) {
-            IgniteTestUtils.fillDummyFile(bigFile, BIG_IN_BYTES);
+            fillDummyFile(bigFile, BIG_IN_BYTES);
+        }
+        if (!Files.exists(zipFile)) {
+            createZipFile(Map.of(
+                    "a1/a2", SIZE_IN_BYTES,
+                    "b1", SIZE_IN_BYTES,
+                    "c1/c2/c3/c4", BIG_IN_BYTES,
+                    "d1/d2", SIZE_IN_BYTES,
+                    "d1/a2", SIZE_IN_BYTES
+            ), zipFile);
+        }
+    }
+
+    @AfterEach
+    public void cleanup() {
+        List<UnitStatus> list = list(UNIT_ID);
+
+        for (UnitStatus unitStatus : list) {
+            for (UnitVersionStatus versionToStatus : 
unitStatus.versionToStatus()) {
+                if (versionToStatus.getStatus() == DEPLOYED) {
+                    HttpResponse<Object> response = undeploy(UNIT_ID, 
versionToStatus.getVersion());
+                    assertThat(response.code(), is(OK.code()));
+                }
+            }
         }
+
+        await().timeout(10, SECONDS).untilAsserted(() -> {
+            MutableHttpRequest<Object> get = HttpRequest.GET("cluster/units");
+            Collection<UnitStatus> statuses = 
client.toBlocking().retrieve(get, Argument.listOf(UnitStatus.class));
+
+            assertThat(statuses, is(empty()));
+        });

Review Comment:
   ```suggestion
           await().until(() -> {
               MutableHttpRequest<Object> get = 
HttpRequest.GET("cluster/units");
               return client.toBlocking().retrieve(get, 
Argument.listOf(UnitStatus.class));
           }, is(empty()));
   ```



##########
modules/code-deployment/src/integrationTest/java/org/apache/ignite/internal/deployment/ItDeploymentUnitTest.java:
##########
@@ -281,4 +281,18 @@ public void testAbaValidation() {
 
         smallUnit.waitUnitClean(igniteImpl(2));
     }
+
+    @Test
+    public void testZipDeploy() {
+        String id = "test";
+        Unit unit = files.deployAndVerifyFlatZip(id, 
Version.parseVersion("1.1.0"), igniteImpl(1));
+
+        Unit unit2 = files.deployAndVerifyTreeZip(id, 
Version.parseVersion("1.1.1"), igniteImpl(1));
+
+        UnitStatuses status = buildStatus(id, unit, unit2);
+
+        await().timeout(2, SECONDS)
+                .pollDelay(500, MILLISECONDS)
+                .until(() -> 
igniteImpl(2).deployment().clusterStatusesAsync(), willBe(List.of(status)));

Review Comment:
   Can we check the actual files structure after deploy? Will the 
`waitUnitReplica` work?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to