Continuous integration sample details

You build and run the sample, and look at source files to understand how the sample works.

Running the sample

The sample includes two build processes for the current project and baseline:

  1. MyTest: a testing process for rulesets.

  2. MyDeploy: a deployment process for deploying a ruleset to Rule Execution Server.

Note:

To find your local host port number (<PORT>) to run this sample, see Checking the server port number.

To configure the sample:

  1. You create a database before running the sample:

    1. In your browser, enter http://localhost:<PORT>/rozo. A sign-in page opens.

    2. If necessary, enter:

      • Username: rtsAdmin

      • Password: rtsAdmin

    3. Click Sign in. A new page opens.

    4. Click Create DB to create the database.

    5. Click Sign out.

  2. Sign in to Decision Center with the username and password in Step 1.

  3. On the Home tab, select the rule project loanvalidation-rules.

Configuring a ruleset

You create the ruleset that is updated by the sample.

To configure the ruleset:

  1. Click the Configure tab.

  2. Click Manage RuleApps.

  3. Click New.

  4. In Name, enter MyRuleApp.

  5. In Rulesets, click New.

  6. In Name, enter MyRuleset, and select loanvalidation-rules as the project.

  7. Click Save to save the ruleset, and click Save again to save the ruleapp.

Configuring a testing profile

To configure a testing profile:

  1. Click the Configure tab.

  2. Click Continuous Integration and Configuration. The Configuration Build Management page is displayed.

  3. Click Add profile configuration if it is not open.

  4. In Profile Type, select Testing.

  5. In Name, enter MyTest.

  6. Click Apply.

  7. In Update profile configuration, select the Enable/Disable check box to enable the profile.

  8. Configure the profile as follows:

    Property Name Property Description Value
    Decision Center Data source The data source holding the scenario suites. In a real project, the authoring and build instances of Decision Center should be two separate instances pointing at the same database. For simplicity, you use the same instance in this sample. jdbc/ilogDataSource
    Decision Center Password The password to connect to the server. rtsAdmin
    Decision Center URL The URL to the server. http://localhost:<PORT>/teamserver
    Decision Center User The user who connects to the server. rtsAdmin
    Inactivity Threshold The tests are launched when no authoring activities are detected during the time you specify (in minutes). Enter 0 to execute the tests immediately.
    Interval The minimal time between two consecutive tests (launch times specified in minutes). Enter 0 to execute the tests immediately.
    Notification Threshold The minimal number of authoring activities enabling test launches. Enter 1 to execute the tests only when one rule (or a decision table) is updated.
    Query The query that searches for the scenario suite you want to use in the tests. Note that you can use more than one query at a time. Use the + button in the user interface configuration to add more queries. MyQuery
    Rule Execution Server Server The server that executes the tests. Sample (the default Rule Execution Server)
  9. Click Apply.

  10. Click the Build tab to see the MyTest build profile. There are no reports at this time.

You have configured the profile as follows:

Creating a query

You create the query that retrieves the scenario suite you want to execute to test the ruleset.

To create the query:

  1. Click the Query tab.

  2. Click New.

  3. In Name, enter MyQuery.

  4. Change Find to all test suites.

  5. Click Save.

Configuring a deployment profile

Now you configure the deployment build process.

To create a deployment profile:

  1. On the Configure tab, click Continuous Integration Configuration. The Configuration Build Management page opens.

  2. Click Add profile configuration.

  3. In Profile Type, select Deployment.

  4. In Name, enter MyDeploy.

  5. Click Apply.

  6. In Update profile configuration, select the Enable/Disable check box to enable the profile.

  7. Configure the profile as follows:

    Property Name Property Description Property Description
    Decision Center Data source The server data source with the rule project you want to deploy. In a real use, the authoring server instance and the build server instance should be two different instances of Decision Center pointing at the same database. For simplicity, you use the same instance in this sample. jdbc/ilogDataSource
    Decision Center Password The password to connect to the server. rtsAdmin
    Decision Center URL The URL to Decision Center. http://localhost:<PORT>/teamserver
    Decision Center User The user of the server. rtsAdmin
    Rule Execution Server Web App. The web application name for the server. res
    Deployment time The time at which the ruleset is deployed (in hour:minute format). Enter the current time.
    Merging Policy The ruleset deployment policy. REPLACE_RULESET
    Rule Execution Server Host The name of the host where the server is located. localhost
    Rule Execution Server Password The password used to connect to the server. resAdmin
    Rule Execution Server Port The port number of your server. <PORT> (See Checking the server port number.)
    Rule Execution Server User The user of the server. resAdmin
    RuleApp Name The name of the deployed RuleApp. MyRuleApp
  8. Click Apply.

