![]() |
FOSSology Advancing open source analysis and development |
The tests are designed to be run from the FOSSology source tree. This cuts down on installation and configuration time.
The installation process has been automated. As sudo, just run the Install.php script found in the tests directory.
$ sudo Install.php
If for some reason parts of the install fail, each step can be done by hand and usually there is a separate script for each step.
The initial install only needs to be done the first time the tests are installed. After that, the tests can be run as often as needed.
Installation is really a two phase step. First the Install.php script is run. Then a small set of manual steps are performed. When all of the steps have been completed with no errors, the tests are ready to run (see below for the complete list).
TODO: Rando to write a check script to check on the configuration….
The initial install script is run when the tests have never been installed on a system or when a retest is needed and the system was upgraded to a new OS or the test users and data were removed from the system.
To run the install script:
cd <path-to-sources>/fossology/tests sudo ./Install.php
Usually the Install script is run just once. It does not hurt to run it multiple times.
The steps below are required when first installing the test suite.
TG cd over to the fosstester's sources. cd to the test directory.sudo ./lnfo-runTests.php
fosstester run the configTestEnv.php script to create the test environment.fosstester$ ./configTestEnv.php 'http://mysys.domain/repo/' fosstester fosstester
Run the tests
./testFOSSology.php -a
See Install Steps Detail section below for more details on the install process.
There are times when parts of the test install need to be redone after an initial install. This document can't detail all of them but will try to capture the tasks that seem to need to be re-done as the test system is used.
createUIUsers.php script using fo-runTests. First the TestEnvironment.php file must be changed to the fossy user or any user allowed to create accounts../configTestEnv.php 'http://mysys.domain/repo/' fossy fossy fo-runTests -l createUIUsers.php
or
./fo-runTests.php -l createUIUsers.php ./configTestEnv.php 'http://mysys.domain/repo/' superuser superduper
Important Note for Multi-System Setups - make sure the scheduler.conf file is configured correctly or the upload from server tests will fail. Either the test users home dir needs to be mounted under /home on all the agents or restrict where fosscp can run (either confine it to the server or the server and a single agent). If you don't want to mess with NFS just confine fosscp to the server and 1 agent. Then on that designated agent, check out the sources and install the test user and the test data.
All of the tests use the &nopopup=1 parameter when logging in. This makes the java script popups turn into a H3 heading instead.
The fosstester user and user data should be created/installed before running the suites. The tests are fully automated. Use the -a option to run all of the tests (normal usage). Using the -a option, the script will wait for the uploads to complete and then run the verify tests. If for some reason the automation does not work, the verify step can be run by hand see Running the Test Suites below for an example.
All suites can be run from a master script testFOSSoloyg.php located at
..path-to-sources/fossology/tests/ ./testFOSSology.php -a
The testFOSSology.php script when running will log it's output in …path-to-sources/fossology/tests/FossTestResults-yyyy-mo-day-hh:mm:ss-[am|pm]. When -a is used, then all the results are logged in a single file. When the verify step runs it moves the test results to ~fosstester/public_html/TestResults/Data/Latest.
The tests have finished. How do you tell if they passed? The easiest way is to grep the log file:
grep Passes FossTestResults-2009-05-14-10:57:21-am results in: Test cases run: 1/3, Passes: 30, Failures: 0, Exceptions: 0 Test cases run: 19/21, Passes: 290, Failures: 0, Exceptions: 0
The above will show you all of the results lines from each suite that was run. As long as Failures is 0 for everything, the tests passed. If there is a failure, examine the log file and use the sections Common Test Failures and Test Output and Investigating Test Failures to help investigate the failure.
When developing a test and debugging it often just that test is all that needs to be run. There is an easy way to do that now using fo-runTests. To run a single test, cd to the test directory where the test file is:
fo-runTests -l test2run.php
The above example assumes that the tests were installed. Part of the installation is to create a symlink in /usr/local/bin for ease of use. If the link didn't exist, one would have to put a relative path in to the php file.
For example: cd ui/tests/BasicTests ../../../tests/fo-runTests.php -l mytest.php
The moral of the story is that if the link isn't there, use the relative path to the tests directory where fo-runTests.php is located.
All suites can be run from a master script testFOSSoloyg.php located at
..path-to-sources/fossology/tests/
Make sure the testFOSSology.php script executable, (it should be that way already).
The usage for testFOSSology.php is:
Usage: ./testFOSSology.php [-l path] {[-a] | [-b] | [-h] | [-s] | [-v -l]}
-a: Run all FOSSology Test Suites
-b: Run the basic test suite. This runs the SiteTests and any Tests that don't depend on uploads
-h: Display Usage
-l path: test results file path
-s: Run SiteTests only (this is a lightweight suite)
-v -l: Run the Verify Tests. These tests require uploads to be uploaded first.
See the test documentation for details You must specify a log file when using -v, best to use the same
log file that was used in a previous run for example -a -l foo, then -v -l foo when all the files
have been uploaded with -a.
The tests are fully automated. Use the -a option to run all of the tests (normal usage). Using the -a option, the script will wait for the uploads to complete and then run the verify tests. If for some reason the automation does not work, the verify step can be run by hand, like the example below.
./testFOSSology -v -l <previous run logfile>
The testFOSSology.php script when running will log it's output in …path-to-sources/fossology/tests/FossTestResults-yyyy-mo-day-hh:mm:ss-[am|pm]. When -a is used, then all the results are logged in a single file. When the verify step runs it moves the test results to ~fosstester/public_html/TestResults/Data/Latest.
Each suite when run separately will create it's own log file with the format FossTestResults-yyyy-mo-day-hh:mm:ss-[am|pm]. These results will not be moved to the TestResults area.
/repo/ part of the url. The other common mistake is getting the hostname wrong. Either of these mistakes will cause all the tests to fail due to login failures. All of the tests may pass, but may not be run by the user you expect, check the file before running the tests./usr/local then the tests will appear to run very fast but the results files will be empty. The tip off is it will say waiting for jobs to finish but will continue executing.Feel free to add your own to the list!
The initial install script performs the following steps:
fosstester and noemail. The fosstester user is used to run the test suite.fosstester's home directory into three sub directories, archives, licenses and public_html.fosstester account. The install script attempts to adjust the servers file in the .subversion directory so that fosstester can check out the source. This is required.The steps below are for use when the steps need to be run individually or if something does not work in the inital install and needs to be redone.
This step must be done by a user with sudo access. Make sure to cd to the correct source location and to the tests directory in the sources (not the ui/tests). Run the script.
sudo ./lnfo-runTests.php
wget http://downloads.sourceforge.net/simpletest/simpletest_1.0.1.tar.gz sudo cp simpletest_1.0.1.tar.gz /usr/local cd /usr/local sudo tar -xvf simpletest_1.0.1.tar.gz
As sudo run the script in tests:
sudo ./CreateTestUser.sh
As a sudo user run the script in tests
sudo installTestData.sh
Before the script can be run, the TestEnvironment file must be changed so the user is fossy, then the script is run and then change the TestEnvironment file back (either edit directly or reurn script).
./configTestEnv.php 'http://mysys.domain/repo/' fossy fossy fo-runTests -l createUIUsers.php or ./fo-runTests.php -l createUIUsers.php ./configTestEnv.php 'http://mysys.domain/repo/' fosstester fosstester
NOTE This section needs some work. It's correct, but was written before the Initial Install section was written. Kept in here for now.
cd ….path-to-sources/fossology/tests
sudo ./Install.php
For example:
cd ...path-to-sources/fossology/tests/ configTestEnv.php http://fluffy.ostt/repo/ fosstester fosstester the url must end in a / and the path should be to the repo you want to test. For example, repo/ could be ~rando/ui/
The above step sets up an include file called TestEnvironment.php. The script puts the file in the current directory.
Make sure that the file TestEnvironment.php exists in the directory …path-to-sources/fossology/tests.
<as a user with sudo access...> cd ...path-to-sources/fossology/tests/ sudo lnfo-runTests.php
The first suite is call SiteTests and are very light weight. SiteTests are designed to run right after an install and initialization of the repo. They verify that the site can be logged into and that the main important menus are operational. It does no real functional testing other than logging in and verify you can get to a real sub menu. To run the suite:
cd to ...path-to-sources/fossology/ui/tests/SiteTests runSiteTests.php
BasicTests are functional tests for the UI that do not depend on uploaded files. To run them:
cd to ...path-to-sources/fossology/ui/tests/BasicTests runBasicTests.php
NOTE the step below is no longer needed, testFOSSology script takes care of it.
Important Before running verify tests upload the required material.
cd to ...path-to-sources/fossology/tests/ ./uploadTestData.php
The script above will upload all the files that the Verify tests depend on. Uploading from a url must work for this script to complete successfully. The script is actually a simpletest, so if it fails it will tell you why.
VerifyTests are functional tests for the UI that depend on uploaded files. The tests should first check to see if the archive they depend on is uploaded. If it is not, the tests should fail. To run them:
cd to ...path-to-sources/fossology/ui/tests/VerifyTests runVerifyTests.php
The verify tests are not very smart. They assume that all the test suites were run. There may be failures if only selected suites are run and then the verify suite is run.