From 2dfa24ee91c075884e8b89e4ba9145aa2a8e7317 Mon Sep 17 00:00:00 2001 From: Nidhi Date: Wed, 25 Dec 2024 02:08:49 +0530 Subject: [PATCH] chore: Added capability of running ITs on maven (#38354) --- .../git/templates/contexts/GitContext.java | 1 + .../git/GitServerInitializerExtension.java | 14 ++--- app/server/pom.xml | 62 +++++++++++++++++++ 3 files changed, 68 insertions(+), 9 deletions(-) diff --git a/app/server/appsmith-server/src/test/it/com/appsmith/server/git/templates/contexts/GitContext.java b/app/server/appsmith-server/src/test/it/com/appsmith/server/git/templates/contexts/GitContext.java index e383a0eadb92..a3b6a31f1eaa 100644 --- a/app/server/appsmith-server/src/test/it/com/appsmith/server/git/templates/contexts/GitContext.java +++ b/app/server/appsmith-server/src/test/it/com/appsmith/server/git/templates/contexts/GitContext.java @@ -25,6 +25,7 @@ public GitContext( ExtensionContext.Store contextStore = extensionContext.getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class)); contextStore.put(ArtifactExchangeJson.class, artifactExchangeJsonType); contextStore.put("filePath", fileName); + contextStore.put("artifactType", artifactType); this.fileName = fileName; this.artifactExchangeJsonType = artifactExchangeJsonType; } diff --git a/app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java b/app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java index 9605c769562a..1e5a56fe4cae 100644 --- a/app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java +++ b/app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java @@ -1,12 +1,11 @@ package com.appsmith.server.git; import com.appsmith.git.configurations.GitServiceConfig; -import com.appsmith.server.applications.base.ApplicationService; +import com.appsmith.server.artifacts.base.ArtifactService; +import com.appsmith.server.constants.ArtifactType; import com.appsmith.server.constants.FieldName; import com.appsmith.server.domains.GitAuth; import com.appsmith.server.dtos.ArtifactExchangeJson; -import com.appsmith.server.git.common.CommonGitService; -import org.assertj.core.api.Assertions; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.AfterEachCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; @@ -19,8 +18,6 @@ import org.springframework.web.reactive.function.client.WebClient; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; -import org.testcontainers.junit.jupiter.Container; -import org.testcontainers.junit.jupiter.Testcontainers; import reactor.core.publisher.Mono; import java.nio.file.Path; @@ -40,7 +37,7 @@ public class GitServerInitializerExtension implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback, AfterAllCallback { @Autowired - ApplicationService applicationService; + ArtifactService artifactService; @Autowired GitServiceConfig gitServiceConfig; @@ -59,8 +56,7 @@ public void beforeAll(ExtensionContext extensionContext) { @Override public void beforeEach(ExtensionContext extensionContext) { ExtensionContext.Store parentContextStore = extensionContext.getParent().get().getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class)); - Class aClass = parentContextStore.get(ArtifactExchangeJson.class, Class.class); - String filePath = parentContextStore.get("filePath", String.class); + ArtifactType artifactType = parentContextStore.get("artifactType", ArtifactType.class); ExtensionContext.Store contextStore = extensionContext.getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class)); String artifactId = contextStore.get(FieldName.ARTIFACT_ID, String.class); @@ -68,7 +64,7 @@ public void beforeEach(ExtensionContext extensionContext) { // TODO : Move this to artifact service to enable packages // Generate RSA public key for the given artifact - Mono gitAuthMono = applicationService.createOrUpdateSshKeyPair(artifactId, "RSA"); + Mono gitAuthMono = artifactService.createOrUpdateSshKeyPair(artifactType, artifactId, "RSA"); String tedGitApiPath = "http://" + gitContainer.getHost() + ":" + gitContainer.getMappedPort(4200) + "/api/v1/git/"; diff --git a/app/server/pom.xml b/app/server/pom.xml index 814ba6851871..31ecd38c587d 100644 --- a/app/server/pom.xml +++ b/app/server/pom.xml @@ -43,6 +43,9 @@ 3.5.1 true + ${skipTests} + false + ${skipTests} 2.0 true @@ -74,6 +77,30 @@ maven-dependency-plugin 3.4.0 + + org.codehaus.mojo + build-helper-maven-plugin + 3.3.0 + + + add-test-source + + add-test-source + + generate-test-sources + + + src/test/java + + src/test/it + + src/test/utils + + + + + + org.apache.maven.plugins maven-surefire-plugin @@ -84,6 +111,41 @@ --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED + src/test/java + ${skipUTs} + + + + org.junit.jupiter + junit-jupiter-engine + 5.6.2 + + + org.junit.platform + junit-platform-commons + + + + + + + org.apache.maven.plugins + maven-failsafe-plugin + 3.0.0-M5 + + true + + -ea + --add-opens java.base/java.lang=ALL-UNNAMED + --add-opens java.base/java.time=ALL-UNNAMED + --add-opens java.base/java.util=ALL-UNNAMED + + ../dist/plugins + + + src/test/it + ${skipITs} +