You have configured a profile to deploy a ruleset to a remote Rule Execution Server from a Decision Center project.

The profile triggers a deployment when the time in the Deployment time property runs out.

Triggering the test build

To trigger the MyTest profile:

  1. Click the Explore tab.

  2. Click the computation package.

  3. Change the status of intialCorporateScore to Defined.

  4. Click Finish to save your changes.

  5. Click the Build tab.

  6. In the Choose a build profile to display related results menu, select MyTest.

  7. Click Refresh to start the build.

  8. Click View to see the execution results.

Deploying the ruleset

To deploy and view the ruleset:

  1. In the “Choose a build profile to display related results” menu, select MyDeploy.

  2. Click Refresh to start the build.

  3. Sign in to your Rule Execution Server console. You can see that the ruleset has been deployed.

Rebuilding the sample

To rebuild the sample:

  1. In the Samples console, double-click the build target to compile the code.

  2. To redeploy the sample, double-click the deploy target.

How the sample works

The sample is divided into three main parts:

  1. Decision Center customization, located at:

    • servercontinuousintegration\src\com\ibm\rts\sample\build\client

    • servercontinuousintegration\client

  2. Build server, located at:

    • servercontinuousintegration\src\com\ibm\rts\sample\build\client

    • servercontinuousintegration\client

  3. Shared, which is used by the two other parts. It mainly contains the bean and the model for the sample.

The Decision Center customization part is divided into five layers under servercontinuousintegration\src\com\ibm\rts\sample\build\client\:

Decision Center user interface customization

The sample adds the following to the Decision Center user interface:

When the sample is deployed, some configuration is done to Decision Center using the Ant target set-config-param in the servercontinuousintegration\build.xml file.

To view these properties in Decision Center, go to Configure > Installation Manager, and then click Set configuration parameters.

These properties show you where to send the events. The user interface customization is in servercontinuousintegration\client\WebContent. The onCommitElement method of the controller NotificationController.java is called each time the business user updates, deletes, or creates a rule artifact. The controller sends event details through HTTP to the build server.

All the data displayed in the Build tab and the Sample Configuration is retrieved from the build server using HTTP as well.

See the servercontinuousintegration\src\com\ibm\rts\sample\build\client\event\EventManager.java class.

Build server

The build server is divided into three layers under servercontinuousintegration\src\com\ibm\rts\sample\build\server\:

When a user updates, deletes, or creates a rule artifact, the server event manager (EventHandler.java) receives the events from Decision Center and persists them in the sample database using the DAO layer.

At startup, the server creates a watcher thread. (WebSphere® Asynchbeans WorkManager allows you to develop multithreaded applications for use inside WebSphere Application Server). For each configured build profile, the server checks repeatedly whether it is time to trigger the profile. When it is time, the server associates an asynchronous bean, or asyncbean, with the profile for execution. An asyncbean is a Java™ object or enterprise bean that can be executed asynchronously by a Java 2 Platform Enterprise Edition (J2EE) application using the J2EE context of the asynchronous bean creator.

The build profile implementations

This sample implements the following tasks, located at \servercontinuousintegration\src\com\ibm\rts\sample\build\server\impl\:

The Testing task provides two main methods:

The Deployment task provides two main methods:

Source files

This sample is located in the <Install Directory>\teamserver\samples\servercontinuousintegration\src folder.

The sample is written to automatically manage the user interface configured for the build profiles. You simply define the metadata configuration properties in the build profile, and the configuration page handles the read, write, and delete configuration properties in the database.

The file \servercontinuousintegration\server\resources\script.sql contains the SQL statements that create the configuration metadata properties for the two predefined build profiles you use in this sample.

This sample uses the following database schema:

Table Description
BUILDS Contains all triggered builds.
BUILD_PROFILE_PARAMETERS Contains the value of the properties of configured build profiles.
BUILD_PROFILE Contains the build profiles.
BUILD_PROJECT Contains tuple projects and baselines that are associated with the build profiles.
BUILD_TYPE_PARAMETERS Contains the metadata describing the properties associated with a build profile.

You can also view and modify the sample source files in Rule Designer. To import the sample into your workspace, click the Import projects link for the sample in the Samples and Tutorials view, and switch to the Java perspective.