Product Acceptance Test

This Product Acceptance Test (PAT) demonstrates one way to validate learned cluster data that is written to the output catalog. For the code, see

Running the Test Locally

The following prerequisites apply to running the PAT locally.

  • Prepare your data catalogs before running your PATs.
  • Start the pipeline you are testing at the beginning of a test and stop the pipeline at the end of the test.
  • Since the test publishes the following partition to your input catalog, update the input partition name to ensure it contains a timestamp within the configured window of the pipeline processing logic.

    This partition contains the data that is processed by the pipeline and validated as part of the testing step.

  • After the pipeline has finished processing the input data, download the partition "23611423" from the output catalog. The Integration test executable JAR uses this partition as input.

To run the tests from command line, enter the following command.

java -jar  -Dpartition=<output partition path>/23611423 <executable jar path>/p2-learning-processor-standalone-<VERSION>-it-tests.jar

Expected test execution output.

JUnit version 4.12
Time: 0.278

OK (1 test)

Running the Test from Jenkins

The "Prepare test catalogs" stage sets up the environment for testing with the following steps:

  • creates input and output catalogs for the test following the recipe from the file
  • reads a cluster data archive partition tile from the file system
  • changes the date to the current date in the file name, which triggers processing
  • loads the partition into the input catalog
    pipeline_config = helper.preparePipelineConfig(pipeline_config_path, path_prefix, deployment)

    def input_partition_id = "1475716_20180522155459_20180522153926_20180522155455_10." +
    def input_partition_file_path = "${WORKSPACE}/test_data/target/dependency/${input_partition_id}"

    // Changing the date to the current date in the file name (which will trigger processing).
    def now = new Date()
    def fileParts = input_partition_id.split("_")
    fileParts[1] = now.format("yyyyMMddHHmmss", TimeZone.getTimeZone('UTC'))
    def partitionID = fileParts.join("_")

    putPartitions(helper, pipeline_config["archive-catalog"], "sdii-data-archive", [partitionID: input_partition_file_path])

The "Run Product Acceptance Tests" stage executes the following steps:

  • retrieves the defined partition for verification by PATTest.
  • executes PATTest to verify the data.
    def output_partitions = ["23611423"]
    getPartitions(helper, pipeline_config["output"], "data-learnings", output_partitions, WORKSPACE)

    // Run tests
    output_partitions.each { partition ->
        sh("java -jar -Dpartition=${WORKSPACE}/${partition} ${WORKSPACE}/${env.PROJECT_ARTIFACT_ID}-${env.PROJECT_VERSION}-it-tests.jar")

Integration Tests Runner

Integration tests are written to execute JUnit tests. PATTestRunner is the entry-point for executing JUnit tests from the executable jar.

import org.junit.runner.JUnitCore;

public class PATTestRunner {
    public static void main(String[] args) {

Annotate Your Test Classes

import org.junit.experimental.categories.Category;
public class PatTest{

    public void outputDataValidationTest() throws Exception {

Configure Your Maven Profile to Build the Executable Jar

The Maven assembly plugin must be configured to build an executable JAR that includes all required dependencies.


Configure Assembly Plugin Descriptor File

The assembly descriptor file includes/excludes dependencies and files needed for building the executable JAR.

<assembly xmlns=""
            <!-- we're creating the test-jar as an attachment -->
                <include>1475716_20180522155459_20180522153926_20180522155455_10._48.159957275016836_48.080087029569135_12.040017134498243_11.896950104895032 </include>

results matching ""

    No results matching ""