Skip to content

Databases Commands

Bohdan Shakhov edited this page Jul 23, 2025 · 10 revisions

🗄️ Database Interaction Commands

Testlum provides built-in commands to interact with various databases directly from your test scenarios.
You can query, validate, and manipulate data across several types of databases without writing custom code.

Supported Databases

📊 ClickHouse Database Integration

ClickHouse

📖 Overview

Type: Columnar Database

Description:
ClickHouse is an open-source, columnar database management system designed for online analytical processing (OLAP).
It is optimized for fast analytics on large volumes of data and is ideal for real-time reporting.

🛠️ How to Send a Query

Testlum allows executing ClickHouse queries within your testing scenarios.

🧩 Command: <clickhouse>

The <clickhouse> tag sends SQL queries to a ClickHouse database and optionally validates the result.

⚙️ Parameters

Parameter Type Required Description
comment String Description of the query execution
alias String Unique database alias configured in integration.xml
query String SQL query to be executed on ClickHouse
file String File name (expected_n.json) containing the expected query result for comparison (JSON)
condition Boolean Expression Optional condition for conditional execution
threshold Integer (ms) Maximum execution time allowed for the command

🧪 Example Usage

<clickhouse comment="Get all users from system" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
</clickhouse>

You can include multiple <query> blocks inside a single <clickhouse> command if you need to perform several queries in sequence.

Example with multiple queries:

<clickhouse comment="Run multiple queries" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
    <query>SELECT * FROM t_orders</query>
</clickhouse>

Tips:

  • Use the file parameter to validate query results automatically.
  • Use threshold to ensure query execution time is within acceptable limits.
  • alias must match the configuration in your integration.xml.
  • Multiple <query> blocks can be executed sequentially within one <clickhouse> command.

🌿 DynamoDB Database Integration

DynamoDB

📖 Overview

Type: NoSQL Database

Description:
DynamoDB is a managed NoSQL database service provided by AWS.
It is designed for low-latency, high-performance, and scalable applications.
DynamoDB automatically adjusts its capacity based on traffic demands.

🛠️ How to Send a Query

Testlum allows executing DynamoDB queries directly within your testing scenarios.

🧩 Command: <dynamo>

The <dynamo> tag sends operations to a DynamoDB table and optionally validates the response.

⚙️ Parameters

Parameter Type Required Description
comment String Description of the query or operation
alias String Unique database alias configured in integration.xml
query String DynamoDB query or command
file String File with expected results for validation
condition Boolean Optional condition for conditional execution
threshold Integer (ms) Maximum allowed execution time for the command

🧪 Example Usage

<dynamo comment="Get all users from system" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
</dynamo>

You can include multiple <query> blocks inside a single <dynamo> command if you need to execute several DynamoDB queries sequentially.

Example with multiple queries:

<dynamo comment="Run multiple queries on DynamoDB" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
    <query>SELECT * FROM t_orders</query>
</dynamo>

Tips:

  • Use file to automatically compare the real response with the expected one.
  • Multiple <query> blocks are supported within one <dynamo> command.
  • Keep your DynamoDB queries lightweight to ensure low-latency execution.
  • Ensure that the alias matches the one defined inside your integration.xml.

🍃 MongoDB Database Integration

MongoDB

📖 Overview

Type: NoSQL Database

Description:
MongoDB is a document-oriented NoSQL database that stores data in flexible, JSON-like BSON documents.
It is built for scalability and flexibility, making it perfect for applications dealing with evolving and diverse data structures.

🛠️ How to Send a Query

Testlum allows executing MongoDB queries directly from your testing scenarios.

🧩 Command: <mongo>

The <mongo> tag is used to send operations to a MongoDB database and optionally validate the response.

⚙️ Parameters

Parameter Type Required Description
comment String Description of the MongoDB query execution
alias String Unique database alias configured in integration.xml
query String MongoDB query to be executed
file String Expected result file for comparison (in JSON format)
condition Boolean Condition for executing the query
threshold Integer (ms) Max allowed execution time for the query

🧪 Example Usage

<mongo comment="Get all users from system" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
</mongo>

You can include multiple <query> blocks inside a single <mongo> command to run several queries sequentially.

Example with multiple queries:

<mongo comment="Run multiple queries on MongoDB" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
    <query>SELECT * FROM t_orders</query>
