CDash:Testing/Client Management

From KitwarePublic
Jump to navigationJump to search

CDash 1.6 implements a beta version of remote build management. For more information about this functionality, please read CDash:Build Management. This page describes how to test this functionality in CDash.

Overview

The build management test in CDash is split into three parts. First, the client registers with CDash, indicating to the server that it is available to perform remote builds. Second, the server schedules a build to be performed remotely. Finally, the client requests work from the server.

Files used

Client XML file

This contains information about the client computer, such as operating system, compiler version, etc.

Client Test Script #1

This CTest script contacts the CDash server and alerts it that a new client computer is available to perform remote builds. You will need to write this file yourself, but an example is provided below.

Remote Build Scheduling Script

This is a Selenium based PHP script that simulates an administrator logging into CDash and scheduling a new remote build. This file can be found in your CDash source tree:

/path/to/CDash/testing/selenium/test_managebuidl2.php

You shouldn't need to edit it.

Client Test Script #2

This CTest script contacts the server and requests work to be performed remotely. Again, you will need to write this file yourself, based on the example below.

Example Client Scripts

Client XML

<source lang="xml"> <?xml version="1.0" encoding="UTF-8"?> <cdash>

 <system>
   <platform>Linux</platform>
   <version>Ubuntu</version>
   <bits>64</bits>
   <basedirectory>/projects/CDash-nightly</basedirectory>
 </system>
 <compiler>
   <name>gcc</name>
   <version>4.4.3</version>
   <generator>Unix Makefiles</generator>
 </compiler>
 <cmake>
   <version>2.8.1</version>
   <path>/usr/local/bin</path>
 </cmake>
  <library>
    <name>MySQLClient</name>
    <version>16.0.0</version>
    <include>/usr/include/mysql</include>
    <path>/usr/lib/libmysqlclient.so</path>
  </library>
  <program>
    <name>cvs</name>
    <version>1.12.13</version>
    <path>/usr/bin/cvs</path>
  </program>

</cdash> </source>

Client Test Script #1

<source lang="cmake"> set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "elysium") set(CTEST_DROP_URL "/CDash-nightly/submit.php") set(CDASH_TEMP_DIRECTORY "/tmp/cdash-nightly") set(CDASH_SITENAME "elysium.kitware") set(CDASH_SYSTEMNAME "Ubuntu-10.04") set(PROJECT "InsightExample") set(CDASH_SITE_CONFIG_FILE "/projects/DashboardScripts/elysium-nightly.cdash.xml") set(CTEST_DROP_LOCATION ${CTEST_DROP_URL}?sitename=${CDASH_SITENAME}&systemname=${CDASH_SYSTEMNAME}&submitinfo=1) set(CTEST_DROP_SITE_CDASH true) ctest_submit(FILES ${CDASH_SITE_CONFIG_FILE} RETURN_VALUE res)

IF(NOT "${res}" STREQUAL "0")

 MESSAGE(FATAL_ERROR "Cannot submit site file")

ENDIF(NOT "${res}" STREQUAL "0")

  1. Get the siteid from CDash

SET(CDASH_URL ${CTEST_DROP_METHOD}://${CTEST_DROP_SITE}${CTEST_DROP_URL}) SET(CDASH_SITEID_FILE ${CDASH_TEMP_DIRECTORY}/siteid.txt) SET(CDASH_CTESTSCRIPT_FILE ${CDASH_TEMP_DIRECTORY}/ctestscript.cdash) project=${PROJECT}") file(DOWNLOAD ${CDASH_URL}?sitename=${CDASH_SITENAME}&systemname=${CDASH_SYSTEMNAME}&getsiteid=1&project=${PROJECT} ${CDASH_SITEID_FILE}) file(READ ${CDASH_SITEID_FILE} CDASH_SITE_ID) string(STRIP ${CDASH_SITE_ID} CDASH_SITE_ID)

IF(${CDASH_SITE_ID} MATCHES "ERROR:")

 MESSAGE(FATAL_ERROR ${CDASH_SITE_ID})

ENDIF(${CDASH_SITE_ID} MATCHES "ERROR:")

IF(${CDASH_SITE_ID} EQUAL "0")

 MESSAGE(FATAL_ERROR "Cannot define site id")

ENDIF(${CDASH_SITE_ID} EQUAL "0")

file(DOWNLOAD ${CDASH_URL}?siteid=${CDASH_SITE_ID}&getjob=1 ${CDASH_CTESTSCRIPT_FILE})

file(READ ${CDASH_CTESTSCRIPT_FILE} CDASH_CTEST_SCRIPT)

IF(${CDASH_CTEST_SCRIPT} EQUAL "0")

 MESSAGE("Nothing to do...")

ELSE()

 MESSAGE(FATAL_ERROR "Expected response not received from server")

ENDIF() </source>

Client Test Script #2

<source lang="cmake"> set(CDASH_TEMP_DIRECTORY "/tmp/cdash-nightly") SET(CDASH_CTESTSCRIPT_FILE ${CDASH_TEMP_DIRECTORY}/ctestscript.cdash) SET(CDASH_SITEID_FILE ${CDASH_TEMP_DIRECTORY}/siteid.txt) file(READ ${CDASH_SITEID_FILE} CDASH_SITE_ID) string(STRIP ${CDASH_SITE_ID} CDASH_SITE_ID)

IF(${CDASH_SITE_ID} MATCHES "ERROR:")

 MESSAGE(FATAL_ERROR ${CDASH_SITE_ID})

ENDIF(${CDASH_SITE_ID} MATCHES "ERROR:")

IF(${CDASH_SITE_ID} EQUAL "0")

 MESSAGE(FATAL_ERROR "Cannot define site id")

ENDIF(${CDASH_SITE_ID} EQUAL "0")

set(CTEST_DROP_METHOD "http") set(CTEST_DROP_SITE "elysium") set(CTEST_DROP_URL "/CDash-nightly/submit.php") SET(CDASH_URL ${CTEST_DROP_METHOD}://${CTEST_DROP_SITE}${CTEST_DROP_URL})

file(DOWNLOAD ${CDASH_URL}?siteid=${CDASH_SITE_ID}&getjob=1 ${CDASH_CTESTSCRIPT_FILE})

file(READ ${CDASH_CTESTSCRIPT_FILE} CDASH_CTEST_SCRIPT) if("${CDASH_CTEST_SCRIPT}" MATCHES "client testing works")

 message("Test passed")
 return()

endif()

message(FATAL_ERROR "failed to hear from server") </source>

Setting CMake variables

Once you've created your .xml and two .ctest files it's time to reconfigure CMake.

CDASH_USE_SELENIUM               ON                                                                                 
CLIENT_TEST_SCRIPT1              /path/to/client-part1.ctest                              
CLIENT_TEST_SCRIPT2              /path/to/client.ctest  
PHPUNIT_EXE                      /usr/bin/phpunit

Running the tests

At this point you should be able to successfully test client management in CDash:

 cd /path/to/CDashTesting/build
 ctest -VV -R managebuild