Housekeeping
Purge / Maintenance
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 concerning 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 |