Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

22706 cli testscontainers and test reporting improvements #25885

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions .github/workflows/cli-cicd-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,15 @@ jobs:
BUILD_ID=$(basename "${{ github.ref }}")
fi

./mvnw clean verify
if [[ -z "${GITHUB_SHA}" ]]; then
BUILD_HASH=$(git log -1 --pretty=%h)
else
BUILD_HASH=${GITHUB_SHA::7}
fi

./mvnw clean verify -Dtest.failure.ignore=true

FAILURES=$(find target -name TEST-*.xml | xargs grep '<failure' | wc -l)
FAILURES=$(find . -name TEST-*.xml | xargs grep '<failure' | wc -l)

if [ $FAILURES -eq 0 ]; then
OUTPUT_STATUS="PASSED"
Expand Down Expand Up @@ -77,13 +83,14 @@ jobs:

for report in surefire failsafe
do
echo "<tr><td>${module}</td><td><a href=\"${module}/site/${report}-report.html\">${report} report</a></td></tr>" >> ${INDEX_FILE}
echo "<tr><td>${module}</td><td><a href=\"${module}/${report}-report.html\">${report} report</a></td></tr>" >> ${INDEX_FILE}
done
done

cat ${CICD_RES_PATH}/cli/cli-results-footer.html >> ${INDEX_FILE}

echo "BUILD_ID=${BUILD_ID}" >> "$GITHUB_ENV"
echo "BUILD_HASH=${BUILD_HASH}" >> $GITHUB_ENV
echo "results_location=${XML_REPORTS_PATH}" >> "$GITHUB_OUTPUT"
echo "results_report_location=${HTML_REPORTS_PATH}" >> "$GITHUB_OUTPUT"

Expand Down
3 changes: 3 additions & 0 deletions tools/dotcms-cli/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,6 @@ nb-configuration.xml

# Local environment
.env
/.allure/
/api-data-model/.allure/
/cli/.allure/
36 changes: 14 additions & 22 deletions tools/dotcms-cli/api-data-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
<testcontainers.version>1.17.6</testcontainers.version>
<skip.surefire.tests>false</skip.surefire.tests>
<skip.failsafe.tests>false</skip.failsafe.tests>
<test.failure.ignore>true</test.failure.ignore>
<test.failure.ignore>false</test.failure.ignore>
<maven.plugin.jar.version>3.3.0</maven.plugin.jar.version>
</properties>
<dependencyManagement>
<dependencies>
Expand Down Expand Up @@ -104,12 +105,6 @@
<artifactId>quarkus-devtools-registry-client</artifactId>
</dependency>

<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>junit-jupiter</artifactId>
Expand All @@ -124,21 +119,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>elasticsearch</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>


</dependencies>
<build>
<plugins>
Expand Down Expand Up @@ -206,6 +186,18 @@
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>${maven.plugin.jar.version}</version>
<executions>
<execution>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>

