Description

The AvroFileReceiver writes Domain Attribute values into an Avro file format. This Receiver may be used with any Domain to generate a Flat Avro file with the desired number of records and data. 


This article will show how to generate a Flat Avro file from a User Domain within the GenRocket web platform.


Step 1 - Create a Project in GenRocket

For this example, a Project titled "AvroDemo" has been created. A default Project Version is automatically created when the Project is created.


Click on the New Project button within the Projects Pane to create a new Project. For detailed steps on how to create a Project, please click here.



Step 2 - Create a Domain for the Project

For this example, a Domain titled "User" has been created for the Project. This Domain will be used to generate the raw test data, which will be morphed into the Flat Avro file format.


To create a Domain, click on the New Domain menu within the Domains Pane and then select an option. More information about creating Domains can be found here
 


The User Domain has the following Attributes: id, firstName, lastName, middleInitial, userName, and password. 

Additionally, the loopCount has been changed to 100. To learn how to change the loopCount for a Domain, click here.



Step 3 - Assign the AvroFileReceiver to the Domain

The AvroFileReceiver will need to be assigned to the User Domain. This Receiver will morph the raw test data into the Avro output format. 


Receivers may be assigned by clicking on the New Receiver button within the Domain Dashboard. To learn more about assigning a Receiver to a Domain, please click here



Step 4 - Configure AvroFileReceiver Parameters

For the AvroFileReceiver, a fileName must be provided and will be the name of the generated output file. The subDir parameter can be used to place the file in a named sub-directory within the output directory. 



The Attributes Property Keys tab can be used to do the following: 

  • Change the Column Name
  • Include or Not Include the Attribute in the Output File
  • Change the Column Data Type (String, Int, Long, etc.).
  • Change the Attribute Order



Step 5 - Create a Scenario and Assign a Primary Domain

A Scenario defines the instructions for generating test data. One will need to be created for the Domain before test data can be generated. The Domain should be assigned as the Primary Domain for the Scenario.


This can be done by clicking on the New Scenario button within the Project or Domain Dashboard. For more information, click here.


Step 6 - Download the User Scenario

Click the Download button within the Scenario Dashboard to download the Scenario to your local computer.


Step 7 - Run the Scenario in the Command Window or Terminal

Open a Command Window or Terminal Session and make certain the directory location is the output directory defined in the Resources Pane of the GenRocket web platform. Enter the following command line: 


genrocket -r <ScenarioName>.grs


<ScenarioName> should be the actual name of the downloaded Scenario. For this example, the command line would be: 


genrocket -r UserScenario.grs


For this example, a file has been created titled "AvroDemo" and is in the Flat Avro format. 



Step 8 - View the File

This example will generate a Flat Avro file titled "AvroDemo.avro".  An Avro Viewer will be necessary to view the generated file. One can be accessed by clicking here



Drag and drop the file into the viewer or click on the Choose Files button to browse to your files and make a selection.



The file will appear as shown below in the viewer: