Skip to content

Commit 5e005cf

Browse files
committed
Add instructions for variety testing
Most test currently are using multiple n-byte generated text files. In practice users would have a richer diversity of files, hence this commit: - Add instructions on how to tests with a variety of files types and sizes - Adds a helper bash script to help duplicate/scale the test variety data to a specified volume Signed-off-by: Fon E. Noel NFEBE <[email protected]>
1 parent e2debbe commit 5e005cf

File tree

2 files changed

+90
-4
lines changed

2 files changed

+90
-4
lines changed

README.md

+30-4
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ Run `./upload-test.py test-tree/challenging-names --only=414 --remote-dir=test-4
111111
```
112112
- No duplicates should be be seen on Permanent UI.
113113

114+
### Uploads
114115
#### Large uploads
115-
##### Uploads
116116

117117
To test large file (`400MB` +) uploads, a couple of large files are required. Some ready-made test files can be downloaded via:
118118

@@ -192,14 +192,14 @@ Run
192192
Check the downloads folder in `test-tree/downloads` and ensure that the `downloads/nested` directory has a structure like the nested directory uploaded in the [nested uploads test](#nested-uploads).
193193

194194

195-
#### Quantity Tests
195+
### Quantity Tests
196196

197197
To test uploads/downloads with a large number of files, we definitely need "a large number" of files on either side (local/remote) of the process.
198198

199199
To generate a number of files with a specific size in `test-tree/special-files`, run `./create-files.py --quantity 10 --size 10000 --root-name "10-10B"` (*In this case, the command would generate 10, 10 bytes files.*)
200200

201201
*Take note that in the command `--quantity`, `--size` and `--root-name` are arguments whose values you can change. Quanity for number of files, size for file zie and root name for the name of the parent folder that would hold the files*
202-
##### Large number of uploads
202+
#### Large number of uploads
203203

204204
For 1000, 1B Files:
205205
- Run `./create-files.py`
@@ -223,8 +223,34 @@ For 1000, 5MB Files:
223223

224224
*Of course, by looking at the pattern above, other number-size arrangements can be generated for further testing.*
225225

226+
#### Variety of file types/sizes
226227

227-
##### Large number of downloads
228+
*Prepare data variety*
229+
230+
To test a variety of file types/sizes simply create a directory in `test-tree` such as `variety` and store a bunch of diffent files types in the range of a few kilo bytes to about 50 mega bytes. Ideally, a few images (`.png`, `.jpg`), document files (`.docx`, `.ppt`, `.xlxs`), video and sound files, and archive files.
231+
232+
*Otherwise*
233+
234+
- You can download our test data stored in aws via `aws s3 cp s3://permanent-repos/test_files/critical-path.zip ./test-tree/variety`. (Access required via aws authentication)
235+
- It's a zip file, so remember to unzip: `unzip -d ./test-tree/variety ./test-tree/variety/critical-path.zip`
236+
- Delete the zip or move it to avoid it being part of the test data `rm ./test-tree/variety/critical-path.zip`
237+
238+
*Duplicate data*
239+
240+
Once you have the files in place, you duplicate the files to achieve a desire volume using the duplication script described in the next section.
241+
242+
The `./duplicate-files` script is designed to create multiple copies of files in a specified source directory. It allows you to make 'n' copies of each file found in the source directory and save them in either the same directory or a different destination directory.
243+
244+
Usage: `./script.sh <source_path> <n> <destination_path (optional)>`
245+
246+
##### *Variety upload test*
247+
248+
Now you can test uploads with the variety of files set up in `./test-tree/variety`
249+
250+
- Run `./upload-test.py test-tree/variety --remote-dir=variety --log-file=variety.txt --remote=prod --archive-path="/archives/QA (0a21-0000)/My Files/"`
251+
252+
253+
#### Large number of downloads
228254

229255

230256

duplicate-files

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
if [ $# -lt 2 ]; then
4+
echo "Usage: $0 <source_path> <number_of_duplicates> [destination_path]"
5+
exit 1
6+
fi
7+
8+
source_path="$1"
9+
n="$2"
10+
destination_path="$3"
11+
12+
if [ ! -d "$source_path" ]; then
13+
echo "Error: The specified source path does not exist."
14+
exit 1
15+
fi
16+
17+
if [ "$n" -le 0 ]; then
18+
echo "Error: 'n' should be a positive integer."
19+
exit 1
20+
fi
21+
22+
if [ -z "$destination_path" ]; then
23+
destination_path="$source_path"
24+
fi
25+
26+
# Check if the destination path already exists
27+
if [ ! -d "$destination_path" ]; then
28+
echo "Notice: The specified destination path does not exist. Creating it..."
29+
mkdir -p "$destination_path"
30+
fi
31+
32+
# Loop through each file in the specified source path
33+
for file in "$source_path"/*; do
34+
if [ -f "$file" ]; then
35+
filename=$(basename "$file")
36+
37+
# Check if there's an extension
38+
if [[ "$filename" == *.* ]]; then
39+
file_extension="${filename##*.}"
40+
filename_without_extension="${filename%.*}"
41+
else
42+
file_extension=""
43+
filename_without_extension="$filename"
44+
fi
45+
46+
# Create 'n' copies of the file in the destination path
47+
for ((i = 1; i <= n; i++)); do
48+
if [ -z "$file_extension" ]; then
49+
new_filename="${filename} ($i)"
50+
else
51+
new_filename="${filename_without_extension} ($i).$file_extension"
52+
fi
53+
54+
cp "$file" "$destination_path/$new_filename"
55+
echo "Created copy: $destination_path/$new_filename"
56+
done
57+
fi
58+
done
59+
60+
echo "Done."

0 commit comments

Comments
 (0)