Skip to content

Write test resources to JSON file and add delete tool

Tiffany Rea requested to merge write-resource-to-file into master

What does this MR do and why?

Describe in detail what your merge request does and why.

First iteration of https://gitlab.com/gitlab-org/quality/team-tasks/-/issues/1033

Record the creation of resources in a file that can be read after tests are complete.

  • Write resources to text file gitlab/qa/tmp/resource.txt
  • In this file, collect the api_delete_path of each resource and some correlating info except for the gitlab-qa-sandbox-group

So we will have something like this to read from:

/user/keys/30 - QA::Resource::SSHKey - with id '30'
/groups/276 - QA::Resource::Group - with full_path 'gitlab-qa-sandbox-group/qa-test-2021-12-15-08-16-18-b1013efc0ea74380'
/projects/447 - QA::Resource::Project - with full_path 'gitlab-qa-sandbox-group/qa-test-2021-12-15-08-16-18-b1013efc0ea74380/ssh-tests-94030b36954907e6'
/user/keys/31 - QA::Resource::SSHKey - with id '31'
/groups/277 - QA::Resource::Group - with full_path 'gitlab-qa-sandbox-group/qa-test-2021-12-15-08-17-33-1efbb33cf3ba5eaa'
/projects/448 - QA::Resource::Project - with full_path 'gitlab-qa-sandbox-group/qa-test-2021-12-15-08-17-33-1efbb33cf3ba5eaa/ssh-tests-8ce276eb668d2326'
/user/keys/32 - QA::Resource::SSHKey - with id '32'
/groups/278 - QA::Resource::Group - with full_path 'gitlab-qa-sandbox-group/qa-test-2021-12-15-08-23-21-582767e9bd59e14c'
/projects/451 - QA::Resource::Project - with full_path 'gitlab-qa-sandbox-group/qa-test-2021-12-15-08-23-21-582767e9bd59e14c/ssh-tests-ef7c86c5eeab5d0e'
/user/keys/34 - QA::Resource::SSHKey - with id '34'
/groups/280 - QA::Resource::Group - with full_path 'gitlab-qa-sandbox-group/qa-test-2021-12-15-08-58-45-96c1a68c99ad4cf5'
/projects/453 - QA::Resource::Project - with full_path 'gitlab-qa-sandbox-group/qa-test-2021-12-15-08-58-45-96c1a68c99ad4cf5/ssh-tests-ef891a91fdce1085'
  • Add DeleteTestResources class under tools/:
    • Read each line of the file
    • Delete what still doesn't return 404
    • Print out what failed to be deleted
    • Delete the file after finishes
  • Add a rake task for this class

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Tiffany Rea

Merge request reports