Skip to content
This repository has been archived by the owner on Nov 2, 2020. It is now read-only.

Internal database for keywords and variables

Tatu Aalto edited this page Sep 2, 2016 · 5 revisions

What is internal database

Internal database is used to provide keyword and variables completions when user writes Robot Framework test data. The database contains two different parts, table and index. The database is group of files, which are located in the Sublime Text packages directory, under this plugin database directory.

Tables

One table is a single Robot Framework data object, data object here means a test suite, resource or variable file or a library. Table contains details from one data object, like all the keywords and variables it provides, also in a case of a test suite or resource file, which libraries, resources and variables files it imports. Tables contains the same information what one sees in the Robot Framework test suite or resource file, it is just parsed in a json format.

Tables are created by scanning the files from the folder which is defined in the robot_framework_workspace parameter. Scanning will only take account the files which has the extension defined in the robot_frameowrk_extension parameter. Both parameters can be found from the plugin .sublime-settings file.

Scanning will parse the found files and will take account the *** Setting *** table imports. If *** Setting *** table contains imports for resources, libraries and variable files, the scanning will create also a table for the imported objects in the database.

Currently scanning does not take account the Test/Suite/Global variables declared in the test data. Also scanning does not take account libraries dynamically imported in the test data. Also currently plugin is only able to parse libraries defined in Python.

Data for the table is always read from the file located in the file system and it is newer read from the Sublime Text buffer.

Index

One index contains all the keyword and variables which are visible for the single data object. Visible means all the keywords and variables which the data object has defined in *** Keyword *** and *** Variables *** tables and all the keyword and variables which the data object has imported from other resources, libraries and variable files.

Example if resoruce has defined two keywords called Keyword 1 and Keyword 2. Also resource has also imported the String library. Then the index will contain all the keywords from the String and BuiltIn library and the Keyword 1 and Keyword 2 which the resource itself has defined. Also index will contain the default Robot Framework variables like ${SPACE} or ${EMPTY}.

Also index contains information, from which table the keyword is imported from. This is used when jump to the keyword source is done or the keyword documentation is displayed.

Creating the internal database

There are two ways to create database:

  1. Create whole database always from scratch
  2. Create tables in index separately

Robot Framework: Create Database

The Robot Framework: Create Database command is the easiest way to maintain the database. The Robot Framework: Create Database command will always create the database from scratch. This means that all data is erased from database and table and index files are created for each time the command is executed. The downside is time taken in this operation, which gets longer when the keyword and data object amount goes up. In performance testing, using my PC and set of data which contains +3000 keywords and +300 test/resource/libraries objects, the time to create database from scratch is somewhere between 3-4 minutes long. But if the keyword amount is under 1000 and you have under 50 test/resource/libraries in use, creating the database from scratch is a good option.

The creation of database tables, in the above data set, takes about 1 min or so seconds and rest of the time is consumed to create the database index for each data object. Creation of the tables is disk depended operation and index creation is CPU depended operation and therefore the time it takes to execute the Robot Framework: Create Database with your hardware may wary a lot.

Create tables and index in separate operations

For large data sets, it is best to maintain the table and index data is separate operations. For this purpose there are two commands: Robot Framework: Create Database Tables and Robot Framework: Update Internal Database For Active Tab.

The Robot Framework: Create Database Tables command creates all the database tables. This command is intended to run as a first command when the plugin is taken in use and after operations which has updated robot_framework_workspace folder without using Sublime Text. Example like with git pull operations.

The Robot Framework: Update Internal Database For Active Tab command creates the table and index for the tab which is currently active in the Sublime Text. This command is intended to run, when user updated and saved the Robot Framework data file and wants to update the corresponding database table.