</mongo>

Tips:

  • Use the file parameter to automatically compare query results.
  • MongoDB queries are flexible; you can also construct advanced queries (aggregations, filters, etc.).
  • alias must match exactly with the MongoDB configuration inside integration.xml.
  • Multiple queries inside one <mongo> command help you optimize database interaction during testing.

🐬 MySQL Database Integration

MySQL

📖 Overview

Type: Relational Database Management System (RDBMS)

Description:
MySQL is a popular open-source relational database known for its speed, reliability, and ease of use.
It supports SQL and is commonly used in web applications, especially as part of the LAMP stack (Linux, Apache, MySQL, PHP/Python).

🛠️ How to Send a Query

Testlum allows executing MySQL queries directly from your testing scenarios.

🧩 Command: <mysql>

The <mysql> tag sends SQL queries to a MySQL database and optionally validates the result.

⚙️ Parameters

Parameter Type Required Description
comment String Description of the query action
alias String Unique alias from your integration.xml
query String SQL query string to execute
file String Expected result file for automatic validation
condition Boolean Conditional execution of the query
threshold Integer (ms) Max allowed query execution time

🧪 Example Usage

<mysql comment="Get all users from system" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
</mysql>

You can include multiple <query> blocks inside a single <mysql> command to execute several SQL queries sequentially.

Example with multiple queries:

<mysql comment="Run multiple queries on MySQL" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
    <query>SELECT * FROM t_orders</query>
</mysql>

Tips:

  • Use the file parameter to automatically validate query results.
  • Be sure your SQL syntax matches MySQL standards (especially for functions and joins).
  • Always match the alias with your MySQL database configuration in integration.xml.
  • Group related queries inside a single <mysql> block for better performance and readability.

🏛️ Oracle Database Integration

Oracle DB

📖 Overview

Type: Relational Database Management System (RDBMS)

Description:
Oracle is a powerful, commercial relational database system known for its performance, reliability, and advanced features.
It supports SQL and offers capabilities like partitioning, clustering, and enterprise-level security.

🛠️ How to Send a Query

Testlum allows executing Oracle database queries easily within your test scenarios.

🧩 Command: <oracle>

The <oracle> tag sends SQL queries to an Oracle database and optionally validates the result.

⚙️ Parameters

Parameter Type Required Description
comment String Description of the database operation
alias String Unique Oracle connection alias defined in integration.xml
query String SQL query string to execute
file String JSON file with expected query results for validation
condition Boolean Optional execution condition
threshold Integer (ms) Maximum allowed query execution time

🧪 Example Usage

<oracle comment="Get all users from system" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
</oracle>

You can include multiple <query> blocks inside a single <oracle> command if you want to run several SQL statements in sequence.

Example with multiple queries:

<oracle comment="Run multiple queries on Oracle" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
    <query>SELECT * FROM t_orders</query>
</oracle>

Tips:

  • Oracle SQL can differ slightly from MySQL/PostgreSQL — especially in syntax for sequences, functions, and joins.
  • Always ensure the alias matches your Oracle DB configuration in integration.xml.
  • You can group logically related queries inside a single <oracle> block to optimize execution and validation.

🐘 PostgreSQL Database Integration

PostgreSQL

📖 Overview

Type: Relational Database Management System (RDBMS)

Description:
PostgreSQL is an open-source, object-relational database system renowned for its extensibility, support for diverse data types, and standards compliance.
It emphasizes SQL flexibility and is highly favored for complex and modern application needs.

🛠️ How to Send a Query

Testlum enables you to send PostgreSQL queries directly within your testing scenarios.

🧩 Command: <postgres>

The <postgres> tag is used to execute SQL queries on a PostgreSQL database and optionally validate results.

⚙️ Parameters

Parameter Type Required Description
comment String Description of the query execution
alias String Unique alias configured inside integration.xml
query String SQL query string to be executed
file String JSON file with expected query results for validation
condition Boolean Condition under which this query should be executed
threshold Integer (ms) Maximum execution time allowed for the query

🧪 Example Usage

<postgres comment="Get all users from system" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
</postgres>

You can include multiple <query> blocks inside a single <postgres> command to run several queries sequentially.

Example with multiple queries:

