Housekeeping
Automatic housekeeping
As a Community user, please refer to the manual purge guide.
Main concept
Automatic Houskeeping brings the ability for the controller to automatically delete Executions based on a “Time To Live” parameter, meaning a default maximum retention period. In addition to simplifying the user’s life, automatic houskeeping ensures that both deleted and remaining entities are handled in a coherent way and that no orphan objects are left behind.
The following entities are automatically deleted when an execution is deleted:
- The entry corresponding to the execution in the execution table
- The execution report including the generated attachments
- The keyword measures
- The plan at the origin of the execution if and only if it is an ephemeral plan originating from an external repository (ALM, Jira, etc). Plans of the Visual Plan Editor are never deleted automatically.
Housekeeping is available as of v3.11.
Enabling automatic houskeeping
Go to your Admin view and click the Houskeeping entry from the Settings tab. All you have to do is check the “Enable housekeeping” checkbox.
Configuration
Time To Live
The setting TTL of Executions [s] decides for how many seconds past executions will be kept. For instance, if you execute a plan today and set a value of 86400 as a TTL, the execution will be deleted tomorrow (24 hours later).
Scheduler entry
Automatic Housekeeping relies on a scheduler entry which is configured to run every night at mid night. To change the frequency or time of the housekeeping routine execution, go to the Scheduler view and edit the properties of the Housekeeping entry:
Retaining specific executions
Users can now cherry-pick executions one at a time in order for them to be retained and ignored by the housekeeping job. All you have to do is check the Retain this execution box in the Archiving section of your execution as demonstrated on the following screenshot:
Additional comments can be written in the Description text area.
Job execution example
In the following series of screenshot, you’ll see a run in which only one execution had been retained and all others were removed:
Manual Purge
Complete purge
If your database grows too much and you want to get rid of all the old executions and performance metrics, you can drop the whole database then re-import only your work, which is the fastest way to execute a purge. Follow below steps :
- Warning : make sure to backup your work first !
- Connect to you mongo instance and execute the following :
> use step
switched to db step
> db.dropDatabase();
{ "dropped" : "step", "ok" : 1 }
> exit
Keep only current month results
Idea is to execute a backup of the current months collections executions, reports and measurements in order to clean up the database from the previous executions. Let’s say we are currently in October and that we want to remove all data related to executions done before that month. We will first export the executions executed from 1st of October.
- First get the timestamp as NumberLong format we will use to perform our queries. Connect to your database and run the following command :
> NumberLong(ISODate("2017-10-01"))
NumberLong("1506816000000") # This is the result we need
> exit # Exit the database
- We can now export the executions, reports and measurements using following commands :
mongoexport -d step -c executions -q '{"startTime":{"$gt":NumberLong("1506816000000")}}' -o executions_gt_20171001.json
mongoexport -d step -c measurements -q '{"begin":{"$gt":NumberLong("1506816000000")}}' -o measurements_gt_20171001.json
mongoexport -d step -c reports -q '{"executionTime":{"$gt":NumberLong("1506816000000")}}' -o reports_gt_20171001.json
- Execute a complete purge (do not forget to re-import your Keyword and Test Plans !)
- Restore your last month executions by running following commands :
mongoimport -d step -c executions executions_gt_20171001.json
mongoimport -d step -c measurements measurements_gt_20171001.json
mongoimport -d step -c reports reports_gt_20171001.json
Export only 1 execution and its data
Sometimes you may want to backup only 1 test plan execution in order to keep it for later analysis. So first you need to gather the Execution ID of your test plan execution :
- login to your Step instance, go to the Executions tab and click to the execution you want to get the ID :
- Now that you have the execution ID (in our example it is 59d4d8f9a63eaa00074f6dd0), you can export the executions and its data :
mongoexport -d step -c executions -q '{"_id":ObjectId("59d4d8f9a63eaa00074f6dd0")}' -o execution_59d4d8f9a63eaa00074f6dd0.json
# To export the measurement metrics :
mongoexport -d step -c measurements -q '{"eId":"59d4d8f9a63eaa00074f6dd0"}' -o measurements_59d4d8f9a63eaa00074f6dd0.json
# To export executions steps :
mongoexport -d step -c reports -q '{$or: [ { "parentID":ObjectId("59d4d8f9a63eaa00074f6dd0") }, { "executionID":"59d4d8f9a63eaa00074f6dd0" } ] }' -o reports_59d4d8f9a63eaa00074f6dd0.json
You can now restore the executions with its associated data using the following :
mongoimport -d step -c executions execution_59d4d8f9a63eaa00074f6dd0.json
mongoimport -d step -c measurements measurements_59d4d8f9a63eaa00074f6dd0.json
mongoimport -d step -c reports reports_59d4d8f9a63eaa00074f6dd0.json
Note that you can only restore the performance metrics or the functional results depending on your goal. To know which collections to restore use following table :
Collections | Functional results | Performance metrics |
---|---|---|
reports | mandatory | mandatory |
reports | mandatory |
not mandatory |
measurements | not mandatory | mandatory |