Test with Kafka activities

Relevant for: API testing

This topic describes how to add and configure Kafka activities in your API test.

Overview

Use UFT One's native API testing capabilities to test your Kafka server.

Kafka activities enable you to test the main API functionality of your Kafka server. You can use these activities in UFT One to verify Kafka's data exchange processes, including the processes of publishing messages to topics, consuming or deleting messages from topics.

Kafka activities are independent of each other. You can add and configure one or multiple activities to serve your testing purpose.

Back to top

Prerequisite

Before you can run Kafka activities in UFT One, you must have a Kafka server (Kafka broker) set up.

If your Kafka server is secured with SSL, before you add Kafka activities, configure the Kafka SSL for the entire test.

To configure the Kafka SSL

  1. Create an API test or open an existing API test.
  2. Right-click the Start node in the canvas and select Properties.
  3. In the Test Settings tab of the Properties pane, set Enable SSL to Yes, and then configure CA certificate and client keystore information.

Back to top

Publish a message to a Kafka topic

This activity allows you to publish a message to a partition on a Kafka topic.

In the process, UFT One acts as a producer to test if a message can be successfully sent to the correct partition of the correct topic on your Kafka server.

To publish a message to a Kafka topic

  1. Create an API test or open an existing API test, and expand Kafka activities under the Kafka node in Toolbox > Standard Activities.
  2. Drag a Publish Message to Kafka Topic activity from Toolbox pane to the Test Flow in the canvas.
  3. In the Input/Checkpoints tab of the Properties pane, set the activity properties.

    You can enter the name of an existing topic hosted on your Kafka server or a new name. If you enter a new name, after this activity is successfully executed, a new topic with only one partition (partition 0) is created on your Kafka server.

    Note: If you leave the Partition parameter empty, the default value is used, that is, UFT One sends the specified message to partition 0. If you set this parameter to a negative value, the message will be sent to any available partition on your topic.

  4. If necessary, add checkpoints to validate this activity.

Back to top

Receive messages from a Kafka topic

This activity enables you to fetch all messages unconsumed by other consumers in the same group from a specified topic.

In the process, UFT One acts as a consumer. You must specify a Consumer Group ID for UFT One to retrieve messages that are not consumed by other consumers in the consumer group.

To receive messages from a Kafka topic

  1. Create an API test or open an existing API test, and expand Kafka activities under the Kafka node in Toolbox > Standard Activities.
  2. Drag a Receive Messages from Kafka Topic activity from Toolbox pane to the Test Flow in the canvas.
  3. In the Input/Checkpoints tab of the Properties pane, set the activity properties.

    You can set the Group ID to any value according to your test scenario. Remember to change the Group ID if you want to receive the same messages from the topic again.

  4. If necessary, add checkpoints to validate this activity.

Back to top

Receive a message from a specific offset/partition

This activity enables you to fetch a message from a specific partition at a defined offset.

In the process, UFT One acts as a consumer and always uses a new consumer group ID to retrieve a message from the specified offset on your Kafka server.

To receive messages from a specific offset/partition

  1. Create an API test or open an existing API test, and expand Kafka activities under the Kafka node in Toolbox > Standard Activities.

  2. Drag a Receive Message from Specific Partition/Offset activity from the Toolbox pane to the Test Flow in the canvas.

  3. In the Input/Checkpoints tab of the Properties pane, set the activity properties.

    Note: If you leave the Partition and Offset parameters empty, default values are used, that is, UFT One retrieves a message from partition 0 at offset 0.

  4. If necessary, add checkpoints to validate this activity.

Back to top

Receive messages starting from a specific offset/partition

This activity enables you to fetch all messages starting from a defined offset in a specific partition.

In this process, UFT One acts as a consumer and always uses a new consumer group ID to retrieve all messages starting from the defined offset on your Kafka server.

To receive messages starting from a specific partition/offset

  1. Create an API test or open an existing API test, and expand Kafka activities under the Kafka node in Toolbox > Standard Activities.

  2. Drag a Receive Messages Starting from Specific Partition/Offset activity from the Toolbox pane to the Test Flow in the canvas.

  3. In the Input/Checkpoints tab of the Properties pane, set the activity properties.

    Note: If you leave the Partition and Offset parameters empty, default values are used, that is, UFT One retrieves all messages starting from partition 0 at offset 0.

  4. If necessary, add checkpoints to validate this activity.

Back to top

Receive all messages from a Kafka topic

This activity enables you to fetch all messages from a Kafka topic.

In this process, UFT One acts as a consumer and always uses a new consumer group ID to retrieve all messages from the specified topic on your Kafka server.

To receive all messages from a topic

  1. Create an API test or open an existing API test, and expand Kafka activities under the Kafka node in Toolbox > Standard Activities.

  2. Drag a Receive All Messages from Topic activity from the Toolbox pane to the Test Flow in the canvas.

  3. In the Input/Checkpoints tab of the Properties pane, set the activity properties.

  4. If necessary, add checkpoints to validate this activity.

Back to top

Delete messages from an offset/partition

This activity enables you to delete all messages at offsets smaller than a specified offset in a partition. Once you successfully execute this activity, you cannot recover the deleted messages.

To delete messages from an offset/partition

  1. Create an API test or open an existing API test, and expand Kafka activities under the Kafka node in Toolbox > Standard Activities.

  2. Drag a Delete Messages from Partition/Offset activity from the Toolbox pane to the Test Flow in the canvas.

  3. In the Input/Checkpoints tab of the Properties pane, set the activity properties.

    Note: If you leave the Partition and Offset parameters empty, default values are used and no message is deleted as offset 0 is the smallest offset.

  4. If necessary, add checkpoints to validate this activity.

Back to top