TPT is a testing and verification tool for embedded control systems. TPT can test MATLAB Simulink or dSPACE TargetLink models, ETAS ASCET models, C-Code or test via MiL, SiL, PiL and HiL. The PikeTec TPT Plugin allows users to execute tests modeled in TPT (Time Partition Testing) via Jenkins. A XML file can be generated in JUnit format for the reporting of test results. You can also display the TPT test report in Jenkins.
We will give you a short overview here. If you need a more detailed description please refere to the chapter Jenkins Continuous Integration of TPT manual.
The plugin provides two build steps:
- Execute TPT test cases: The TPT test cases are executed and the test results are converted into JUnit-XML files. If the build step is operating in distributing mode, it will delegate the work to worker jobs.
- Execute TPT tests as a worker for a TPT distributing job: Execute the work delegated to it by Execute TPT test cases in distributing mode.
You have two options to publish the TPT test results:
- Add a TPT Report post build action to your job to display the TPT report in Jenkins.
- Configure the build steps to transform the test results into the JUnit format and then publish the results in Jenkins using the Publish JUnit test result report post build action provided by the JUnit Plugin.
Simply create a new Jenkins Job and add the Execute TPT test cases build step and configure it as needed. Do not set the option "Distribute work to TPT worker jobs".
Make sure:
- The TPT software is installed on the computers where tests should be run.
- All 3^(rd) party tools needed on the Jenkins node where the job will run are available.
- The correct TPT project file is available (use e.g. SCM checkout to check this).
- The Junit XML directory is placed in the workspace of the job in case you want to publish the test results to Jenkins.
Using only Execute TPT test cases and Execute TPT tests as a worker for a TPT distributing job (distributing mode)
You can configure the Execute TPT test cases build step to delegate the work to a worker job by setting the option "Distribute work to TPT worker jobs". The worker job must contain a Execute TPT tests as a worker for a TPT distributing job build step.
The Execute TPT test cases build step will open the specified TPT file, lookup the tests, split them in packages with an equal number of tests and starts for each package a build of the worker job.
When all worker job build are finished the Execute TPT test cases build step will copy the test data into its workspace. The job will now generate an overall report and If you configured the job for publishing via JUnit the JUNit XML files.
Make sure:
- Only one worker job build runs on a node at any given time.
- The TPT software is installed on the computers where tests should be run.
- All 3^(rd) party tools needed on the Jenkins node where the job will run are available.
- The correct TPT project file is available (use e.g. SCM checkout to check this).
- The Junit XML directory is placed in the workspace of the job in case you want to publish the test results to Jenkins.
The Execute TPT tests as a worker for a TPT distributing job will communicate with TPT via a network protocol (Java RMI). If two builds are using the same port and would run on the same node the outcome of the execution would be nondeterministic. Use e.g. the Throttle Concurrent Builds Plugin to prevent builds from runnig on the same node.
The plugin supports Jenkins pipelines. The easies way to get a valid configuration is to use the Pipeline Snippet Generator. The plugin provides the following steps: tptExecute, tptReport, and tptAgent.
Basic pipeline example
node('windows') {
stage('Execute TPT') {
tptExecute
enableJunit: true,
exePaths: "${PathToTPT}\\tpt.exe",
jUnitreport: 'junit',
executionConfiguration: [tptConfig(configuration: 'Lights Control FUSION',
id: 'example1',
tptFile: 'C:\\tools\\tpt\\examples\\04 Test Assessments - 01 GUI Assessments.tpt')]
}
stage('Publish') {
junit 'junit/*.xml'
tptReport()
}
}
Example for distributing mode
node('windows') {
stage('Execute TPT') {
tptExecute enableJunit: true,
exePaths: "${PathToTPT}\\tpt.exe",
executionConfiguration: [tptConfig(configuration: 'Lights Control FUSION',
id: 'aaa',
tptFile: 'C:\\temp\\examples\\04 Test Assessments - 01 GUI Assessments.tpt')],
isDistributing: true,
jUnitreport: 'junit',
workerJob: 'agentJob', // see "Example for agent job"
workerJobCount: '2'
}
stage('Publish') {
junit 'junit/*.xml'
tptReport()
}
}
Example for worker job
node('windows') {
stage('Execute TPT') {
tptAgent exePaths: "${PathToTPT}\\tpt.exe", tptBindingName: 'TptApi2', tptPort: '1098'
}
}
TPT hangs/does not start when I use Jenkins. If I start TPT normally it works fine.
This is usually a problem with the licensing. Since Jenkins normally runs as a service with a different user TPT will access other settings than when executed manually. If you have a correctly configured TPT you can copy the license configuration file "%LOCALAPPDATA%\TPT\$InstallDirName_hash$\license_serverconfig.cfg" (please replace
Please note that other 3rd party tools as MATLAB Simulink or ETAS ASCET may have their own issues running in a service environment.
I cannot publish the TPT test results. The JUnit publisher cannot find anything.
The JUnit publisher can only find files in the workspace of the Job while the Execute TPT test cases allows you to create the XMLfiles anywhere in the file system. Please ensure you configured the paths correctly. You can use a relative path. A valid configuration would be "junit" as the path given to the build step and "junit/*.xml" given to the publisher.