</build>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
@QuarkusTest
public class ContainerResource implements QuarkusTestResourceLifecycleManager {

private static final boolean TESTCONTAINERS_ENABLED;
private static final int POSTGRES_SERVICE_PORT;
private static final int ELASTICSEARCH_SERVICE_PORT;
private static final int DOTCMS_SERVICE_PORT;
Expand All @@ -35,6 +36,8 @@ public class ContainerResource implements QuarkusTestResourceLifecycleManager {

static {

TESTCONTAINERS_ENABLED = Boolean.parseBoolean(ConfigProvider.getConfig().getValue("testcontainers.enabled", String.class));

POSTGRES_SERVICE_PORT = Integer.parseInt(ConfigProvider.getConfig().getValue("testcontainers.postgres.service.port", String.class));
ELASTICSEARCH_SERVICE_PORT = Integer.parseInt(ConfigProvider.getConfig().getValue("testcontainers.elasticsearch.service.port", String.class));
DOTCMS_SERVICE_PORT = Integer.parseInt(ConfigProvider.getConfig().getValue("testcontainers.dotcms.service.port", String.class));
Expand All @@ -52,6 +55,7 @@ public class ContainerResource implements QuarkusTestResourceLifecycleManager {
dockerComposeContainer.withExposedService("dotcms", DOTCMS_SERVICE_PORT, Wait.forListeningPort().withStartupTimeout(Duration.ofSeconds(dockerComposeStartupTimeout)));
dockerComposeContainer.withEnv("DOTCMS_IMAGE", dockerImage);
dockerComposeContainer.withEnv("DOTCMS_LICENSE_FILE", dotcmsLicenseFile);
dockerComposeContainer.withPull(true);

if (isLoggerEnabled) {
dockerComposeContainer.withLogConsumer("dotcms", new Slf4jLogConsumer(LOGGER));
Expand All @@ -64,6 +68,11 @@ public class ContainerResource implements QuarkusTestResourceLifecycleManager {
@Override
public Map<String, String> start() {

if (!TESTCONTAINERS_ENABLED) {
LOGGER.info("Testcontainers are disabled. Skipping container startup.");
return new HashMap<>();
}

COMPOSE_CONTAINER.start();
final Map<String, String> conf = new HashMap<>();
conf.put("%test.dotcms.url", COMPOSE_CONTAINER.getServiceHost("dotcms", DOTCMS_SERVICE_PORT) + ":" + COMPOSE_CONTAINER.getServicePort("dotcms", DOTCMS_SERVICE_PORT));
Expand All @@ -73,6 +82,10 @@ public Map<String, String> start() {

@Override
public void stop() {
if (!TESTCONTAINERS_ENABLED) {
LOGGER.info("Testcontainers are disabled. Skipping container shutdown.");
return;
}
COMPOSE_CONTAINER.stop();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;

import static io.restassured.RestAssured.given;

@QuarkusTest
@QuarkusTestResource(ContainerResource.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
testcontainers.enabled=true
testcontainers.logger.enabled=true
testcontainers.docker.compose.local.enabled=false
testcontainers.docker.image=${DOTCMS_IMAGE:dotcms/dotcms:master_latest_SNAPSHOT}
testcontainers.docker.compose.file=src/test/resources/docker-compose.yaml
testcontainers.docker.compose.startup.timeout=120
testcontainers.dotcms.license.file=${DOTCMS_LICENSE_FILE}
# Setting 'testcontainers.dotcms.license.file' property is mandatory
# It is used to set the license file in the container
testcontainers.dotcms.license.file=${DOTCMS_LICENSE_FILE:/path/to/license/file.dat}
testcontainers.dotcms.service.port=8080
testcontainers.elasticsearch.service.port=9200
testcontainers.postgres.service.port=5432
31 changes: 11 additions & 20 deletions tools/dotcms-cli/cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<testcontainers.version>1.17.6</testcontainers.version>
<skip.surefire.tests>false</skip.surefire.tests>
<skip.failsafe.tests>false</skip.failsafe.tests>
<test.failure.ignore>true</test.failure.ignore>
<test.failure.ignore>false</test.failure.ignore>
</properties>
<dependencyManagement>
<dependencies>
Expand All @@ -44,6 +44,15 @@
<artifactId>api-data-model</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>com.dotcms</groupId>
<artifactId>api-data-model</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>test-jar</type>
<scope>test</scope>
</dependency>

<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-arc</artifactId>
Expand All @@ -63,11 +72,7 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
Expand All @@ -88,20 +93,6 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>postgresql</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>elasticsearch</artifactId>
<version>${testcontainers.version}</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.starxg</groupId>
<artifactId>java-keytar</artifactId>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@

import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;

import static io.restassured.RestAssured.given;

@QuarkusTest
@QuarkusTestResource(ContainerResource.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import org.junit.jupiter.api.Test;

@QuarkusTest
class RemoteTraversalServiceTest extends FilesTestHelper {
class RemoteTraversalServiceIntegrationTest extends FilesTestHelper {

@ConfigProperty(name = "com.dotcms.starter.site", defaultValue = "default")
String siteName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import picocli.CommandLine;

@QuarkusTest
class FilesPullCommandTest extends CommandTest {
class FilesPullCommandIntegrationTest extends CommandTest {

@Inject
AuthenticationContext authenticationContext;
Expand Down

This file was deleted.

Loading