Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support galasactl runs delete --name U52 #1210

Closed
16 tasks done
jasonrhughes opened this issue Oct 13, 2022 · 2 comments
Closed
16 tasks done

Support galasactl runs delete --name U52 #1210

jasonrhughes opened this issue Oct 13, 2022 · 2 comments
Assignees
Labels
cli Galasa CLI enhancement New feature or request

Comments

@jasonrhughes
Copy link

jasonrhughes commented Oct 13, 2022

# Original Text from @jasonrhughes

Over time, local test runs build up and the local RAS directory content grows accordingly.
We could manually trim the directory contents (if this doesn't upset Galasa) but a more elegant solution might be to right click results (or group of results) in the Galasa Results view and delete them from there - which would also clear them from the RAS.

(I would personally not want this to be automatically time-based - i.e., delete test runs older than a certain age - but rather to be able to prune manually.)

I notice it's possible to do this from the Galasa Runs view but the very few runs contained there don't correspond to those in the Galasa Results view.

Story

As a user of galasa, I want to be able to delete test runs which have completed in the past, so that they don't take up space in my Galasa system.

Background

  • The user can query which test runs between dates already: galasactl runs get --age 6w:1w
  • Using the --format raw makes it easy to get the names of the runs out using a script.
  • We introduce the galasactl runs delete --name xxx command to allow individual runs to be removed.
  • Then the user has full control over what gets deleted. They can implement a regular check to delete old stuff, or be more selective.
  • The CLI must turn the run name into the run id ?
  • If the run is already deleted, the command passes.
  • If the run is deleted, no output is observed, only the 0 (OK) exit code.
  • Deleting the run also delete the re-runs
  • runs delete requires a bootstrap, and doesn't work locally.

The Rest API changes

DELETE /ras/runs/{id}

Does not take a body. Ignores it.

Status codes:

200 OK (same if the property was deleted, or it doesn't exist).
401 Unauthorised. Invalid JWT token, or you don't have permissions.
400 Bad request : The run is currently active. Cancel if first.

Assumptions: We have done the story which always makes sure that Finished state is reached when a test run is cancelled. Story #1775

Once complete, we can try as script like this:

#! /usr/bin/env bash

# Where is this script executing from ?
BASEDIR=$(dirname "$0");pushd $BASEDIR 2>&1 >> /dev/null ;BASEDIR=$(pwd);popd 2>&1 >> /dev/null
# echo "Running from directory ${BASEDIR}"
export ORIGINAL_DIR=$(pwd)
cd "${BASEDIR}"

#-----------------------------------------------------------------------------------------                   
#
# Set Colors
#
#-----------------------------------------------------------------------------------------                   
bold=$(tput bold)
underline=$(tput sgr 0 1)
reset=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 76)
white=$(tput setaf 7)
tan=$(tput setaf 202)
blue=$(tput setaf 25)

#-----------------------------------------------------------------------------------------                   
#
# Headers and Logging
#
#-----------------------------------------------------------------------------------------                   
underline() { printf "${underline}${bold}%s${reset}\n" "$@" ;}
h1() { printf "\n${underline}${bold}${blue}%s${reset}\n" "$@" ;}
h2() { printf "\n${underline}${bold}${white}%s${reset}\n" "$@" ;}
debug() { printf "${white}%s${reset}\n" "$@" ;}
info() { printf "${white}➜ %s${reset}\n" "$@" ;}
success() { printf "${green}✔ %s${reset}\n" "$@" ;}
error() { printf "${red}✖ %s${reset}\n" "$@" ;}
warn() { printf "${tan}➜ %s${reset}\n" "$@" ;}
bold() { printf "${bold}%s${reset}\n" "$@" ;}
note() { printf "\n${underline}${bold}${blue}Note:${reset} ${blue}%s${reset}\n" "$@" ;}

h2 "Querying the RAS for old records we don't want any longer."
mkdir $BASEDIR/temp
cd $BASEDIR/temp >> /dev/null

set -o pipefail

galasactl runs get --age 120d:90d --format raw | cut -f1 -d'|' | sort | uniq > files-to-delete.txt
rc=$? ; if [[ "${rc}" != "0" ]]; then error "Failed to query the test runs to delete." ; exit 1 ; fi
success "Queried the run records we want to delete."

h2 "Deleting the run records we don't care about."
while IFS="" read -r line || [ -n "$testRunName" ]
do
    info "Deleting test run $testRunName"
    galasactl runs delete --name $testRunName
    rc=$? ; if [[ "${rc}" != "0" ]]; then error "Failed to delete the test runs $testRunName" ; exit 1 ; fi
    success "Deleted test run $testRunName"
done < files-to-delete.txt

cd - >> /dev/null 

Tasks

  • Code up the API servlet + unit test
    • handles deletion of re-runs also
    • add a delete method into the RAS extensions API discard already exists on the IRunResult interface
      • and the default implementation (can be a no-op)
      • and the couchdb implementation
    • openapi.yaml updates
  • Code up the CLI to call the new servlet
    • Converts the name to the id
    • insists on a bootstrap
    • insists on a run name (not a restart run name)
    • Calls the API endpoint
    • Handles the return code
    • Shows no output if things worked, or if the run wasn't found (already deleted).
  • Add test to the ecosystem scripts to delete a run and check it has gone.
  • Docs in the readme of the CLI
  • Docs in the galasa.dev site (administering the ecosystem section).
@techcobweb techcobweb added the enhancement New feature or request label Nov 15, 2022
@techcobweb
Copy link
Contributor

We are looking at enhancing the command-line tool so that tasks such as this could be automated more easily...

See https://ibm.box.com/s/fsc4bwxsb9pb8jdcymk30ay7vsf7l8fq

The scope of this request is covered if we implement these plans.
Happy to have comments on that document if you have any...

@techcobweb techcobweb added the cli Galasa CLI label Jan 12, 2023
@techcobweb techcobweb moved this to 📋 Backlog in galasa-dev team Mar 30, 2023
@techcobweb techcobweb moved this from 📋 5 Backlog to 🆕 New in galasa-dev team Feb 21, 2024
@techcobweb techcobweb moved this from 🆕 New to 📋 5 Backlog in galasa-dev team Feb 21, 2024
@techcobweb techcobweb moved this from 📋 5 Backlog to 4 Release backlog in galasa-dev team Mar 11, 2024
@techcobweb techcobweb changed the title Enhancement request: delete test runs from Galasa Results to prune RAS size Support galasactl runs delete --name U52 Mar 11, 2024
@techcobweb techcobweb moved this from 4 Release backlog to 📋 5 Backlog in galasa-dev team Mar 25, 2024
@techcobweb techcobweb moved this from 📋 5 Backlog to 4 Release backlog in galasa-dev team Jul 24, 2024
@techcobweb techcobweb self-assigned this Aug 6, 2024
@techcobweb techcobweb removed their assignment Aug 19, 2024
@techcobweb
Copy link
Contributor

@jt-nti Thinking we need a new chapter or something for admins, to cover administering the Galasa service ?

Also we have a script which might be useful here: galasa-dev/cli#278

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cli Galasa CLI enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants