Database Testing
Last updated
Last updated
Loadmill allows users to execute various queries directly to their DB in order to validate data. This is a very powerful feature as it allows users to check data integrity and accuracy.
To execute a database query:
Go to the relevant test flow within your Test Suite.
Request Method: POST.
Request URL: https://db-relay-service.loadmill.com/api/postgres
Content Type: application/json
Request Body:
{
"connectionString": "postgres://...",
"query": "SELECT * FROM USERS"
}
See the request example below:
Running this request will return a JSON response with the required data.
To execute MongoDB queries:
Apply the same steps above.
Request URL: https://db-relay-service.loadmill.com/api/mongo
Request Body:
In this example we're searching for a user with the name "John"
{
connectionString: 'mongodb://...',
collection: 'users',
command: 'find',
query: { "name":"John" }
}
InsertOne:
{
connectionString: 'mongodb://...',
collection: 'users',
command: 'insertOne',
query: { "name": "John", "age": "56" }
}
updateOne:
{
connectionString: 'mongodb://...',
collection: 'users',
command: 'updateOne',
query: { "name":"John" },
update: { "$set": { "age": "67" } }
}
deleteOne:
{
connectionString: 'mongodb://...',
collection: 'users',
command: 'deleteOne',
query: { "name":"John" }
}
Additional help regarding update operators can be found here.
To execute Redis queries:
Request Method: POST.
Request URL: https://db-relay-service.loadmill.com/api/redis
Request Body:
{
connectionString: "redis://...",
command:"get | hget | hgetall",
key:"any-key",
field: "any-field"
}
To execute queries directly to MySQL 5.7:
Request Method: POST.
Request URL: https://db-relay-service.loadmill.com/api/mysql
Request Body:
{
"connectionString": "mysql://...",
"query": "SELECT * FROM TASKS"
}
Request Method: POST.
Request URL: https://db-relay-service.loadmill.com/api/oracle
Request Body:
https://<www.your-domain.com>/api/oracle
body: {
connectionString: 'host[:port][/service_name]'
user: 'database-user'
password: 'mypw'
query: 'SELECT * FROM table_name'
}
Executing queries to your environment DB may require VPN. You can easily overcome this by whitelisting the DB relay service static IPs: [52.42.51.230, 54.190.108.53]
in your firewall.
You can use a Docker image for DB relay service to deploy it in a specific environment.
Find more information here.