Skip to content

Commit 2dfa24e

Browse files
authored
chore: Added capability of running ITs on maven (#38354)
1 parent a8cb8aa commit 2dfa24e

File tree

3 files changed

+68
-9
lines changed

3 files changed

+68
-9
lines changed

app/server/appsmith-server/src/test/it/com/appsmith/server/git/templates/contexts/GitContext.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public GitContext(
2525
ExtensionContext.Store contextStore = extensionContext.getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class));
2626
contextStore.put(ArtifactExchangeJson.class, artifactExchangeJsonType);
2727
contextStore.put("filePath", fileName);
28+
contextStore.put("artifactType", artifactType);
2829
this.fileName = fileName;
2930
this.artifactExchangeJsonType = artifactExchangeJsonType;
3031
}

app/server/appsmith-server/src/test/utils/com/appsmith/server/git/GitServerInitializerExtension.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
package com.appsmith.server.git;
22

33
import com.appsmith.git.configurations.GitServiceConfig;
4-
import com.appsmith.server.applications.base.ApplicationService;
4+
import com.appsmith.server.artifacts.base.ArtifactService;
5+
import com.appsmith.server.constants.ArtifactType;
56
import com.appsmith.server.constants.FieldName;
67
import com.appsmith.server.domains.GitAuth;
78
import com.appsmith.server.dtos.ArtifactExchangeJson;
8-
import com.appsmith.server.git.common.CommonGitService;
9-
import org.assertj.core.api.Assertions;
109
import org.junit.jupiter.api.extension.AfterAllCallback;
1110
import org.junit.jupiter.api.extension.AfterEachCallback;
1211
import org.junit.jupiter.api.extension.BeforeAllCallback;
@@ -19,8 +18,6 @@
1918
import org.springframework.web.reactive.function.client.WebClient;
2019
import org.testcontainers.containers.GenericContainer;
2120
import org.testcontainers.containers.wait.strategy.Wait;
22-
import org.testcontainers.junit.jupiter.Container;
23-
import org.testcontainers.junit.jupiter.Testcontainers;
2421
import reactor.core.publisher.Mono;
2522

2623
import java.nio.file.Path;
@@ -40,7 +37,7 @@
4037
public class GitServerInitializerExtension implements BeforeAllCallback, BeforeEachCallback, AfterEachCallback, AfterAllCallback {
4138

4239
@Autowired
43-
ApplicationService applicationService;
40+
ArtifactService artifactService;
4441

4542
@Autowired
4643
GitServiceConfig gitServiceConfig;
@@ -59,16 +56,15 @@ public void beforeAll(ExtensionContext extensionContext) {
5956
@Override
6057
public void beforeEach(ExtensionContext extensionContext) {
6158
ExtensionContext.Store parentContextStore = extensionContext.getParent().get().getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class));
62-
Class<? extends ArtifactExchangeJson> aClass = parentContextStore.get(ArtifactExchangeJson.class, Class.class);
63-
String filePath = parentContextStore.get("filePath", String.class);
59+
ArtifactType artifactType = parentContextStore.get("artifactType", ArtifactType.class);
6460
ExtensionContext.Store contextStore = extensionContext.getStore(ExtensionContext.Namespace.create(ArtifactBuilderExtension.class));
6561

6662
String artifactId = contextStore.get(FieldName.ARTIFACT_ID, String.class);
6763
String repoName = "test" + artifactId;
6864

6965
// TODO : Move this to artifact service to enable packages
7066
// Generate RSA public key for the given artifact
71-
Mono<GitAuth> gitAuthMono = applicationService.createOrUpdateSshKeyPair(artifactId, "RSA");
67+
Mono<GitAuth> gitAuthMono = artifactService.createOrUpdateSshKeyPair(artifactType, artifactId, "RSA");
7268

7369
String tedGitApiPath = "http://" + gitContainer.getHost() + ":" + gitContainer.getMappedPort(4200) + "/api/v1/git/";
7470

app/server/pom.xml

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@
4343
<reactor-test.version>3.5.1</reactor-test.version>
4444
<!-- By default skip the dockerization step. Only activate if necessary -->
4545
<skipDockerBuild>true</skipDockerBuild>
46+
<skipITs>${skipTests}</skipITs>
47+
<skipTests>false</skipTests>
48+
<skipUTs>${skipTests}</skipUTs>
4649
<!-- We're forcing this version temporarily to fix CVE-2022-1471-->
4750
<snakeyaml.version>2.0</snakeyaml.version>
4851
<source.disabled>true</source.disabled>
@@ -74,6 +77,30 @@
7477
<artifactId>maven-dependency-plugin</artifactId>
7578
<version>3.4.0</version>
7679
</plugin>
80+
<plugin>
81+
<groupId>org.codehaus.mojo</groupId>
82+
<artifactId>build-helper-maven-plugin</artifactId>
83+
<version>3.3.0</version>
84+
<executions>
85+
<execution>
86+
<id>add-test-source</id>
87+
<goals>
88+
<goal>add-test-source</goal>
89+
</goals>
90+
<phase>generate-test-sources</phase>
91+
<configuration>
92+
<sources>
93+
<source>src/test/java</source>
94+
<!-- Default test directory -->
95+
<source>src/test/it</source>
96+
<!-- Additional test directory -->
97+
<source>src/test/utils</source>
98+
<!-- Another additional directory -->
99+
</sources>
100+
</configuration>
101+
</execution>
102+
</executions>
103+
</plugin>
77104
<plugin>
78105
<groupId>org.apache.maven.plugins</groupId>
79106
<artifactId>maven-surefire-plugin</artifactId>
@@ -84,6 +111,41 @@
84111
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED
85112
--add-opens java.base/java.time=ALL-UNNAMED
86113
--add-opens java.base/java.util=ALL-UNNAMED</argLine>
114+
<testSourceDirectory>src/test/java</testSourceDirectory>
115+
<skipTests>${skipUTs}</skipTests>
116+
</configuration>
117+
<dependencies>
118+
<dependency>
119+
<groupId>org.junit.jupiter</groupId>
120+
<artifactId>junit-jupiter-engine</artifactId>
121+
<version>5.6.2</version>
122+
<exclusions>
123+
<exclusion>
124+
<groupId>org.junit.platform</groupId>
125+
<artifactId>junit-platform-commons</artifactId>
126+
</exclusion>
127+
</exclusions>
128+
</dependency>
129+
</dependencies>
130+
</plugin>
131+
<plugin>
132+
<groupId>org.apache.maven.plugins</groupId>
133+
<artifactId>maven-failsafe-plugin</artifactId>
134+
<version>3.0.0-M5</version>
135+
<configuration>
136+
<printSummary>true</printSummary>
137+
<!-- Allow JUnit to access the test classes -->
138+
<argLine>-ea
139+
--add-opens java.base/java.lang=ALL-UNNAMED
140+
--add-opens java.base/java.time=ALL-UNNAMED
141+
--add-opens java.base/java.util=ALL-UNNAMED</argLine>
142+
<systemPropertyVariables>
143+
<pf4j.pluginsDir>../dist/plugins</pf4j.pluginsDir>
144+
<!-- Specify plugin directory -->
145+
</systemPropertyVariables>
146+
<testSourceDirectory>src/test/it</testSourceDirectory>
147+
<skipITs>${skipITs}</skipITs>
148+
<!-- Property for skipping integration tests -->
87149
</configuration>
88150
<dependencies>
89151
<dependency>

0 commit comments

Comments
 (0)