This is an automated email from the ASF dual-hosted git repository.

apkhmv 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 213e70d2be IGNITE-19139 Fix flaky ItDeployUndeployCallsTest (#1987)
213e70d2be is described below

commit 213e70d2be4598aac28dc02610397fb003bc5b80
Author: Vadim Pakhnushev <[email protected]>
AuthorDate: Fri Apr 28 20:06:05 2023 +0300

    IGNITE-19139 Fix flaky ItDeployUndeployCallsTest (#1987)
---
 .../cli/call/unit/ItDeployUndeployCallsTest.java   | 35 ++++++++++++++--------
 .../cli/commands/unit/ItDeploymentUnitTest.java    | 22 +++++++-------
 .../internal/rest/ItGeneratedRestClientTest.java   |  3 +-
 .../rest/api/deployment/DeploymentCodeApi.java     |  3 ++
 4 files changed, 39 insertions(+), 24 deletions(-)

diff --git 
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/call/unit/ItDeployUndeployCallsTest.java
 
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/call/unit/ItDeployUndeployCallsTest.java
index f78829f442..66a3348c6e 100644
--- 
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/call/unit/ItDeployUndeployCallsTest.java
+++ 
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/call/unit/ItDeployUndeployCallsTest.java
@@ -22,6 +22,7 @@ import static 
org.apache.ignite.internal.cli.call.unit.DeployUndeployTestSupport
 import static 
org.apache.ignite.internal.cli.call.unit.DeployUndeployTestSupport.tracker;
 import static org.apache.ignite.rest.client.model.DeploymentStatus.DEPLOYED;
 import static org.assertj.core.api.AssertionsForClassTypes.assertThat;
+import static org.awaitility.Awaitility.await;
 
 import jakarta.inject.Inject;
 import java.io.FileNotFoundException;
@@ -34,12 +35,10 @@ import 
org.apache.ignite.internal.cli.core.exception.UnitAlreadyExistsException;
 import org.apache.ignite.internal.cli.core.exception.UnitNotFoundException;
 import org.apache.ignite.internal.cli.core.style.component.MessageUiComponent;
 import org.apache.ignite.internal.cli.core.style.element.UiElements;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 
 /** Integration test for the deployment lifecycle: deploy, list, check status, 
undeploy. */
-@Disabled("IGNITE-19139")
 public class ItDeployUndeployCallsTest extends 
CallInitializedIntegrationTestBase {
 
     @Inject
@@ -96,7 +95,7 @@ public class ItDeployUndeployCallsTest extends 
CallInitializedIntegrationTestBas
         List<UnitStatusRecord> unisStatuses = 
listUnitCall.execute(urlInput).body();
         assertThat(unisStatuses.size()).isEqualTo(1);
         // And status is not empty
-        assertThat(unitStatusCall.execute(statusInput("test.id"))).isNotNull();
+        await().untilAsserted(() -> 
assertThat(unitStatusCall.execute(statusInput("test.id"))).isNotNull());
 
         // When undeploy unit
         CallOutput<String> undeployOutput = 
undeployUnitCall.execute(undeployInput("test.id", "1.0.0"));
@@ -104,7 +103,7 @@ public class ItDeployUndeployCallsTest extends 
CallInitializedIntegrationTestBas
         
assertThat(undeployOutput.body()).isEqualTo(MessageUiComponent.from(UiElements.done()).render());
 
         // Then list is empty
-        assertThat(listUnitCall.execute(urlInput).isEmpty()).isTrue();
+        await().untilAsserted(() -> 
assertThat(listUnitCall.execute(urlInput).isEmpty()).isTrue());
     }
 
     @Test
@@ -171,6 +170,14 @@ public class ItDeployUndeployCallsTest extends 
CallInitializedIntegrationTestBas
         var err = (UnitAlreadyExistsException) output.errorCause();
         assertThat(err.unitId()).isEqualTo("test.id");
         assertThat(err.version()).isEqualTo("1.0.0");
+
+        // Cleanup
+        CallOutput<String> undeployOutput = 
undeployUnitCall.execute(undeployInput("test.id", "1.0.0"));
+        assertThat(undeployOutput.hasError()).isFalse();
+        
assertThat(undeployOutput.body()).isEqualTo(MessageUiComponent.from(UiElements.done()).render());
+
+        // Wait for cleanup
+        await().untilAsserted(() -> 
assertThat(listUnitCall.execute(urlInput).isEmpty()).isTrue());
     }
 
     @Test
@@ -201,14 +208,16 @@ public class ItDeployUndeployCallsTest extends 
CallInitializedIntegrationTestBas
         assertThat(deployOutput.hasError()).isFalse();
         
assertThat(deployOutput.body()).isEqualTo(MessageUiComponent.from(UiElements.done()).render());
         // And list is not empty
-        List<UnitStatusRecord> unisStatuses = 
listUnitCall.execute(urlInput).body();
-        assertThat(unisStatuses.size()).isEqualTo(1);
-        
assertThat(unisStatuses.get(0).versionToDeploymentInfo().size()).isEqualTo(1);
-        assertThat(unisStatuses.get(0).versionToDeploymentInfo().get("1.1.0"))
-                .isNotNull()
-                .matches(deploymentInfo -> deploymentInfo.getStatus() == 
DEPLOYED);
-
-        // And status is not empty
-        assertThat(unitStatusCall.execute(statusInput("test.id"))).isNotNull();
+        await().untilAsserted(() -> {
+            List<UnitStatusRecord> unisStatuses = 
listUnitCall.execute(urlInput).body();
+            assertThat(unisStatuses.size()).isEqualTo(1);
+            
assertThat(unisStatuses.get(0).versionToDeploymentInfo().size()).isEqualTo(1);
+            
assertThat(unisStatuses.get(0).versionToDeploymentInfo().get("1.1.0"))
+                    .isNotNull()
+                    .matches(deploymentInfo -> deploymentInfo.getStatus() == 
DEPLOYED);
+
+            // And status is not empty
+            
assertThat(unitStatusCall.execute(statusInput("test.id"))).isNotNull();
+        });
     }
 }
