Description

A Test Data Query performs a MongoDB query on the defined database resource. This MongoDB query can be performed in one of two ways for a database: 

  • Mongo Before - Query columns from one or more database collections as a set of data that is buffered into memory.  

  • Mongo Each - Query one row of columns, from one or more database collections, on each row iteration of test data generation.  

 

A Test Data Query configuration has the following primary components: 

  • Parameters - Define the resource path, sub-directory, name, and variables for the Test Data Query.

  • MongoDB Query Parameters  - Defines the collection name, method name, query, sort and projection, which constitute the MongoDB query to be performed on the database.

  • Domain Attributes - Defines the Attributes that will be populated by the real data obtained from the MongoDB query.

Note: An Organization Variable Set may also be selected and used with a Test Data Query. 


Step 1: Configure Test Data Query Parameters

Test Data Query Parameters define any resources variables to be used during the MongoDB Query. Available parameters vary based on the type of query.

 

Mongo Before

Items with an asterisk (*) are required to perform this type of Test Data Query.

  • resourcePath* - Defines the path where the resource file for MongoDB connection properties exists.

  • resourceSubDir - Defines an optional sub-directory under the resourcePath where the resource file for MongoDB connection properties exists.

  • resourceName* - Defines the name of the resource that contains the database connection information on a user's local machine.

  • bufferSize* - Defines how many rows to keep in memory at a time. Note: Setting the number of rows to a very high number may cause an OutOfMemoryException to occur if the computer does not have enough available memory. The default buffer size is 1000 rows.

  • setLoop* - setLoop provides the ability to OVERRIDE the loopCount, at the Scenario level, and to the number of rows that are queried. The default is set to False.

  • queryOnce* - When the Domain that defines the query has a Parent Domain, it becomes a Child Domain of the Parent Domain. This flag determines if the Child Domain's query should be executed each time the Child Domain is called from the Parent Domain or if the query should only be executed once, the first time the Parent Domain calls the Child Domain. The default is set True to query once.

  • grVar1 - The first of five possible variables that may be used within the MongoDB Query.

  • grVar2 - The second of five possible variables that may be used within the MongoDB Query.

  • grVar3 - The third of five possible variables that may be used within the MongoDB Query.

  • grVar4 - The fourth of five possible variables that may be used within the MongoDB Query.

  • grVar5 - The fifth of five possible variables that may be used within the MongoDB Query.



Mongo Each

Items with an asterisk (*) are required to perform this type of Test Data Query.

  • resourcePath* - Defines the path where the resource file for MongoDB connection properties exists.

  • resourceSubDir -Defines an optional sub-directory under the resourcePath where the resource file for MongoDB connection properties exists.

  • resourceName* - Defines the name of the resource that contains the database connection information on a user's local machine.

  • grVar1 - The first of five possible variables that may be used within the MongoDB Query.

  • grVar2 - The second of five possible variables that may be used within the MongoDB Query.

  • grVar3 - The third of five possible variables that may be used within the MongoDB Query.

  • grVar4 - The fourth of five possible variables that may be used within the MongoDB Query.

  • grVar5 - The fifth of five possible variables that may be used within the MongoDB Query.



Note: Remember to click Save after making changes to the parameter configuration.


Step 2: Enter the MongoDB Query Parameters

Items with an asterisk (*) are required.

  • collectionName* - Defines the collection name for MongoDB Query.

  • methodName* - Defines the method name name for MongoDB Query. Method Name can be either find or aggregate.

  • query - Defines the MongoDB Query. This parameter is mandatory if methodName is aggregate.

  • sort - Defines the sort parameter for MongoDB Query.

  • projection - Defines the projection parameter for MongoDB Query. This parameter is mandatory if methodName is find

The MongoDB Parameter form if methodName is find:




Step 3: Add Domain Attributes to the Test Data Query

To finish the configuration, you will need to add the Domain Attributes. Data read from columns will be populated into the Domain Attributes for the Test Data Query. This will need to be done for each queried column of data in the database collection.

  • Click on Add below the Domain/Attribute/Column table.



  • Select the Domain and Attribute from the drop-down menus.

  • Enter the name of the Column being read by the MongoDB Query.

  • Click Save to finish.



  • The new Domain Attribute will appear in the table as shown below:



    Note: Options in the Action Column can be used to edit or delete a Domain Attribute from the Test Data Query configuration.



For MongoDB Properties files: Here are the parameter required in Properties file

host=localhost

port=27017

database=anyDB

user=root

password=root