TestFileDB, a database of test files for use in automated software tests

The TestFileDB is a small python database of PFNs of files used for automated software tests. The database lives within the existing software structure and can thus be used in any project/package.

Table of Contents

Why should I use it?

  1. Inviolability. The database refers to files by a logical dataset name, or a qmtest name. This allows for an extra layer of obfuscation whereby new files can be chosen or files can be moved to different locations without the test authors needing to change a single line of tests.
  2. Accountability. Not only does TestFileDB keep the PFNs, but also a whole host of file metadata about who produced it, why, and under which conditions. This vastly simplifies management of test files and debugging.
  3. Usability. TestFileDB comes with a framework of useful and extensible features since it is a full python module. Migration of files to the standard test element is simplified, inclusion of a file into a qmtest or an options file is simplified, etc. see below.

Where is it?

TestFileDB lives under PRConfig, the DBASE package designed to hold options files and tests for the LHCb Performance and Regressions testing system.

Using and abusing the package:

- How can I access it?

TestFileDB is a full python module including inbuilt help. The actual database is stored in a simple python dictionary within the module, called test_file_db. Try:

SetupProject LHCb --use PRConfig
lb-run --use=PRConfig LHCb/v42r1 python 
and then in python:
from PRConfig import TestFileDB
print TestFileDB.test_file_db.keys()
print TestFileDB.test_file_db["2012_raw_default"]

- How can I browse what's there?


  1. Read through the python module in gitlab: https://gitlab.cern.ch/lhcb-datapkg/PRConfig/blob/master/python/PRConfig/TestFileDB.py
  2. Browse through the entries in TestFileDB as shown above
  3. Browse through using the browsing script $PRCONFIGROOT/scripts/BrowseTestFiles.py The inbuilt browser works like browsing a directory structure where files are separated into "directories" based on their metadata.
  4. Browse manually with the low-level helper commands. This is the basic part that is wrapped in the BrowseTestFiles.py script.
from PRConfig import TestFileDB
from PRConfig import TestFileUtils

- How can I access it through options?

  • The following is completely valid python options:
from Configurables import Moore
from PRConfig import TestFileDB

- How can I use it in my project?

PRConfig should be available in all LHCb applications. If not you may need to explicitly include it in your lb-run statement:

lb-run --use=PRConfig SomeProject /vXrY 

- Can I maintain my own list of files in this way even if they are not for general consumption?

Yes! Please do. You can create a new database starting from a python dictionary and importing the base class object testfiles from TestFileObjects import testfiles.

Editing and adding

- Obtaining a local copy for editing

This obviously depends where (in which project) you're planning on adding the tests. The example below is for Moore, replace with your version.

lb-dev Moore/latest
cd MooreDev _HEAD
git lb-clone-pkg PRConfig

Edit, commit with release notes.

- Editing

In general make sure:

  • Your files are accessible for anyone who may run from the database. Usually this means they need to be at CERN on EOS, castor or in some public directory (DEV).
  • You can access the files without needing a grid certificate.
  • The files listed are PFNs.
  • You have added as much information as possible to the metadata of the files.
  • You have not missed any required metadata, the automatic script below will ensure you don't miss anything, or you can check with the TestReadable script: https://gitlab.cern.ch/lhcb-datapkg/PRConfig/blob/master/scripts/TestReadable.py

Remember that this is a full python module, so any valid python to create the entries in the database is allowed, even something procedural.

- Database tags:

One of the key features of the TestFileDB is that it can store the database tags appropriate for reading the files. This is a very useful feature, since the database tags might sit far outside the standard tags for random test files. Please be mindful of this when filling the database. Please use the following priority to decide which tags to use:

  1. The tags used in creation of the file. If there is any way of you finding this out you are encouraged to do so.
  2. A compatible pair of tags which are necessary updates to the tags used to create the file. In case the original tags are not compatible with current software, small updates may be required.
  3. If all else fails, an appropriate pair of tags that you deem appropriate for running on this file can be entered. In case you really cannot find out what was originally used, or what is originally used is completely so obsolete to be entirely irelevent, then please enter any two compatible tags which you deem appropriate, but only if this is really really necessary.

- Adding files to CERN-SWTEST/EOS:

CAUTION: as of 01/05/20, the CERN-SWTEST is not managed as a DIRAC StorageElement anymore

ACTION RESTRICTED TO RELEASE MANAGERS: you must be a member of lhcb-release-managers egroup

For files actually used in our automated nightly tests, especially centrally produced files we need to make sure they are not tied to the validity of a specific user account or production obsoletion cycle.

If you have the file locally on lxplus, just copy it over to whatever location you find suitable under /eos/lhcb/cern-swtest/lhcb/swtest/:

eos cp myFile.root /eos/lhcb/cern-swtest/lhcb/swtest/<mySubFolders>

The corresponding PFN will be "root://eoslhcb.cern.ch//eos/lhcb/cern-swtest/lhcb/swtest//myFile.root"

If the file is a GRID produced file, it is good practice to keep the LFN as subfolder: /eos/lhcb/cern-swtest/.

For example, the file /lhcb/MC/Upgrade/LDST/00075219/0000/00075219_00007952_1.ldst:

eos cp 00075219_00007952_1.ldst /eos/lhcb/cern-swtest/lhcb/MC/Upgrade/LDST/00075219/0000/00075219_00007952_1.ldst

If you have the file on the grid, please download it in a temporary folder before copying it to /eos/lhcb/cern-swtest:

lb-dirac bash --norc
dirac-dms-get-file <LFN>

You can then check the files are readable for you with the script TestReadable.py: https://gitlab.cern.ch/lhcb-datapkg/PRConfig/blob/master/scripts/TestReadable.py

- Commit and use in nightlies

Don't forget to edit the release notes before you commit! Contact Marco Cattaneo and Marco Clemencic if you want these files to be immediately accessible in the nightlies, and/or request a release of PRConfig by contacting Ben Couturier and Marco Clemencic.

Edit | Attach | Watch | Print version | History: r21 < r20 < r19 < r18 < r17 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r21 - 2020-10-26 - RosenMatev
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    LHCb All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use Discourse or Send feedback