Skip to content

Commit f7307a5

Browse files
committed
Add test notes for special files
- How to prepare large files for upload tests - Document commands to use for large file upload tests Signed-off-by: Fon E. Noel NFEBE <[email protected]>
1 parent 64e8f3a commit f7307a5

File tree

2 files changed

+98
-0
lines changed

2 files changed

+98
-0
lines changed

README.md

+32
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,42 @@ 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+
##### Large uploads
115+
###### Uploads
116+
117+
To test for large file uploads. A couple of large files are needed and can be downloaded via:
118+
119+
`./special-files-downloader --large`
120+
121+
If you have you own large files you would like to test with, you can list the links to those files in a text file like so:
122+
123+
'my_files.txt'
124+
```
125+
https://link.com/to/file_1.extension
126+
https://link.com/to/file_2.extension
127+
https://link.com/to/file_3.extension
128+
```
129+
130+
and then run `./special-files-downloader --my-sources my_files.txt`
131+
132+
- *You can specify as many paths as you want*
133+
- *You can name the the source text file anything you want but pass the right name and path to `--my-sources`*
134+
135+
**You don't need to download any files if you already have some special files on your computer, simply copy such files into one of these directories `test-tree/special-files/large`, `test-tree/special-files/zips`, `test-tree/special-files/mixed` or `test-tree/special-files/custom`**
136+
137+
Once the files are on disk:
138+
139+
Run `./upload-test.py test-tree/special-files --remote-dir=special-files --log-file=special-files-log.txt --remote=prod --archive-path="/archives/QA (0a21-0000)/My Files/"`
140+
114141
### What file types and scenarios are left out?
115142

116143
Anything not included in the section above describing what is currently covered is by implication excluded from these tests.
117144

145+
## Troubleshooting
146+
147+
- Remember that the commands are examples and some of the arguments may not apply to your specific environment.
148+
- *For example ensure that arguments such as `--remote`, `--archive-path` are updated and correct*
149+
118150
## Web Interface
119151

120152
For prod, just go to the site as per usual. For dev, go to

special-files-downloader.py

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env python3
2+
import os
3+
import sys
4+
import argparse
5+
import requests
6+
from urllib.parse import urlparse
7+
8+
SPECIAL_FILES_PATH = "test-tree/special-files/"
9+
LARGE_FILE_URIS = [
10+
"https://www.quintic.com/software/sample_videos/Cricket%20Bowling%20150fps%201200.avi"
11+
]
12+
ZIP_FILE_URLS = []
13+
14+
15+
def parse_cli():
16+
parser = argparse.ArgumentParser(
17+
prog="special-files-downloader", description="Download special test files"
18+
)
19+
20+
parser.add_argument("--large", help=f"Download large files for testing")
21+
parser.add_argument("--zip", help=f"Download zip files for testing")
22+
parser.add_argument(
23+
"--my-sources", help=f"Download files from links listed in text file path"
24+
)
25+
parser.add_argument(
26+
"--all",
27+
help="Download all earmarked special files.",
28+
)
29+
30+
return parser
31+
32+
33+
def download_file_from_url(uri, path):
34+
response = requests.get(uri, allow_redirects=False)
35+
fname = os.path.basename(urlparse(uri).path)
36+
if response.status_code == 200:
37+
with open(path + fname, "wb") as file:
38+
file.write(response.content)
39+
40+
41+
def main():
42+
parser = parse_cli()
43+
if len(sys.argv) == 1:
44+
parser.print_help()
45+
print("No downloads done....")
46+
args = parser.parse_args()
47+
48+
if args.large:
49+
for uri in LARGE_FILE_URIS:
50+
download_file_from_url(uri, SPECIAL_FILES_PATH + "large/")
51+
if args.zip:
52+
for uri in ZIP_FILE_URLS:
53+
download_file_from_url(uri, SPECIAL_FILES_PATH + "zips/")
54+
if args.all:
55+
ALL = ZIP_FILE_URLS + LARGE_FILE_URIS
56+
for uri in ALL:
57+
download_file_from_url(uri, SPECIAL_FILES_PATH + "mixed/")
58+
if args.my_sources:
59+
sources = open(args.my_sources, "r")
60+
sources = sources.readlines()
61+
for source in sources:
62+
download_file_from_url(source, SPECIAL_FILES_PATH + "custom/")
63+
64+
65+
if __name__ == "__main__":
66+
main()

0 commit comments

Comments
 (0)