Skip to Content
author's profile photo Former Member
Former Member

Best way to implement Integration tests to DataHub (5.6)

What is the best way to implement Integration test (aka, on a running datahub/tomcat server). Verify data in datahub, and successful status. Test should start server, run tests and rapport status, and then shutdown server.

Automated test, that you can run with maven command, or other solution. Looking for the recommendation on what to use here, and to fit in to run automated in a deployment process.

Guide lines, recommendations, working solutions that been implemented and working well?

Add a comment
10|10000 characters needed characters exceeded

Related questions

1 Answer

  • Posted on Sep 28, 2015 at 08:58 PM

    Here is a POM profile we have so far for performing automated integration tests.

    The profile is located in the parent pom and inherited by all pom projects using the parent pom.

    The complex part is to unpack the datahub instead of deploying the war file. And then the extensions to be tested. Also, the encryption-key.txt & local.properties has to be copied to the classes folder. The repetitions of the copy statements are to handle the unknown nesting of the projects.

    The mock-hybris-server-1.0-SNAPSHOT.jar is an internal tool to disable the ImpEx publication as the hybris platform is not in the scope of the test.

    The URL containing the dynamically allocate tomcat port number is obtained as follow :

     public static final String BASE_URL = System.getProperty("integration.test.url", "http://localhost:8080/datahub-webapp") + "/v1"; // Fallback to 8080
    

    Here is the maven pom profile :

         <!-- Maven Tomcat Plugin -->
         <profiles>
             <profile>
                 <id>tomcat-plugin-active</id>
                 <build>
                     <plugins>
                         <plugin>
                             <groupId>org.codehaus.mojo</groupId>
                             <artifactId>build-helper-maven-plugin</artifactId>
                             <version>1.9.1</version>
                             <executions>
                                 <execution>
                                     <id>default-cli</id>
                                     <goals>
                                         <goal>reserve-network-port</goal>
                                     </goals>
                                     <phase>pre-integration-test</phase>
                                     <configuration>
                                         <portNames>
                                             <portName>tomcat.http.port</portName>
                                         </portNames>
                                     </configuration>
                                 </execution>
                             </executions>
                         </plugin>
     
                         <plugin>
                             <groupId>org.apache.tomcat.maven</groupId>
                             <artifactId>tomcat7-maven-plugin</artifactId>
                             <version>2.2</version>
                             <configuration>
                                 <path>/datahub-webapp</path>
                                 <ignorePackaging>true</ignorePackaging>
                                 <warSourceDirectory>${project.build.directory}/datahub-webapp</warSourceDirectory>
                                 <port>${tomcat.http.port}</port>
                                 <systemProperties>
                                     <JAVA_OPTS>-Djava.net.preferIPv4Stack=true</JAVA_OPTS>
                                     <CATALINA_OPTS>-enableassertions</CATALINA_OPTS>
                                 </systemProperties>
                             </configuration>
                             <executions>
                                 <execution>
                                     <id>default-cli</id>
                                     <phase>pre-integration-test</phase>
                                     <goals>
                                         <goal>run</goal>
                                     </goals>
                                     <configuration>
                                         <fork>true</fork>
                                     </configuration>
                                 </execution>
                                 <execution>
                                     <id>stop-tomcat</id>
                                     <phase>post-integration-test</phase>
                                     <goals>
                                         <goal>shutdown</goal>
                                     </goals>
                                 </execution>
                             </executions>
                         </plugin>
     
                         <plugin>
                             <groupId>org.apache.maven.plugins</groupId>
                             <artifactId>maven-failsafe-plugin</artifactId>
                             <version>2.18.1</version>
                             <configuration>
                                 <systemPropertyVariables>
                                     <integration.test.url>http://localhost:${tomcat.http.port}/datahub-webapp</integration.test.url>
                                 </systemPropertyVariables>
                                 <includes>
                                     <include>**/*IntegrationTest.java</include>
                                     <include>**/*IT.java</include>
                                 </includes>
                             </configuration>
                             <executions>
                                 <execution>
                                     <goals>
                                         <goal>integration-test</goal>
                                         <goal>verify</goal>
                                     </goals>
                                 </execution>
                             </executions>
                         </plugin>
     
                         <plugin>
                             <groupId>org.apache.maven.plugins</groupId>
                             <artifactId>maven-dependency-plugin</artifactId>
                             <executions>
                                 <execution>
                                     <id>default-cli</id>
                                     <phase>prepare-package</phase>
                                     <goals>
                                         <goal>unpack</goal>
                                     </goals>
                                     <configuration>
                                         <artifactItems>
                                             <artifactItem>
                                                 <groupId>com.hybris.datahub</groupId>
                                                 <artifactId>datahub-webapp</artifactId>
                                                 <version>${datahub.version}</version>
                                                 <type>war</type>
                                                 <overWrite>true</overWrite>
                                                 <outputDirectory>${project.build.directory}/datahub-webapp
                                                 </outputDirectory>
                                             </artifactItem>
                                         </artifactItems>
                                         <includes>**/*</includes>
                                     </configuration>
                                 </execution>
                             </executions>
                         </plugin>
                         <!-- Copy the local.properties file to the tomcat WEB-INF/classes directory -->
                         <plugin>
                             <artifactId>maven-antrun-plugin</artifactId>
                             <version>1.6</version>
                             <executions>
                                 <execution>
                                     <id>copy-local-props</id>
                                     <phase>package</phase>
                                     <configuration>
                                         <target>
                                             <copy failonerror="false" file="${basedir}/../../../parent-pom/local.properties"   tofile="${project.build.directory}/datahub-webapp/WEB-INF/classes/local.properties" />
                                             <copy failonerror="false" file="${basedir}/../../../parent-pom/encryption-key.txt" tofile="${project.build.directory}/datahub-webapp/WEB-INF/classes/encryption-key.txt" />
                                             <copy failonerror="false" file="${basedir}/../../parent-pom/local.properties"      tofile="${project.build.directory}/datahub-webapp/WEB-INF/classes/local.properties" />
                                             <copy failonerror="false" file="${basedir}/../../parent-pom/encryption-key.txt"    tofile="${project.build.directory}/datahub-webapp/WEB-INF/classes/encryption-key.txt" />
                                             <copy failonerror="false" file="${basedir}/../parent-pom/local.properties"         tofile="${project.build.directory}/datahub-webapp/WEB-INF/classes/local.properties" />
                                             <copy failonerror="false" file="${basedir}/../parent-pom/encryption-key.txt"       tofile="${project.build.directory}/datahub-webapp/WEB-INF/classes/encryption-key.txt" />
                                             <copy failonerror="false" file="${basedir}/local.properties"                       tofile="${project.build.directory}/datahub-webapp/WEB-INF/classes/local.properties" />
                                             <copy failonerror="false" file="${basedir}/encryption-key.txt"                     tofile="${project.build.directory}/datahub-webapp/WEB-INF/classes/encryption-key.txt" />
                                             <copy failonerror="false" file="${basedir}/../../../parent-pom/mock-hybris-server-1.0-SNAPSHOT.jar" tofile="${project.build.directory}/datahub-webapp/WEB-INF/lib/mock-hybris-server-1.0-SNAPSHOT.jar" />
                                             <copy failonerror="false" file="${basedir}/../../parent-pom/mock-hybris-server-1.0-SNAPSHOT.jar"    tofile="${project.build.directory}/datahub-webapp/WEB-INF/lib/mock-hybris-server-1.0-SNAPSHOT.jar" />
                                             <copy failonerror="false" file="${basedir}/../parent-pom/mock-hybris-server-1.0-SNAPSHOT.jar"       tofile="${project.build.directory}/datahub-webapp/WEB-INF/lib/mock-hybris-server-1.0-SNAPSHOT.jar" />
                                             <copy failonerror="false" file="${basedir}/mock-hybris-server-1.0-SNAPSHOT.jar"                     tofile="${project.build.directory}/datahub-webapp/WEB-INF/lib/mock-hybris-server-1.0-SNAPSHOT.jar" />
                                         </target>
                                     </configuration>
                                     <goals>
                                         <goal>run</goal>
                                     </goals>
                                 </execution>
                             </executions>
                         </plugin>
                     </plugins>
                 </build>
             </profile>
    
    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.