Reverse engineering Siebel Test Automation Jenkins plugin

Saturday, August 7, 2021

I have recently been helping a Swedish insurance company to improve their DevOps capabilities. Like many other large companies, they are using an Oracle product called Siebel as their CRM and one of the challenges is to introduce smoke testing through test automation for Siebel.

Oracle provides different tools to orchestrate this test automation in Siebel and this article has been a great resource for me to understand in more details how it works.

Recording a functional test

First, we can use the Siebel Usage Pattern Tracking framework (UPT). This is a feature in Siebel which allows to record user actions in the Siebel web interface and to replay those later on. The article I’ve been referring to gives more details on that and how to use it. It is important to note that the SWECmd=AutoOn parameter needs to be added to the URL in order to have the recording menu displayed, for example : https://my_siebel_instance/siebel/app/fins/sve?SWECmd=AutoOn

Then to replay tests, the Desktop Integration Siebel Agent (DISA) must be installed in the computer responsible for running tests.

Running the first test manually

Let’s first record something with UPT and try to replay it. There will likely be some configuration required on our local DISA, I personally had to do the following to make it work :

  • In the C:\DISA\DesktopIntSiebelAgent\config.properties file, adding the Siebel FQDN to the allowList.
  • In the C:\DISA\DesktopIntSiebelAgent\plugins\SiebelTestAutomation\Drivers directory, adding the chromedriver.
  • If it doesn’t work, we can have a look in the log file in C:\DISA\DesktopIntSiebelAgent\plugins\SiebelTestAutomation. One of the issues I encountered was that the chrome driver version wasn’t the same as my chrome browser, which was clearly outlined in the logs.

Then, if we are good to go, we can run C:\DISA\DesktopIntSiebelAgent\disa.exe and playback the tests from Siebel, Chrome will open and replay the previously recorded actions through Siebel’s web interface.

Configuring tests in Siebel