diff --git 
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItDeploymentUnitTest.java
 
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItDeploymentUnitTest.java
index 70868903de..57bd8750da 100644
--- 
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItDeploymentUnitTest.java
+++ 
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/cli/commands/unit/ItDeploymentUnitTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.ignite.internal.cli.commands.unit;
 
+import static org.awaitility.Awaitility.await;
 import static org.junit.jupiter.api.Assertions.assertAll;
 
 import java.io.IOException;
@@ -24,12 +25,10 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import 
org.apache.ignite.internal.cli.commands.CliCommandTestInitializedIntegrationBase;
 import org.junit.jupiter.api.BeforeAll;
-import org.junit.jupiter.api.Disabled;
 import org.junit.jupiter.api.DisplayName;
 import org.junit.jupiter.api.Test;
 
 /** Integration test for deployment commands. */
-@Disabled("https://issues.apache.org/jira/browse/IGNITE-19139";)
 public class ItDeploymentUnitTest extends 
CliCommandTestInitializedIntegrationBase {
 
     private String testFile;
@@ -114,14 +113,17 @@ public class ItDeploymentUnitTest extends 
CliCommandTestInitializedIntegrationBa
                 () -> assertOutputContains("Done")
         );
 
-        execute("unit", "status", "test.unit.id.5");
-
-        assertAll(
-                this::assertExitCodeIsZero,
-                this::assertErrOutputIsEmpty,
-                () -> assertOutputContains("1.0.0"),
-                () -> assertOutputContains("DEPLOYED")
-        );
+        await().untilAsserted(() -> {
+            resetOutput();
+            execute("unit", "status", "test.unit.id.5");
+
+            assertAll(
+                    this::assertExitCodeIsZero,
+                    this::assertErrOutputIsEmpty,
+                    () -> assertOutputContains("1.0.0"),
+                    () -> assertOutputContains("DEPLOYED")
+            );
+        });
     }
 
     @Test
diff --git 
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/rest/ItGeneratedRestClientTest.java
 
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/rest/ItGeneratedRestClientTest.java
index 80cff4aee7..9cb7ab343c 100644
--- 
a/modules/cli/src/integrationTest/java/org/apache/ignite/internal/rest/ItGeneratedRestClientTest.java
+++ 
b/modules/cli/src/integrationTest/java/org/apache/ignite/internal/rest/ItGeneratedRestClientTest.java
@@ -20,6 +20,7 @@ package org.apache.ignite.internal.rest;
 import static java.util.stream.Collectors.toList;
 import static 
org.apache.ignite.internal.testframework.IgniteTestUtils.testNodeName;
 import static 
org.apache.ignite.internal.testframework.matchers.CompletableFutureMatcher.willCompleteSuccessfully;
+import static org.awaitility.Awaitility.await;
 import static org.hamcrest.MatcherAssert.assertThat;
 import static org.hamcrest.Matchers.contains;
 import static org.hamcrest.Matchers.containsInAnyOrder;
@@ -400,7 +401,7 @@ public class ItGeneratedRestClientTest {
         assertThat(deploymentApi.versions("test.unit.id"), contains("1.0.0"));
 
         deploymentApi.undeployUnit("test.unit.id", "1.0.0");
-        assertThat(deploymentApi.units(), empty());
+        await().untilAsserted(() -> assertThat(deploymentApi.units(), 
empty()));
     }
 
     @Test
diff --git 
a/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/DeploymentCodeApi.java
 
b/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/DeploymentCodeApi.java
index d0cce5424e..5cb09962ac 100644
--- 
a/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/DeploymentCodeApi.java
+++ 
b/modules/rest-api/src/main/java/org/apache/ignite/internal/rest/api/deployment/DeploymentCodeApi.java
@@ -29,6 +29,8 @@ import io.micronaut.http.annotation.Get;
 import io.micronaut.http.annotation.PathVariable;
 import io.micronaut.http.annotation.Post;
 import io.micronaut.http.multipart.CompletedFileUpload;
+import io.micronaut.security.annotation.Secured;
+import io.micronaut.security.rules.SecurityRule;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.media.ArraySchema;
 import io.swagger.v3.oas.annotations.media.Content;
@@ -45,6 +47,7 @@ import org.reactivestreams.Publisher;
  * REST endpoint allows to deployment code service.
  */
 @Controller("/management/v1/deployment/")
+@Secured(SecurityRule.IS_AUTHENTICATED)
 @Tag(name = "deployment")
 public interface DeploymentCodeApi {
 

Reply via email to