<postgres comment="Run multiple queries on PostgreSQL" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
    <query>SELECT * FROM t_orders</query>
</postgres>

Tips:

  • PostgreSQL supports advanced SQL features like CTEs, window functions, and JSON fields — leverage them in your queries!
  • Always match the alias exactly with your PostgreSQL database setup in integration.xml.
  • Use file validation for automatic checks of query results during your testing flows.

🔥 Redis Integration

Redis

📖 Overview

Type: In-Memory Key-Value Store

Description:
Redis (Remote Dictionary Server) is an open-source, in-memory data structure store known for its extremely fast performance.
It supports various data types such as strings, hashes, lists, sets, and sorted sets, and features persistence, replication, pub/sub messaging, and Lua scripting.
Redis is often used as a cache, message broker, or real-time database in modern applications.

🛠️ How to Send a Query

Testlum allows executing Redis commands directly inside your test scenarios.

🧩 Command: <redis>

The <redis> tag sends queries (commands) to a Redis server.

⚙️ Parameters

Parameter Type Required Description
comment String Description of the Redis operation
alias String Unique Redis connection alias configured in integration.xml
file String File containing the expected query results
query Complex Structure Represents a single Redis command and its arguments
condition Boolean Conditional execution of the command
threshold Integer (ms) Maximum allowed execution time for the command

🛠️ Structure Inside <query>

Each <query> can contain:

Element Required Description
<command> Redis command (e.g., GET, SET, DEL)
<arg> ✅ (at least one) Arguments for the command (e.g., keys, values)

✅ **Each <query> must contain exactly one <command> and any number of <arg> elements depending on the command needs.

🧪 Example Usage — Single Query

<redis comment="Check ability to get key-value pair using GET command" 
         alias="MY_REDIS" file="expected_1.json">
    <query>
        <command>GET</command>
        <arg>name</arg>
    </query>
</redis>

🧪 Example Usage — Multiple Queries

<redis comment="Check ability to execute two queries inside one 'redis' command" 
      alias="MY_REDIS" file="expected_2.json">
    <query>
        <command>SET</command>
        <arg>name</arg>
        <arg>John</arg>
    </query>
    <query>
        <command>GET</command>
        <arg>name</arg>
    </query>
</redis>

You can include multiple <query> blocks inside a single <redis> command to perform complex operations sequentially.

Tips:

  • Redis commands are extremely fast — but setting a threshold helps catch unexpected slowdowns.
  • Remember: each <query> = one Redis command (but unlimited <arg> parameters are allowed).
  • Use the file parameter to validate expected Redis server responses automatically.
  • Match your alias exactly with what you configured in integration.xml.

📊 Sql Database Integration

Any other database integration

📖 Overview

Type: Columnar Database

Description:
This allows you to execute tests against any SQL database without being tied to a particular database implementation. This command is designed to be flexible, enabling you to test a variety of databases by simply adding the appropriate JDBC driver for the database of your choice.

🛠️ How to Send a Query

Testlum allows executing sql queries within your testing scenarios.

🧩 Command: <sqlDatabase>

The <sqlDatabase> tag sends SQL queries to a any sql database and optionally validates the result.

⚙️ Parameters

Parameter Type Required Description
comment String Description of the query execution
alias String Unique database alias configured in integration.xml
query String SQL query to be executed on any relational database
file String File name (expected_n.json) containing the expected query result for comparison (JSON)
condition Boolean Expression Optional condition for conditional execution
threshold Integer (ms) Maximum execution time allowed for the command

🧪 Example Usage

<sqlDatabase comment="Get all users from system" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
</sqlDatabase>

You can include multiple <query> blocks inside a single <sqlDatabase> command if you need to perform several queries in sequence.

Example with multiple queries:

<sqlDatabase comment="Run multiple queries" alias="ALIAS" file="expected_1.json">
    <query>SELECT * FROM t_user</query>
    <query>SELECT * FROM t_orders</query>
</sqlDatabase>

Tips:

  • Use the file parameter to validate query results automatically.
  • Use threshold to ensure query execution time is within acceptable limits.
  • alias must match the configuration in your integration.xml.
  • Multiple <query> blocks can be executed sequentially within one <sqlDatabase> command.

Tip:
Database commands can be combined with API, Web, or Mobile scenarios to create full end-to-end test workflows!

Clone this wiki locally