Project

Profile

Help

Test #5145

closed

Test scenario for deleting an uploaded content

Added by lmjachky over 4 years ago. Updated over 4 years ago.

Status:
CLOSED - COMPLETE
Priority:
Normal
Assignee:
Sprint/Milestone:
-
Version:
Platform Release:
Tags:
Sprint:
Quarter:

Description

With the pull request https://github.com/pulp/pulpcore/pull/210 comes a change which fixes the issue that prevented users to delete uploaded content from a file system via REST API.

A following test scenario may be used:
1. Create a random file:

dd if=/dev/zero of=2g.bin bs=256M count=8

2. Upload it, e.g. chunk by chunk (source: https://pulp.plan.io/attachments/518614):

#!/bin/bash
pkg=$1
PORT=http://localhost:24817
size=$(ls -l $pkg | cut -d ' ' -f5)
echo "get sha256 sum"
sha256=$(sha256sum $pkg | cut -d ' ' -f1)
echo sha256=$sha256
echo "Split file"
split --bytes=300M $pkg chunk
export UPLOAD=$(http POST $PORT/pulp/api/v3/uploads/ size=$size | jq -r '._href')
echo $UPLOAD
n=0
# get chunck files infos
for f in chunk*; do
  fname[$n]=$f
  fsize[$n]=$(ls -l $f | cut -d ' ' -f5)
  if [ $n -eq 0 ]; then
    bindex[$n]=0
  else
    bindex[$n]=$((${eindex[$(($n-1))]} + 1))
  fi  
  eindex[$n]=$((fsize[$n] + ${bindex[$n]} - 1))
  n=$(($n+1))
done
# upload chuncks
for n in ${!fname[*]}; do
    echo "Uploading: ${fname[$n]} ${bindex[$n]}-${eindex[$n]}"
    http --form PUT $PORT$UPLOAD file@${fname[$n]} "Content-Range:bytes ${bindex[$n]}-${eindex[$n]}/*"
done
echo "Ending Upload"
http PUT $PORT${UPLOAD}commit/ sha256=$sha256

3. Delete uploaded content via REST API:

#!/bin/bash

PORT=http://localhost:24817

for u in $(http $PORT/pulp/api/v3/uploads/ | jq -r '.results[] | ._href'); do
    echo $u
    http DELETE $PORT$u
done

4. Check if the upload was deleted:

http http://localhost:24817/pulp/api/v3/uploads/

{
    "count": 0,
    "next": null,
    "previous": null,
    "results": []
}

cd /var/lib/pulp/uploads/


Related issues

Related to Pulp - Issue #5092: Files are not deleted whent deleting uploadsCLOSED - CURRENTRELEASElmjachkyActions
Actions #1

Updated by lmjachky over 4 years ago

  • Status changed from NEW to ASSIGNED
  • Assignee set to lmjachky
Actions #2

Updated by lmjachky over 4 years ago

  • Status changed from ASSIGNED to POST

Added by Lubos Mjachky over 4 years ago

Revision 21bb248a | View on GitHub

Add test for testing the delete method of uploads

closes #5145 https://pulp.plan.io/issues/5145

Actions #3

Updated by Anonymous over 4 years ago

  • Status changed from POST to MODIFIED
Actions #4

Updated by kersom over 4 years ago

  • Related to Issue #5092: Files are not deleted whent deleting uploads added
Actions #5

Updated by kersom over 4 years ago

  • Status changed from MODIFIED to CLOSED - COMPLETE

Also available in: Atom PDF