Testing Your Module

Creating the Feed Simulation

A feed simulation automatically enqueues test data and at rates faster rates and in different ways than manual data.

The StreamBase Feed Simulator is highly customizable, and you can learn more about its many features in the Test/Debug Guide. Several feed simulations are provided with the firstapp sample module that is installed with StreamBase, as described in First Application Sample. Here, you will recreate one of them: firstapp-enum.sbfs. It generates tuples choosing values from a list that you provide.

  1. Switch to the SB Test/Debug perspective, and open the Feed Simulations view. The view contains a list of existing feed simulations in the project (your list may be empty at this point). Below the list are control buttons to run and stop a selected feed simulation, and a slide control that lets you change the rate at which tuples are submitted.

  2. To add a simulation to the list, right-click in the list area and choose New Feed Simulation from the context menu.

  3. In the New StreamBase Feed Simulation wizard:

    1. Enter or select the name of your module's parent folder, firstapp.

    2. Enter a name for your simulation: firstapp-enum.

      Click Finish to create the new feed simulation and close the wizard.

  4. Your new file opens in the Feed Simulation Editor.

    In the Simulation Streams area, you must define a stream for the feed simulation that can enqueue data to the module's input stream. Click Copy from Stream/Named Schema to borrow the stream's schema from the module.

  5. In the Stream Selection dialog, open the firstapp and expand down through the firstapp.sbapp node. Select TradesIn and click OK.

  6. This places the TradesIn stream in the Simulation Streams area. Open the arrow symbol on left of the stream's name to see the schema of the imported stream.

  7. In the Feed Simulation Editor, you will change the default behavior, which is to generate random values for each field in the input stream. Instead, you will model a set of specific values. In the Generation Method section, select the Custom option and click Customize Fields.

  8. In the Customize Fields dialog, define each field as follows:

    symbol
    1. In the Generation Method column, select Enumerated from the drop-down menu.

    2. Select the option at the bottom of the dialog named The following values.

    3. Click the Add Row button four times, and enter these values and weights in the new rows:

      Value Weight
      NKE 1.0
      CMG 2.0
      GMCR 1.0
      FSLR 2.5
    quantity
    1. In the Generation Method column, select Enumerated again.

    2. Again select the The following values option.

    3. Click the Add Row button six times.

    4. Choose the option, The following values.

    5. Enter these values and weights:

      Value Weight
      30000 0.1
      10000 0.1
      100 0.2
      200 0.2
      400 0.2
      1000 0.2

    The weights determines the relative frequency of values generated. By default, all weights are one, meaning all values are equally likely to appear. A fractional weight of 0.2 means that the specified value is to appear 20% of the time.

    Click OK to close the dialog.

  9. Press Ctrl+S to save your feed simulation.

Running Your Feed Simulation

  1. If your firstapp module is not currently running, click the Run button to start it. If StreamBase Studio asks you if you want to switch from the Authoring perspective to the SB Test/Debug perspective, click Yes.

  2. In the Application Output view, make sure that the Stream option is set to (All Output Streams).

  3. In the Feed Simulations view, select firstapp-enum.sbfs and click Run.

    Notice that the Application Input view displays generated tuples enqueued from your Feed Simulation. At the same time, the Application Output view begins displaying tuples on the two output streams.

  4. Let the feed simulation run for five or ten seconds, then click Stop.

    Note that stopping the Feed Simulation does not stop the module.

  5. Observe the results in the Application Input and Application Output views. (If necessary, resize the views so that you can see their contents clearly.)

    • In the Application Input view, notice that the list of trades value has entries that are both above and below the threshold of 10000 that was set in your Filter operator. For example:

    • In the Application Output View, select BigTrades from the Stream drop-down. Verify that the quantity value is always above 10000 for entries in the list.

      Tip

      Click to select a row to display its field summary in the table below the list, as shown in the next figure.

    • In the Application Output View, select AllTheRest from the Stream drop-down. Verify that the quantity value is always below 10000 for entries in the list.

  6. Click the Stop Running Application button in the StreamBase toolbar, or press F9.

    When the module stops, Studio switches back to the SB Authoring perspective.