First, there is some work to be done in Siebel. In the list of recorded scripts, we can select the one we want to execute and click “Import”. Then, let’s go to the Version tab through the sitemap to configure the following steps :

  • Verify that the recorded script we just imported is present in the Test Script menu.
  • Create a Test Set in the Test Set menu and add the previous test script in this set.
  • Create a Master Suite in the Master Suite and add the previous test set in this suite.
  • Go to Automation execution configuration and schedule a test execution :
    • Click on the “+” icon, fill in the Master Suite to be executed, the application version and the schedule date to “now” for example, then, save with “Ctrl-S”
    • Fill in the Server information. I personally had to change application type to Desktop_Chrome and fill in the URL (https://my_siebel_instance/siebel/app/fins/sve).
    • Finally, fill in the User list with, for example, username: SADMIN and password, and click “Schedule driving”.
    • Some files will be generated at the bottom in the appendices and the test automation is ready to be run.

Automating test execution

Oracle provides some guidance to setup a Jenkins server in order to run the tests automatically. They provide a Jenkins plugin called STE.hpi, available in the Siebel Server’s plugins directory. However, Oracle only provides a guide for Jenkins.

At a high level, it works like the following :

First, a tester needs to schedule a test execution in the Automation Execution Configurations menu from the Siebel web interface. When the schedule date is reached, the Jenkins pipeline, containing a Siebel test execution step, can be triggered. It will request a RUN-ID from the Siebel REST API and execute the corresponding tests through browser automation with the Chrome driver for example. DISA can be installed directly on the Jenkins master or on a separate machine connected to Jenkins as a build agent.

This is where things get a little trickier for me : in my organization, pipelines were chosen to be standardized in Azure DevOps. Using Jenkins in that case adds complexity and maintenance effort as it’s not a supported tool internally.

Ok, time to hack. Let’s look into this Jenkins plugin using a Java decompiler to check what they are doing.

Here are the interesting parts :

In the WEB-INF\classes\com\oracle\siebel\jenkins\BuildStepCommandInterpreter\config.jelly file :

<f:entry title="Command" field="text">
  <f:textarea 
    style="background-color:#f0f0f0; font-size:13px; font-family:courier" 
    readonly="readonly" 
    value="java -jar %DISA_DIR%\DesktopIntSiebelAgent\plugins\SiebelTestAutomation\Framework\KWDPresetup.jar"/>
</f:entry>

In the WEB-INF\classes\com\oracle\siebel\jenkins\BuildStepCreator.java file :

protected String getContents() {
 if (this.disa == null || this.disa.equalsIgnoreCase("")) {
   return "@echo off\nset BUILD_ID=%BUILD_ID%\n" + this.text + " /d %DISA_DIR% /r " + this.upost + " /n %NODE_NAME% /j " + this.user + " /g " + this.pass + " /x NA";
 }
 return "@echo off\nset BUILD_ID=%BUILD_ID%\n" + this.text.replace("%DISA_DIR%", this.disa) + " /d %DISA_DIR% /r " + this.upost + " /n %NODE_NAME% /j " + this.user + " /g " + this.pass + " /x " + this.disa;
}

So, in the end, the plugin is only executing a jar file from the DISA directory with a few parameters. Great, we don’t need Jenkins to do that!

My Siebel test instance has a self signed SSL certificate which needs to be imported in the Java keystore so that the tool can communicate with the Siebel REST API. To do that, in Google Chrome, browse to the Siebel website, click on the https lock icon > Certificate > Details > Copy to file > DER encoded binary X.509 (.CER) and export it in C:\siebel_certificate.cer.

By the way, C:\DISA contains its own jre, so let’s use it.

To import the certificate in the keystore, the following command can be used :

"C:\DISA\jre\bin\keytool" -import -file "C:\siebel_certificate.cer" -keystore "C:\DISA\jre\lib\security\cacerts" -alias "siebel certificate"

(The default password for the keystore is changeit)

Also, Jenkins runs the jar file as “nt authority\system” so I used PsTools to run commands as this user :

PsExec.exe -i -s cmd.exe

Then, whoami in cmd answers back “nt authority\system”.

Finally, let’s run the plugin script in this PsExec cmd :

set DISA_DIR=C:\DISA
set NODE_NAME=master
"C:\DISA\jre\bin\java" -jar C:\DISA\DesktopIntSiebelAgent\plugins\SiebelTestAutomation\Framework\KWDPresetup.jar /d %DISA_DIR% /r https://my_siebel_instance/siebel /n %NODE_NAME% /j SADMIN /g my_password /x C:\DISA

If all goes well, we get the following result from the previous command :

INFO :: Checking config.properties file to fetch HTTP Proxy Details...
INFO :: No HTTP Proxy Details found. Process will continue...
INFO :: Making REST Call To Siebel Server To Fetch RUN-ID....
INFO :: REST GET URL :: https://my_siebel_instance/siebel/v1.0/service/Automation%20Rest%20Service/GetTestRunId?ClientName=master
INFO :: RUN-ID : 1-3FBR6 is Picked.
INFO :: SOAP URL :: https://my_siebel_instance/siebel/app/eai/enu?SWEExtSource=WebService&SWEExtCmd=Execute&WSSOAP=1
INFO :: Starting Attachment Download for RUN-ID 1-3FBR6
200
INFO :: XML File C:\DISA\DesktopIntSiebelAgent\plugins\SiebelTestAutomation\batchconfig.xml downloaded successfully.
INFO :: MasterSuite File C:\DISA\DesktopIntSiebelAgent\plugins\SiebelTestAutomation\Scripts\MasterSuiteThibaut.csv downloaded successfully.
INFO :: Optional Resources folder not found in attachments to download. Process Will Continue...
INFO :: Optional Dataset file not found in attachments to download. Process Will Continue...
INFO :: Attachments Downloaded Successfully for RUN-ID :: 1-3FBR6
Starting Siebel Test Automation Execution...

java -jar C:\DISA\DesktopIntSiebelAgent\plugins\SiebelTestAutomation\Framework\SiebelTestAutomation.jar C:\DISA\DesktopIntSiebelAgent\plugins\SiebelTestAutomation
Exit Value: 0
INFO :: Siebel Test Automation Execution Completed Successfully.
INFO :: Uploading Attachments...
INFO :: Reports folder C:\DISA\DesktopIntSiebelAgent\plugins\SiebelTestAutomation\Reports successfully zipped, at location C:\STEReportsLogs\1-3FBR6\Reports_08062021133735.zip
INFO :: ZIP and XML file uploaded successfully.
INFO :: Updating RUN-ID Status to Completed.
INFO :: REST UPDATE URL :: https://my_siebel_instance/siebel/v1.0/service/Automation%20Rest%20Service/UpdateStatus?Id=1-3FBR6&Status=Completed

We also get the results with test PASS in the Automation execution configuration menu in the Siebel web interface.

I have had an issue with Siebel returning an empty RUN-ID. For me, the problem was related to the scheduled time in the Automation execution configuration menu. I had to make sure that the script runs after the scheduled date.

In the end, by decompiling the Jenkins plugin, we found out that it just executes a jar to run the test automation. Even if this part isn’t documented, the behaviour is actually fairly simple so the dependency on Jenkins can be removed and we have the flexibility to choose any other tool!