Description
The GenRocket G-REST Engine allows the running of GenRocket Scenarios over REST on a given port. For example, a user may want to test a controller method whose only interface is over REST. The user may use G-REST to deliver dynamic test data to the controller method.
G-REST is a server that takes your request. Changes are made to the Scenario based on the received request and then it is run by GenRocket Runtime.
In This Article
- G-REST Port Configuration
- Commands
- Example
- Request URL
- Which GenRocket Receiver should I use with the GenRocket REST Engine?
- Example Running In Memory
- Example Not Running In Memory
- Frequently Asked Questions
G-REST Port Configuration
The G-REST engine requires one port to receive and respond to requests.
- requestPort - 8181 (default) - Receives client socket requests.
- Launch from a command line via, genrocket -T 8181 -d
- The port number may be changed at DevOps’s discretion.
- The user enters the port number (configured by DevOps) when launching a G-SocketEngine.
Commands
-T <port> or --run-http-server <port>
Example
genrocket -T 8181 -d
If it launches successfully, you will see the following output. Note: Your version numbers may be different:
GenRocket Runtime Version: 3.5.38 GenRocket Version: 3.5.38.100 GenRocket Engine Version: 3.5.38.100 GenRocket Generator Runtime Version: 3.5.38.100 GenRocket Receiver Runtime Version: 3.5.38.100 GenRocket GRepositoryClient Runtime Version: 3.5.38.100 GenRocket GRepositoryServer Runtime Version: 3.5.38.100 GenRocket HttpServerEngine started on port: 8181 Press Ctrl+C to shutdown server.
At this point, G-REST will be listening on port 8181 for requests.
Request URL
If you start the G-REST on port 8181, then the URL you will use to send requests will be the following:
http://localhost:8181/grRest
Which GenRocket Receiver should I use with the GenRocket REST Engine?
If you are creating Scenarios that are to be run specifically by G-REST, then you only need to use the GenRocket JSONRestReceiver with any Domain.
You can also run any Scenario with G-REST and get a JSON Response payload if you remember to set the inMemory payload parameter's value to true (click here for full details).
Example Running In Memory
In this example, the parameters are set to run UserScenario.grs inMemory and set the User Domain's loopCount to 3.
- The interface must be set to "auto."
- The path must be set to the directory where the Scenario is stored.
- The scenarioDomain must contain the name of the Scenario to run (including .grs).
- The inMemory parameter must be set to "true".
- The loopCount must be set to a reasonable number so as not to run out of memory when the Domains are being generated in memory.
- If the loop count is less than zero, the loopCount will be set to 1.
- The sfProfileName should be set only when running Scenarios that are generating directly to Salesforce.
{ "interfaceType": "Auto", "path": "/User/johnDoe/test/scenarios", "scenario": "UserScenario.grs", "scenarioDomain": "User", "inMemory": "true", "loopCount": "3", "sfProfileName": "" }
Example Response
The response yields three user Domains in JSON format.
{ "responseType": "OK", "data": [ { "id": "1", "firstName": "Rolanda", "lastName": "Gunderson", "middleInitial": "R", "username": "user1", "password": "C4CA4238A0B923820DCC509A6F75849B", "ssn": "001-01-0001", "cardNumber": "5110000000000006", "phoneNumber": "(599) 536-5222" }, { "id": "2", "firstName": "Shelly", "lastName": "Johnsen", "middleInitial": "J", "username": "user2", "password": "C81E728D9D4C2F636F067F89CC14862C", "ssn": "001-01-0002", "cardNumber": "4100000000000001", "phoneNumber": "(253) 357-7288" }, { "id": "3", "firstName": "Jayne", "lastName": "Tye", "middleInitial": "E", "username": "user3", "password": "ECCBC87E4B5CE2FE28308FD9F2A7BAF3", "ssn": "001-01-0003", "cardNumber": "6011010000000003", "phoneNumber": "(678) 575-5230" } ] }
Example Not Running In Memory
In this example, the parameters are set to run UserScenario.grs normally (not inMemory), in which case the loopCount and the scenarioDomain are ignored.
- The interface must be set to "auto."
- The path must be set to the directory where the Scenario is stored.
- The scenarioDomain will be ignored, so it can be left blank.
- The inMemory parameter must be set to "false".
- The loopCount will be ignored in that it will not set the loopCount of the SceanrioDomain; however, it cannot be blank, so set it to any number (e.g., 0).
- The sfProfileName should be set only when running Scenarios that are generating directly to Salesforce.
{ "interface" : "auto", "path": "/Users/htaylor/Downloads", "scenario": "UserScenario.grs", "scenarioDomain": "", "inMemory": "false", "loopCount": "0", "sfProfileName": "" }
Example Output
In this example, the UserScenario contained a Domain called User that uses an XMLFileReceiver for its test data output format. If the loopCount of the User Domain is set to 10 and the XMLFileRecierver's fileName parameter is set to User.xml, then a file named User.xml would be generated containing similar user domain information as presented below.
<rows>
<row id="1" firstName="Shelby" lastName="Mayes" middleInitial="Y" username="user1"
password="C4CA4238A0B923820DCC509A6F75849B" ssn="001-01-0001" creditCard="5110000000000006" phoneNumber="(280) 337-5600"/> <row id="2" firstName="Luisa" lastName="Hazelwood" middleInitial="N" username="user2" password="C81E728D9D4C2F636F067F89CC14862C" ssn="001-01-0002" creditCard="4100000000000001" phoneNumber="(583) 164-5239"/> <row id="3" firstName="Judy" lastName="Ling" middleInitial="H" username="user3" password="ECCBC87E4B5CE2FE28308FD9F2A7BAF3" ssn="001-01-0003" creditCard="6011010000000003" phoneNumber="(530) 282-9412"/> <row id="4" firstName="Mei" lastName="Hecker" middleInitial="L" username="user4" password="A87FF679A2F3E71D9181A67B7542122C" ssn="001-01-0004" creditCard="5210000000000013" phoneNumber="(200) 751-3782"/> <row id="5" firstName="Valeria" lastName="Cowles" middleInitial="S" username="user5" password="E4DA3B7FBBCE2345D7772B0674A318D5" ssn="001-01-0005" creditCard="4100000000000019" phoneNumber="(213) 202-1361"/> <row id="6" firstName="Jung" lastName="Rhodes" middleInitial="O" username="user6" password="1679091C5A880FAF6FB5E6087EB1B2DC" ssn="001-01-0006" creditCard="6011210000000017" phoneNumber="(490) 732-4786"/> <row id="7" firstName="Coleen" lastName="Mead" middleInitial="I" username="user7" password="8F14E45FCEEA167A5A36DEDD4BEA2543" ssn="001-01-0007" creditCard="5310000000000020" phoneNumber="(675) 139-8732"/> <row id="8" firstName="Celestine" lastName="Dimartino" middleInitial="K" username="user8" password="C9F0F895FB98AB9159F51FD0297E236D" ssn="001-01-0008" creditCard="4100000000000027" phoneNumber="(533) 489-1584"/> <row id="9" firstName="Madeleine" lastName="Cancel" middleInitial="E" username="user9" password="45C48CCE2E2D7FBDEA1AFC51C7C6AD26" ssn="001-01-0009" creditCard="6011310000000023" phoneNumber="(763) 139-7957"/> <row id="10" firstName="Margart" lastName="Santoyo" middleInitial="K" username="user10" password="D3D9446802A44259755D38E6D163E820" ssn="001-01-0010" creditCard="5410000000000037" phoneNumber="(552) 722-3825"/> </rows>
Frequently Asked Questions
Are any specific licenses or certificates required to use G-REST?
You are not required to have any specific certificate/license to use G-REST. It is a server that takes your request and, based on the request, makes changes to the Scenario and runs it. GenRocket Rest Server does not take up much memory and space to be launched.
It is the Scenario's configuration that requires the appropriate RAM/CPU. For example, let's say you are generating millions/billions of rows of data. In that case, you will require a larger number of CPUs and Memory in order to generate data efficiently.
Can G-REST be used for a single application to integrate and generate data?
G-REST is designed to run on a Single System by a Single User. However, multiple applications on the same system can make calls to the G-REST Server. If that fits your requirements, you can use the same. For example, you can use that in Jenkins Pipeline.