KCOP test harness

The KCOP test harness is a stand-alone Java™ application that is designed to call any KCOP class by using pre-made records from a text file and display the producer record output in a formatted manner. Its primary purpose is to run any KCOP class aside from CDC for Kafka.

Important: KCOP test harness application is only compatible with 11.4.0.4-5740 and later.

Running the Java Application KcopTestHarness.java

The Java™ application KcopTestHarness.java can be run with these optional parameters:
  • Kcop class
    • Specifies the KCOP class to run. If not, KcopDefaultBehaviorIntegrated is used.
  • Kcop.properties
    • The configuration file is used to set KCOP properties.
  • records.txt
    • It contains pre-made records for the KCOP class.
  • isAvroKcop=true/false
    • It indicates whether the selected KCOP class uses AVRO or JSON.
Note: It is advised that you run the Java™ application without any parameters for the first time. This generates sensitive files in their default format.

Procedure

  1. Got to CDC-KAFKA-INSTALL-DIR/samples. Extract the kafka-kcop-test-harness-11.4.0.x-xxxx-repository.zip file.
    Note: The extracted zip contains both the source code and all of the dependencies that are required to run the application in the kafka-kcop-test-harness-11.4.0.x-xxxx-sources.jar file.
  2. Run the following commands:
    unzip kafka-kcop-test-harness-11.4.0.x-xxxx-repository.zip -d kafkaKcopTestHarnessRepoDir
    cd kafkaKcopTestHarnessRepoDir/
    java -cp "*"
    "com.datamirror.ts.target.publication.userexit.sample.kafka.kcopTestHarness.KcopTestingHarness" <KCOP-
    CLASS> <PATH-TO-KCOP.PROPERTIES> <PATH-TO-RECORDS.TXT> isAvroKcop=true/false
    Note: The preceding arguments are optional, and it is suggested to run the command without any arguments for the first time.
    Example:
    java -cp "*"
    "com.datamirror.ts.target.publication.userexit.sample.kafka.kcopTestHarness.KcopTestingHarness"

    This uses the default KCOP class KcopDefaultBehaviorIntegrated and generates two files default_kcops.properties and default_records.txt in the directory where the Java™ application is run.

    Another option is to run it from the lib directory (CDC-KAFKA-INSTALL-DIR/lib), by using the same commands as described earlier. All of the necessary dependencies are made available when you extract the repository, so it is suggested that you run the harness from the same location.

    Note: The following information assumes you're running the app from the location where you extracted the repository.

Running the KcopTestingHarness.java Java application with a custom KCOP in an external JAR file

  1. To add external jars to your custom KCOP and transport them to your instance, follow the instructions in the video.
  2. After watching the video, a .jar file is sent to your instance directory /opt/ibm/InfoSphereDataReplication/ReplicationEngineforKafka/instance/cdcKafkaInstance/lib/abedmoosaExternal.jar. This JAR file contains a custom KCOP named AbedMoosaCustomKcop.jar in the package main.
  3. Run the following commands:
    cd /opt/ibm/InfoSphereDataReplication/ReplicationEngineforKafka/samples/DIRECOTRY-OF-UNZIPPED-REPO/
    java -cp "*:PATH-TO-EXTERNAL-JAR/"
    "com.datamirror.ts.target.publication.userexit.sample.kafka.kcopTestHarness.KcopTestingHarness"
    "main.AbedMoosaCustomKcop" <PATH-TO-KCOP.PROPERTIES> <PATH-TO-RECORDS.TXT> isAvroKcop=true/false
    Note: To run the Java™ application, set the class path to CDC-INSTALL-DIR/lib/*, which contains all necessary dependencies and jars.

Running the KcopTestingHarness.java Java application with a developed user-defined KCOP

  1. If you want to change the integrated KCOPs provided by the CDC so that the Kafka engine can use them as examples to produce user-defined KCOPs, see Developing a user-defined Kafka custom operation processor (UNIX and Linux).
  2. After following the procedure in Developing a user-defined Kafka custom operation processor (UNIX and Linux), run the KcopTestingHarness using your user-defined KCOP as follows:
    java -cp "*:/opt/ibm/InfoSphereDataReplication/ReplicationEngineforKafka/lib/"
    "com.datamirror.ts.target.publication.userexit.sample.kafka.kcopTestHarness.KcopTestingHarness"
    com.datamirror.ts.target.publication.userexit.sample.kafka.
    user-defined_KCOP