Creating an Eggplant Performance Test Manually
Typically, you create an Eggplant Performance test by using the Objectives feature in Eggplant Performance Studio. However, as you get more familiar with all the elements that make up a performance test, and as you develop more test assets across your workspace and projects, you might choose to create your tests from scratch instead.
This section takes you through the step-by-step process of manually creating a test in Eggplant Performance Studio. The test creation method provided below is one of the several ways you can create a test in Eggplant Performance. The following sample test focuses on the functionality of Eggplant Performance Studio, and how you can use it to manage virtual users (VUs) and tests.
The following tasks related to creating a test are discussed below:
- Creating a Workspace
- Creating a Virtual User (VU)
- Creating a Project
- Creating a New Script
- Generating a Script From Your Recording
- Creating a Workflow
- Creating and Configuring a Test
- Building Your Project
Creating a Workspace
Before you create an Eggplant Performance test, you must either open an existing workspace or add a new one in Eggplant Performance Studio.
The workspace contains all environment-specific data such as injector details, default editors, compiler locations, and custom VU types. A workspace allows you to switch between different environments easily. For example, you can switch between a test and a live environment, both of which can have different injector configurations.
To create a new workspace:
- In Eggplant Performance Studio, select File > New > Workspace.
- When the Add Workspace dialog box opens, enter a name for your new workspace in the Name field.
- Enter the Location path where you want to save your new workspace.
- Click OK. A message displays to tell you whether or not your new workspace was created successfully. If it succeeded, the message prompts you to switch to the new workspace.
- Click Yes. Your new workspace opens in Eggplant Performance Studio.
Creating a Virtual User
Before you can generate scripts for use in your test, you need a virtual user (VU). You must create a new VU type before you can create your first script, but it is not always necessary to create a new VU before creating a new script.
Prerequisite:
You must add a new web VU type, which supports the record and replay of user interactions with web-based applications and servers using HTTP and HTTPS protocols. You can create a Web Java or C# Web VU, depending on your preference.
To create a new VU:
- If the Workspace tree is not already displayed, open Eggplant Performance Studio and display the Workspace tree.
- In the Workspace tree, right-click Virtual Users and select New Virtual User from the drop-down menu. The Create a Virtual User Type dialog box opens.
- Select Web Java Virtual User or Web C# Virtual User (your preference) from the list and click Next.
Note: These examples use the Web C# VU. The name panel automatically opens with the Extends and Namespace fields populated. If you're creating a Java Web VU, you see a Package field instead of a Namespace field.
- Provide a Name for the new VU. The Class name field populates automatically as you type.
- Click Finish. Your new VU will be created and available in the main window.
Creating a Project
Eggplant Performance is a project-based, load testing tool. Scripts, workflows, data, and tests are all stored in a project. You must either open an existing project, or create a new one.
To create a new project:
- Select File > New > Project or click the New Project button on the toolbar. The New Project dialog box opens.
- Enter a name for your new project in the Project Name field.
- Click OK. Your new project will be created and open in the main window.
Creating a New Script
You can create virtual user (VU) scripts by using any of these methods: use a script recorder, use a standard template, or import an existing source file. These instructions create a VU script from a recording.
To record a new script from a recording:- With your project open, right-click Recordings in the Project tree, and select New Recording or click the New Recording button on the toolbar.
- Provide a name for your recording, select Web Proxy Recorder from the drop-down menu, then click Next.
- Choose the web browser from the Applications drop-down list that you would like to record your script against, then click Next. The About to start recording panel opens.
- Click Start recording. The browser opens to a blank page and the recorder user interface (Eggplant Performance Proxy Recorder) opens. You will be prompted to install a certificate to record the HTTP traffic. Install the certificate if necessary. The wizard remains open in the background displaying the Recording in progress panel.
- In the web browser, perform the actions you want to record. These will be included in your first transaction. The default name of the first transaction, which is Start, was set on the Choose a web client application to launch panel (see step 2).
- In the Set Transaction field at the top of the Proxy Recorder, enter the name you want for the second transaction you would like to record, then click Set Transaction.
- Perform the actions in the web browser that should be included in the second transaction.
- Repeat the two previous steps until you are satisfied with the content of your recording.
- Click Next.
Note: You can cancel your recording at any time and start the wizard again to create a new recording. Following is an example of the transactions you might want in your recording:
- Second transaction name: goToWebsite, click Set Transaction, and enter the URL for the Google home page in the browser that appears. (Internet Explorer opened by default with the proxy recorder.)
- Third transaction name: performSearch, click Set Transaction, and enter the Eggplant website in the Google search window.
- Fourth transaction name: we entered selectResult, clicked Set Transaction, and then selected one of the results for the Eggplant website.
- Click More to view your recorded transactions. Alternatively, click the Requests tab to see the requests associated with your activity. The following page shows the selectResult transaction and the URL for Google. Note that the red dot button indicates that the recording was paused.
- When you've completed your recording, click on the recorder toolbar, or click close on the recorder to stop recording. You may see a prompt to confirm that you want to exit the recorder. When you exit the recorder, the Recording finished panel opens in the wizard.
- Click OK to confirm you would like to end the recording.
- Click Next to continue. The Filter hosts panel opens showing you the hosts that were found in your recording.
- Use the Filter hosts panel to specify which hosts you would like to have included in your final script. In the example below, the Whitelist filter mode is selected to specify that you only want to include the specified hosts.
- When you've specified host filters, click Next. The Recording complete panel opens, providing you the option to view the recording in its filtered or unfiltered form. By default, Generate script(s) after the wizard finishes is selected, which will automatically launch the Generate Script from Recording wizard when you complete the recording process.
- Click Finish. The Generate Script from Recording wizard opens immediately if the Generate script(s) after the wizard finishes option was selected in the previous step.
Generating a Script from your Recording
Recording a web session simply creates a raw recording. You use the Eggplant Performance Web script generator to create the final Web script with the help of the Generate Script from Recording wizard.
To generate a script from your recording:- Run the Generate Script from Recording wizard. It opens to the Choose a language panel. As described in the previous section, the Generate Script form Recording wizard opens automatically when you choose Generate script(s) after the wizard finishes on the Recording complete panel in the Generate a New Script wizard.
- Select the programming language (Java or C#) in which you would like your script generated and click Next. The Choose a Custom Virtual User type panel opens. The examples below use a C# VU.
- Select the Web VU you created from the Virtual User Type list and click Next. The Enter new script settings panel opens.
- Select the transactions from your recording that you would like to include in the generated script and click Next. The Choose which script generation rules to apply panel opens.
- Click the Add (green plus) button to add a new generation rule for your VU. The Generation Rules Wizard opens to the Select Rule Type panel. Generation Rules enable you to automatically handle tasks such as parameterization, correlation, and validation each time a new script is generated.
The example below uses the Verify Contains rule type that lets you validate if the server's responses to the virtual user's (VU's) requests are accurate during the test. By verifying the a short section of the page content, the virtual users can report errors if something goes wrong (for example, if the users are unable to view the page they're expecting to see).
- From the Rule Types pane, select Verification Rules > Verify Contains rule and then click Next. The Verify Contains rule is used to ensure that the server’s responses to the Virtual User’s requests are accurate. The Set the expected response content panel opens.
- Click View Recording to use the Web Log Viewer to see the requests and responses made during the recording to find the appropriate text to enter in the Text field. Close or minimize the Web Log Viewer window when you finish viewing the recording.
- Click Next on the Select Rule Type panel. The Select the success/failure options panel opens.
- From the Action to take on failure drop-down list, select the action that you want to occur if the content cannot be verified. For example, Generate a warning message and continue causes a warning message to appear in the run-time results, but the execution otherwise continues. Click Next to go to the Create a request filter panel.
- From the Request filter panel, select the appropriate filter option. For example, select Only apply rule to requests that match the following conditions and click the Add button to create request filter that limits the requests to which your generation rule is applied. The Create a request filter dialog box opens.
- Review the matching requests and adjust the request filters until the requests you want are displayed. When you are satisfied with the filters, click OK to create your filter. The filter and its matching requests are added.
- Click Next. The Enter a name for this rule panel opens.
- Review the summary of your new generation rule and click Finish to add your completed rule. The new rule is displayed on the Choose which script generation rules to apply panel of the Generate Script from Recording wizard.
- Click Next. The Advanced web script generation options panel opens. For our example, we accept all the default values on this panel and its tabs.
- Click Generate to generate your script. The Generation in progress panel opens showing you the script generation progress. When it finishes, you see a message Script generation complete! If you see errors or a failure instead, troubleshoot accordingly.
- When the script generation finishes, click Finish. Your new script will open in the main window and appear under Scripts in the Project tree view. You can see the rules your script was generated with in the main window.
- Click Next on the Select Rule Type panel. The Set the expected response content panel opens.
- Record and generate at least one more script so that you can create a workflow and then proceed to the next section.
Creating a Workflow
You can create a simple test consisting of one script directly, without using a workflow. However, using a workflow gives you a greater degree of control over your scripts when you run a test. In a workflow, you can place scripts in three different categories:
- Initial: Scripts placed in the initial section run only once at the start of a test.
- Repeated: Scripts in the repeated section are iterated the number of times specified in the Virtual User Group Runtime Settings.
- Final: Scripts in the final section run once at the end of the workflow.
To create a workflow:
- Right-click Workflows in the Project tree, then select New workflow. The Create a Workflow dialog box opens.
- Provide a name for your workflow.
- Build the desired workflow from your scripts using the Initial, Repeated, and Final selectors, then click OK. Your new workflow opens in the main Studio window and is listed under Workflows in the Project tree.
For more detailed information on workflows, see Working with Workflows.
Creating and Configuring a Test
Designing a test allows you to configure how your VU scripts will be used during the execution. You can reuse and configure a set of scripts in different ways to allow an infinite number of different tests.
To create and configure a test:- Right-click your new workflow and select Create Test. The Create test from script dialog box opens.
- Enter a name for the test and click OK. In our example, we entered a name but accepted the default group. The test opens in the Main window.
- Double-click the VU Group for your new workflow. The Group Specification panel opens.
- On the Virtual Users tab, increase the number of VUs in the VU group to a conservative number, such as 5, so you don't tax the localhost Injector. Also be mindful of the maximum VUs allowed by available licenses.
- On the Iterations tab on the Runtime Settings tab, raise the number of iterations to 20 to increase the amount of data gathered and available for later analysis, and click OK to commit the changes.
Building Your Project
You must build your project to ensure it compiles correctly.
To build your project:
- Click Build in the toolbar to build your project.
- Confirm that the build was successful.
Your test should now be ready to run. Continue to Running an Eggplant Performance Test in this sample quick start guide for information about running your test.