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,
KcopDefaultBehaviorIntegratedis used.
- Specifies the KCOP class to run. If not,
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
- Got to
CDC-KAFKA-INSTALL-DIR/samples. Extract thekafka-kcop-test-harness-11.4.0.x-xxxx-repository.zipfile.Note: The extracted zip contains both the source code and all of the dependencies that are required to run the application in thekafka-kcop-test-harness-11.4.0.x-xxxx-sources.jarfile. - Run the following
commands:
unzip kafka-kcop-test-harness-11.4.0.x-xxxx-repository.zip -d kafkaKcopTestHarnessRepoDircd 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/falseNote: 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
KcopDefaultBehaviorIntegratedand generates two filesdefault_kcops.propertiesanddefault_records.txtin the directory where the Java™ application is run.Another option is to run it from the
libdirectory (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
- To add external jars to your custom KCOP and transport them to your instance, follow the instructions in the video.
- After watching the video, a
.jarfile is sent to your instance directory/opt/ibm/InfoSphereDataReplication/ReplicationEngineforKafka/instance/cdcKafkaInstance/lib/abedmoosaExternal.jar. This JAR file contains a custom KCOP namedAbedMoosaCustomKcop.jarin the packagemain. - 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/falseNote: To run the Java™ application, set the class path toCDC-INSTALL-DIR/lib/*, which contains all necessary dependencies and jars.
Running the KcopTestingHarness.java Java application with a developed
user-defined KCOP
- 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).
- After following the procedure in Developing a
user-defined Kafka custom operation processor (UNIX and Linux), run the
KcopTestingHarnessusing 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