Setting up and executing the tests ---------------------------------- * The tests are added in pki/tests in the upstream git. * Apply the patch to the DOGTAG_10_0_BRANCH (A seperate patch will be submitted for running on F20). * Compulsory pre-requisite - Build the project in eclipse. The JUnit test classes are compiled to a different folder. Building in eclipse will create the class files at pki/tests/beaker/rhcs/dev_java_tests/bin/ Setting up the beaker-client on local machines ---------------------------------------------- The following steps are needed to setup a beaker client for adding the task rpm and submitting the beaker job to the beaker server. -- Add new repositories in /etc/yum.repos.d: - beaker-client.repo [beaker-client] name=Beaker Client - Fedora19 baseurl=http://beaker-project.org/yum/client/Fedora19 enabled=1 gpgcheck=0 [beaker-client-testing] name=Beaker Client - Fedora19 Testing baseurl=http://beaker-project.org/yum/client-testing/Fedora19 enabled=0 gpgheck=0 -- Install the packages: (There is also a check in compose_pki_test_package for these dependencies) expect, beakerlib, beaker-client, rhts-devel -- Create a file /etc/beaker/client.conf (if not already present after the installation of the packages.) # Base URL of the Beaker server (without trailing slash!) #HUB_URL = "http://hammer1.dsdev.sjc.redhat.com/bkr/" HUB_URL = "https://beaker.engineering.redhat.com/" # Hub authentication method AUTH_METHOD = "krbv" #AUTH_METHOD = "password" # Username and password USERNAME = "akoneru" #PASSWORD = "testing" # Kerberos principal. If commented, default principal obtained by kinit is used. #KRB_PRINCIPAL = "host/$HOSTNAME" # Kerberos keytab file. #KRB_KEYTAB = "/etc/krb5.keytab" # Kerberos service prefix. Example: host, HTTP #KRB_SERVICE = "HTTP" # Kerberos realm. If commented, last two parts of domain name are used. Example: MYDOMAIN.COM. KRB_REALM = "REDHAT.COM" # Kerberos credential cache file. #KRB_CCACHE = "" A beaker server uses two kinds of authentication: Username/Password and a Kerberos login. Currently only the main beaker server is being used - beaker.engineering.redhat.com (A Red Hat internal server. For outsider, the values must be of their own beaker server.) We can login and submit jobs using our kerberos id. Execute kinit @REDHAT.COM With this the basic setup for creating new task rpms (all tests are built into an rpm) and submitting the jobs (represented by an XML. The basic template can be found at pki/tests/beaker/rhcs/beakerjob.rhcs.xml.template). 1. Running the tests from Eclipse. (Only the JUnit tests on the local machine.) -- All the configuration entries of a local setup must be present in the pki/tests/beaker/rhcs/dev_java_tests/src/test.cfg . Once the patch is applied the file will be found under the src package of the tests tests/beaker/rhcs/dev_java_tests/src/. (in Java perspective) **Note** - The pki environment has to be setup before running the tests - the tests do not setup the environment. -- The tests can be either run individually or as as part of a suite. To run the tests as a suite, Open BeakerTestSuite and Run As JUnit test. A suite is a test runner which executes all the tests added to it in the $SuiteClasses tag. There is a customized suite runner PKITestSuite to provide additional functionality when the tests are run in beaker. To run the tests individually - (a class like CATestJunit) - Just run the class as a JUnitTest. 2. Running tests on beaker from command line. ** Assuming that the pki source is clones in /home/test/CS -- Once the pki project is built in eclipse, the task rpm and the beaker jobs can be submitted to the beaker server by executing the compose script in pki/scripts: Usage: ./compose_pki_test_package [Optional] <--runtests> (Builds the task rpm and job xml in /home/test/CS/package.tests/) - The user id is for personalizing the rpm. When a task rpm is submitted to the beaker server, it extracts the rpm to /mnt/tests/CoreOS/rhcs/. This path is taken from the Makefile used to build the rpm(pki/tests/beaker/rhcs/Makefile). So if another rpm with the same to-be-extracted path is added to beaker server, it overwrites the existing test code. In order to prevent that, a unique id (our kerberos id) is used to personalize the rpm. - The optional --runtests option. Without the --runtests options the task rpm and the job xml are not submitted to the beaker server. -- An already built rpm/job (not using the --runtests option above) can be submitted to a beaker server by running ./run_tests [Optional] --wait-on-beaker-job - The run_tests normally just submits the task rpm and job xml to beaker. But when the --wait-on-beaker-job is specified, it blocks the process until the job is completed. -- Creating a repository of the built rpms. A --createrepo option has been added to be used by the compose scripts. Currently only cpmpose_pki_core_packages uses it. The details about where the repository has to be created can be provided in pki/scripts/repository.cfg. A repository of the built rpms will be created by copying the folders RPMS, SRPMS, SPECS, SOURCES in CS/packages to the specified location. If a destination(remote) host name is provided then the repos are scp'ed to the same location on the remote host using the credentials provided. (An expect script - scp_the_repo.exp is used.) (If no credentials are provided, then a prompt appears asking for them.) The "Create_repo_after_build" method in pki/scripts/compose_functions provides the code for handling the --createrepo option. 3. Running tests on beaker from a Jenkins server. Please refer to the Jenkins server at http://vm-051.idm.lab.bos.redhat.com:9090/job/Dogtag-pki/ . Please click on Configure on left panel. Since this patch is not checked in, the project refers to a local build rather than a git location. This setting can be seen by clicking on Advanced button under "Advanced Project Options" section. The compose scripts are called in the Build section. Once the patch is checked in, the project can be configured to use a SCM and Build Triggers can be set. Few more details for reviewing the patch: ----------------------------------------- The beaker test wrapper script for the JUnit tests (for calling the JUnit tests) can be found at "pki/tests/beaker/rhcs/dev_java_tests/run_junit_tests.sh" . This will be called by the main runtest.sh in pki/tests/beaker/rhcs/. It sets up the nssdb to be used by the sample JUnit tests written. And passes in the required env. variables. pki/tests/beaker/rhcs/make-package.sh - Contains code to personalize the task rpm, build the task rpm and create the job xml file. pki/tests/beaker/rhcs/update_beaker_job.py - Creates the job xml from the template file using the values mentioned in job-xml.cfg (in pki/tests/beaker/rhcs/). pki/tests/beaker/rhcs/job-xml.cfg - All the details about the distro to be used, the repos to be used and hostname (a specific beaker test machine loaned for the user whose credentials are present in /etc/beaker/client.conf)