Skip to content

Commit

Permalink
#27059: including fabric8.io maven docker plugin to run postman tests
Browse files Browse the repository at this point in the history
  • Loading branch information
victoralfaro-dotcms committed Jan 17, 2024
1 parent 61d8960 commit 29c917e
Show file tree
Hide file tree
Showing 5 changed files with 183 additions and 63 deletions.
29 changes: 18 additions & 11 deletions .github/workflows/maven-cicd-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref || github.run_id }}
cancel-in-progress: true
env:
JVM_TEST_MAVEN_OPTS: "-e -B -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
JVM_TEST_MAVEN_OPTS: "-e -B --no-transfer-progress -Dorg.slf4j.simpleLogger.log.org.apache.maven.cli.transfer.Slf4jMavenTransferListener=warn"
DOCKER_PLATFORMS: "linux/amd64,linux/arm64"
REGISTRY: ghcr.io
IMAGE_NAME: dotcms/dotcms_test
Expand Down Expand Up @@ -187,7 +187,6 @@ jobs:
- name: Setup Context
id: setup-docker-context
run: |
mkdir -p $DOCKER_BUILD_CONTEXT/context
tar -xvf $DOCKER_BUILD_CONTEXT/docker-build.tar -C $DOCKER_BUILD_CONTEXT/context
- name: Build base image
Expand Down Expand Up @@ -407,7 +406,7 @@ jobs:
shell: bash
env:
NODE_CACHE_HIT: ${{ steps.cache-node-modules.outputs.cache-hit }}
run: eval ./mvnw -Dprod $JVM_TEST_MAVEN_OPTS -Dskip.npm.install=${NODE_CACHE_HIT} $JVM_TEST_MAVEN_OPTS -pl :dotcms-core-web test
run: eval ./mvnw -Dprod -Dskip.npm.install=${NODE_CACHE_HIT} $JVM_TEST_MAVEN_OPTS -pl :dotcms-core-web test
- name: Prepare failure archive (if maven failed)
if: failure()
shell: bash
Expand Down Expand Up @@ -551,22 +550,30 @@ jobs:
with:
current: ${{ matrix.collection_group }}
- name: Prepare license
id: prepare-license
run: |
mkdir -p dotcms-postman/license
touch dotcms-postman/license/license.dat
echo "${{ secrets.DOTCMS_LICENSE }}" > dotcms-postman/license/license.dat
chmod 777 dotcms-postman/license/license.dat
docker_volumes_dir=${{ github.workspace }}/dotcms-postman/target/docker-volumes
[[ -d ${docker_volumes_dir} ]] && rm -rf ${docker_volumes_dir}
dotcms_volumes_dir=${docker_volumes_dir}/dotcms
license_dir=${dotcms_volumes_dir}/license
mkdir -p ${license_dir} #${dotcms_volumes_dir}/cms-shared ${dotcms_volumes_dir}/cms-local
license_file=${license_dir}/license.dat
touch ${license_file}
echo "${{ secrets.DOTCMS_LICENSE }}" > ${license_file}
chmod -R 777 ${license_dir}
- id: run-postman-tests
name: Run Postman Tests
timeout-minutes: 90
run: |
./mvnw $JVM_TEST_MAVEN_OPTS verify \
./mvnw -Dpostman-tests -Dprod $JVM_TEST_MAVEN_OPTS verify \
-pl :dotcms-postman \
-Dpostman.collections=\"${{ steps.resolve-postman-collections.outputs.collections_to_run }}\"
-Dpostman.collections="${{ steps.resolve-postman-collections.outputs.collections_to_run }}"
pec=$?
[[ pec -eq 0 ]] || exit pec
env:
JVM_TEST_MAVEN_OPTS: "-e -B"
DOTCMS_IMAGE: ${{ needs.build-jdk11.outputs.docker-tag }}
- name: Prepare reports archive (if maven failed)
if: failure()
Expand All @@ -587,7 +594,7 @@ jobs:
with:
name: "build-reports-test-postman - ${{ matrix.collection_group }}"
path: |
**/target/*-reports/TEST-*.xml
**/dotcms-postman/target/postman-reports/TEST-*.xml
target/build-report.json
LICENSE
retention-days: 2
Expand Down
10 changes: 6 additions & 4 deletions dotCMS/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,9 @@ dependencies {
implementation (group: 'com.h2database', name: 'h2', version: '2.1.214'){}
implementation (group: 'com.impossibl.pgjdbc-ng', name: 'pgjdbc-ng', version: '0.8.9'){}
implementation (group: 'com.impossibl.pgjdbc-ng', name: 'spy', version: '0.8.9'){}
implementation (group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0'){}
implementation (group: 'com.jayway.jsonpath', name: 'json-path', version: '2.4.0') {
exclude group: 'net.minidev', module: 'json-smart'
}
implementation (group: 'com.lmax', name: 'disruptor', version: '3.3.4'){}
implementation (group: 'com.maxmind.db', name: 'maxmind-db', version: '1.0.0'){}
implementation (group: 'com.maxmind.geoip2', name: 'geoip2', version: '2.1.0'){}
Expand Down Expand Up @@ -246,8 +248,8 @@ dependencies {
implementation (group: 'net.javacrumbs.shedlock', name: 'shedlock-provider-jdbc-internal', version: '4.33.0'){}
implementation (group: 'net.javacrumbs.shedlock', name: 'shedlock-provider-jdbc', version: '4.33.0'){}
implementation (group: 'net.jodah', name: 'failsafe', version: '1.1.1'){}
implementation (group: 'net.minidev', name: 'accessors-smart', version: '1.2'){}
implementation (group: 'net.minidev', name: 'json-smart', version: '2.3'){}
implementation (group: 'net.minidev', name: 'accessors-smart', version: '2.4.9'){}
implementation (group: 'net.minidev', name: 'json-smart', version: '2.4.9'){}
implementation (group: 'net.sf.jopt-simple', name: 'jopt-simple', version: '5.0.2') {
transitive=false
}
Expand Down Expand Up @@ -426,7 +428,7 @@ dependencies {
implementation (group: 'org.jvnet.mimepull', name: 'mimepull', version: '1.9.6'){}
testImplementation (group: 'org.mockito', name: 'mockito-core', version: '2.28.2'){}
testImplementation (group: 'org.objenesis', name: 'objenesis', version: '2.5.1'){}
implementation (group: 'org.ow2.asm', name: 'asm', version: '5.0.4'){}
implementation (group: 'org.ow2.asm', name: 'asm', version: '9.3'){}
compileOnly (group: 'org.postgresql', name: 'postgresql', version: '42.5.1') {
exclude group: 'org.checkerframework', module: 'checker-qual'
}
Expand Down
192 changes: 145 additions & 47 deletions dotcms-postman/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,85 +13,183 @@
<version>1.0.0-SNAPSHOT</version>

<properties>
<version.cargo.plugin>1.10.6</version.cargo.plugin>
<tomcat.version>9.0.60</tomcat.version>
<db.port>5432</db.port>
<es.port>9200</es.port>
<tomcat.port>8080</tomcat.port>
<docker.version.tag>${project.version}</docker.version.tag>
<docker.push.skip>true</docker.push.skip>
<docker.platforms></docker.platforms>
<fabric8.dynamic-port>true</fabric8.dynamic-port>
<skipDockerEnv>false</skipDockerEnv>
<clean.docker.volumes>true</clean.docker.volumes>

<buildDocker>true</buildDocker>
<docker.base.image>tomcat:9.0.74-jdk11</docker.base.image>

<it.test.forkcount>4</it.test.forkcount>
<testdata.dir>${project.build.directory}/testdata</testdata.dir>
<it.test.fork-folder.prefix>${project.build.directory}/testdata/fork-</it.test.fork-folder.prefix>
<it.test.fork-folder>${it.test.fork-folder.prefix}</it.test.fork-folder>
<cleanup.before.tests>true</cleanup.before.tests>
</properties>

<build>
<plugins>
<plugin>
<groupId>com.dkanejs.maven.plugins</groupId>
<artifactId>docker-compose-maven-plugin</artifactId>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<configuration>
<services>
<service>db-test</service>
<service>elasticsearch-test</service>
<service>dotcms-test</service>
</services>
<removeVolumes>false</removeVolumes>
<projectName>cargo-it</projectName>
<removeImages>true</removeImages>
<removeImagesType>local</removeImagesType>
<skip>${skipDockerEnv}</skip>
<composeFile>${project.basedir}/docker-compose.yml</composeFile>
<detachedMode>false</detachedMode>
<removeVolumes>true</removeVolumes>
<showLogs>true</showLogs>
<follow>true</follow>
<imagesMap>
<dotcms>
<name>${DOTCMS_IMAGE}</name>
<external>
<type>properties</type>
<prefix>dockerCore</prefix>
<mode>override</mode>
</external>
<build>
<cleanup>false</cleanup>
<dockerFileDir>${project.basedir}/src/main/docker/original</dockerFileDir>
<buildx>
<platforms>
<platform>${docker.platforms}</platform>
</platforms>
</buildx>
<assembly>
<descriptor>original/docker-descriptor.xml</descriptor>
<targetDir>/maven</targetDir>
</assembly>
</build>
<run>
<ports>
<port>tomcat.port:${tomcat.port}</port>
</ports>
<env>
<file.encoding>UTF-8</file.encoding>
<CATALINA_OPTS>-XX:+PrintFlagsFinal</CATALINA_OPTS>

<!-- Why is this without DOT_ -->
<DB_BASE_URL>jdbc:postgresql://db:5432/dotcms?autosave=conservative</DB_BASE_URL>
<DB_USERNAME>postgres</DB_USERNAME>
<DB_PASSWORD>postgres</DB_PASSWORD>
<DB_MAX_TOTAL>15</DB_MAX_TOTAL>

<DOT_DB_DRIVER>org.postgresql.Driver</DOT_DB_DRIVER>
<DOT_DB_BASE_URL>jdbc:postgresql://db:5432/dotcms?autosave=conservative</DOT_DB_BASE_URL>
<DOT_DOTCMS_DEV_MODE>true</DOT_DOTCMS_DEV_MODE>
<DOT_DATASOURCE_PROVIDER_STRATEGY_CLASS>com.dotmarketing.db.SystemEnvDataSourceStrategy</DOT_DATASOURCE_PROVIDER_STRATEGY_CLASS>
<DOT_ES_ENDPOINTS>http://es:9200</DOT_ES_ENDPOINTS>
<DOT_ES_PROTOCOL>http</DOT_ES_PROTOCOL>
<DOT_INDEX_POLICY_SINGLE_CONTENT>FORCE</DOT_INDEX_POLICY_SINGLE_CONTENT>
<DOT_ASYNC_REINDEX_COMMIT_LISTENERS>false</DOT_ASYNC_REINDEX_COMMIT_LISTENERS>
<DOT_ASYNC_COMMIT_LISTENERS>false</DOT_ASYNC_COMMIT_LISTENERS>
<DOT_CACHE_GRAPHQLQUERYCACHE_SECONDS>600</DOT_CACHE_GRAPHQLQUERYCACHE_SECONDS>
<DOT_ENABLE_SCRIPTING>true</DOT_ENABLE_SCRIPTING>

<WAIT_FOR_DEPS>15</WAIT_FOR_DEPS>
<JVM_ENDPOINT_TEST_PASS>obfuscate_me</JVM_ENDPOINT_TEST_PASS>
</env>
<volumes>
<bind>
<volume>${project.build.directory}/docker-volumes/dotcms/license/license.dat:/data/local/dotsecure/license/license.dat:rw</volume>
</bind>
</volumes>
<wait>
<log>Started bridged http service</log>
<time>200000</time>
</wait>
<links>
<link>database:db</link>
<link>elasticsearch:es</link>
</links>
<log>
<prefix>DOTCMS:</prefix>
<color>cyan</color>
</log>
</run>
</dotcms>
<database>
<name>postgres:15</name>
<run>
<cmd>postgres -c max_connections=400 -c shared_buffers=128MB</cmd>
<ports>
<port>db.port:${db.port}</port>
</ports>
<env>
<POSTGRES_USER>postgres</POSTGRES_USER>
<POSTGRES_PASSWORD>postgres</POSTGRES_PASSWORD>
<POSTGRES_DB>dotcms</POSTGRES_DB>
</env>
<wait>
<log>database system is ready to accept connections</log>
<time>20000</time>
</wait>
<log>
<prefix>DB:</prefix>
<color>magenta</color>
</log>
</run>
</database>
<elasticsearch>
<name>docker.elastic.co/elasticsearch/elasticsearch:7.11.2</name>
<run>
<env>
<cluster.name>elastic-cluster</cluster.name>
<discovery.type>single-node</discovery.type>
<data></data>
<bootstrap.memory_lock>true</bootstrap.memory_lock>
<bootstrap.system_call_filter>false</bootstrap.system_call_filter>
<CLI_JAVA_OPTS>-Xms3g -Xmx3g</CLI_JAVA_OPTS>
</env>
<ports>
<port>es.port:9200</port>
</ports>
<ulimits>
<ulimit>
<name>memlock</name>
<hard>-1</hard>
<soft>-1</soft>
</ulimit>
</ulimits>
<wait>
<http>
<url>http://localhost:${es.port}</url>
</http>
<time>30000</time>
</wait>

<log>
<prefix>ES:</prefix>
<color>blue</color>
</log>
</run>
</elasticsearch>
</imagesMap>
</configuration>
<executions>
<execution>
<id>up</id>
<id>pt-up</id>
<phase>pre-integration-test</phase>
<goals>
<goal>down</goal>
<goal>up</goal>
<goal>start</goal>
</goals>
<configuration>
<skip>${skipITs}</skip>
<removeVolumes>${clean.docker.volumes}</removeVolumes>
<ignorePullFailures>true</ignorePullFailures>
<detachedMode>true</detachedMode>
<verbose>false</verbose>
<services>
<service>db-test</service>
<service>elasticsearch-test</service>
<service>dotcms-test</service>
</services>
</configuration>
</execution>
<execution>
<id>down</id>
<phase>verify</phase>
<id>pt-down</id>
<phase>post-integration-test</phase>
<goals>
<goal>down</goal>
<goal>stop</goal>
</goals>
<configuration>
<skip>${skipITs}</skip>
<services>
<service>db-test</service>
<service>elasticsearch-test</service>
<service>dotcms-test</service>
</services>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${version.exec.plugin}</version>
<executions>
<execution>
<id>integration-tests</id>
<id>postman-tests</id>
<phase>integration-test</phase>
<goals>
<goal>exec</goal>
Expand Down
2 changes: 1 addition & 1 deletion dotcms-postman/runtests.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

wait=60
wait=2
echo "Waiting for ${wait} seconds to images be pulled"
sleep $wait
docker-compose logs -t -f dotcms-test &
Expand Down
13 changes: 13 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@
<module>reports</module>
</modules>
</profile>

<profile>
<id>postman-tests</id>
<activation>
<property>
<name>postman-tests</name>
</property>
</activation>
<modules>
<module>dotcms-postman</module>
<module>reports</module>
</modules>
</profile>
</profiles>

</project>

0 comments on commit 29c917e

Please sign in to comment.