Kiss Manual Cleanup Goodbye: Automate Redis Deletion with Excel and ReadyAPI

by Sharad JainMay 8th, 2025
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Learn how to automate Redis key deletion using ReadyAPI, REST APIs, and Excel input. A scalable solution for test automation with dynamic data sources.
featured image - Kiss Manual Cleanup Goodbye: Automate Redis Deletion with Excel and ReadyAPI
Sharad Jain HackerNoon profile picture
0-item

In today’s fast-paced development environment, automated testing is essential for ensuring the reliability and performance of applications. One such task is the deletion of specific keys in a Redis database, which can be automated using tools like ReadyAPI. In this article, we'll explore how to leverage ReadyAPI to automate a multi-step testing process involving REST API calls, extracting values from JSON responses, and interacting with a Redis database. Specifically, we'll walk through a use case where we need to delete orders from a specific client, with the Redis keys stored in the format order_unique_key. In this example, a data source will have client ID and client Prefix values which will be used to fetch order details and then from order details, we are going to delete orders from Redis DB be using order_id as the Redis key.


By the end of this guide, you will have a comprehensive understanding of how to:

  • Make a REST API call using ReadyAPI
  • Extract a property from the JSON response returned by the API
  • Use that property to search for and delete a key in Redis
  • Read input data from an Excel sheet for scalable, dynamic test execution

Prerequisites

Before diving into the implementation, it's important to have a foundational understanding of the following:

  • REST APIs and JSON response structure
  • Redis data structures, particularly how keys and values are managed
  • Basic experience with ReadyAPI and how to create automated test suites


In this example, we'll focus on deleting keys in Redis, where the keys are dynamically created and associated with JSON objects.

Step 1: Creating the Test Suite

The first step in our automation process is to create a Test Suite within ReadyAPI. Let’s title this suite "ReadyAPI Automation with REST API & Redis DB Delete Key Operation." This suite will include a test case called "Search and Delete Keys from Redis DB."


This test case will be responsible for performing all the necessary actions to interact with both the REST API and the Redis database.


Step 2: Setting Up the Data Source

Next, we'll define a Data Source to provide the input values for our test case. In this scenario, we’ll use an Excel file as the data source. The Excel sheet will include two columns named ClientID and ClientPrefix, which will provide dynamic input for each iteration of the test.


Key configuration points for the data source:

  • Data Source Type: Excel
  • Excel File Path: Specify the path where the Excel file is located
  • Worksheet Name: Define the worksheet name within the Excel file
  • Starting Row and Column: Indicate the row and column from which data should be read
  • Column Name: In this case, the column containing the ClientID and ClientPrefix


This setup ensures that each row in the Excel sheet will correspond to a different test case execution, making our test process scalable and dynamic.


Step 3: Assigning Data to Test Suite Attributes

After configuring the data source, the next step is to map the data from the Excel sheet to attributes in the test suite. This mapping ensures that the correct values are pulled for each test iteration.


For example, we will map the ClientID and ClientPrefix from the Excel sheet to two different test suite attributes. These attributes will then be used as an input parameters in the REST API call.


Step 4: Calling the REST API

With the data source set up, we can now proceed to interact with a REST API to fetch information. Specifically, we’ll make a GET request to retrieve data related to an order.


The GET request will accept the following input parameters:

  • clientId: Pulled dynamically from the Excel sheet
  • clientPrefix: Pulled dynamically from the Excel sheet


The REST API will return a JSON response containing an attribute called order_id. This value will be crucial for the next step in our process.

Step 5: Leveraging Property Transfers in ReadyAPI

One of the most powerful features in ReadyAPI is the Property Transfer functionality, which allows us to dynamically extract values from one part of the test (e.g., the REST API response) and pass them to another part (e.g., the Redis search query).


In our case, we will extract the order_id from the JSON response and assign it to a property called 'order_unique_id'. This property will then be used in subsequent steps, including the Redis search and delete operations.


Step 6: Connecting to Redis DB

Next, we'll establish a connection to the Redis database. Since the connection properties (hostname, port, and password) remain constant across iterations, we’ll define these as environment variables within ReadyAPI. This approach allows us to reuse the same connection settings in different environments without modification.


For the Redis commands, we’ll execute:

  1. Search: Check if the key exists in the Redis database

  2. Delete: If the key exists, execute the DEL command to delete it

Step 7: Iterating Through the Data Source

Since we're using a Data Source Loop, ReadyAPI will automatically iterate through each row in the Excel sheet and execute the defined steps sequentially for each ClientID and ClientPrefix. This makes the test both dynamic and scalable, ensuring that all orders in the Excel sheet are processed efficiently. Adding a Delay step will make sure that Keys from Redis are deleted successfully before iterating through next records from data source.


To help with debugging and verification, we’ve included logger statements at various points in the test. These logs provide visibility into the execution process and ensure that each step is functioning as expected.


Conclusion

By combining ReadyAPIREST APIsExcel data sources, and Redis commands, we've created a robust automated test case that dynamically interacts with a Redis database to search for and delete keys. This process not only verifies the correctness of the delete operation but also demonstrates how to integrate various tools and data sources to streamline testing.


This solution is scalable and adaptable, allowing you to execute end-to-end tests in different environments with minimal manual intervention. ReadyAPI’s powerful features, such as property transfers and environment variables, make it an ideal tool for automating complex workflows involving external databases and APIs.


Thanks & Happy Reading.

Trending Topics

blockchaincryptocurrencyhackernoon-top-storyprogrammingsoftware-developmenttechnologystartuphackernoon-booksBitcoinbooks