Skip to content

Commit 9413eb4

Browse files
authored
Merge pull request #1 from OpenTechStrategies/update-usage
Update usage
2 parents c2f9e51 + 65fcf67 commit 9413eb4

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
test-tree/challenging-names
22
test-tree/apod
33
__pycache__
4+
venv

README.md

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,22 +10,52 @@ protocol.
1010
For more context, see [this
1111
discussion](https://chat.opentechstrategies.com/#narrow/stream/73-Permanent/topic/QA/near/155527).
1212

13+
## Testing scope
14+
15+
The scope of testing here verifies the possibility of correctly uploading and downloading
16+
a finite set of file types in a particular size range to [Permanent.org](Permanent.org) using [rclone](https://rclone.org/)
17+
which talks to permanent using the [SFTP service](https://github.com/PermanentOrg/sftp-service)
18+
19+
### What file types and scenarios are covered?
20+
21+
- Text and png images with obscure names generated via [generate-tree.py](generate-tree.py)
22+
- Images in `.jpg` and `.png` format downloaded from [APOD](https://apod.nasa.gov/apod) via [apod-downloader.py](apod-downloader.py)
23+
- Compressed files in `.zip` and `.tar`
24+
- Videos in `.mp4`, `.webm`, `.gifs` and `.3gp` common in mobile devices.
25+
- Executable files in `.exe`, `.run`, `.sh`, `.dep` and extension-less bin executables.
26+
27+
### What file types and scenarios are left out?
28+
29+
Anything not included in the section above describing what is currently covered is by implication excluded from these tests.
30+
1331
## Usage
1432

33+
You would have to install the python requirements used in this repo.
34+
35+
1. `python -m venv venv`
36+
2. `source venv/bin/activate`
37+
3. `pip install -r requirements.txt`
38+
39+
*It's possible to just install the requirements on your workspace however steps 1 and 2 would create and activate a virtual environment for this project alone! Recommended!*
40+
1541
### APOD
1642

1743
Run `./apod-downloader.py` to download a set of Astronomy Of The Day
1844
photos, in a new directory called `test-tree/apod`.
1945

20-
Run `./upload-test.sh test-tree/apod` to try uploading the APOD photos
46+
Run `./upload-test.py test-tree/apod --archive-path "/archives/rclone QA 1 (0a0j-0000)/My Files/"` to try uploading the APOD photos
2147
(and some html) all at once to a directory on the server.
2248

49+
**NB: The `--archive-path` argument specifies the route to the the specific permanent archive to which uploads would be made. So how do you get the archive path? See [Constructing archive path](https://github.com/permanentOrg/sftp-service/#downloading-from-permanent)**
50+
51+
*That said, the archive path used in the sample command would have to be updated to match some archive created on Permanent.org*
52+
2353
### Challenging Names
2454

2555
Run `./generate-tree.py` to generate test data, which will be placed
2656
in a new subdirectory named `test-tree/challenging-names`.
2757

28-
Then run `./upload-test.sh test-tree/challenging-names` to try uploading the data (you'll need to
58+
Then run `./upload-test.py test-tree/challenging-names --archive-path "/archives/rclone QA 1 (0a0j-0000)/My Files/"` to try uploading the data (you'll need to
2959
[configure
3060
rclone](https://github.com/PermanentOrg/sftp-service#running-rclone-against-permanentorg-instances)
3161
first, of course). See the long comment at the top of

requirements.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
beautifulsoup4==4.12.0
2+
python_dateutil==2.8.2
3+
requests==2.25.1

upload-test.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env python3
22

3-
RCLONE_REMOTE = "permanent-"
4-
ARCHIVE_PATH = "/archives/rclone QA 1 (0a0j-0000)/My Files/"
3+
RCLONE_REMOTE = "permanent"
4+
ARCHIVE_PATH = ""
55
CHALLENGING_NAMES_DIR = "test-tree/challenging-names"
66
APOD_DIR = "test-tree/apod"
77
MISC_DIR = "test-tree/misc"
@@ -52,6 +52,7 @@ def omit_p(fname, omit_list):
5252
def parse_cli():
5353
global LOG_FILE
5454
global RCLONE_REMOTE
55+
global ARCHIVE_PATH
5556

5657
parser = argparse.ArgumentParser(
5758
prog="upload-test",
@@ -65,7 +66,8 @@ def parse_cli():
6566
help="specify file of ids to omit (misc and challenging-names)",
6667
)
6768
parser.add_argument("--only", help="only test one file id")
68-
parser.add_argument("--remote", help="prod or dev", default="dev")
69+
parser.add_argument("--remote", help="Name of configured rclone remote such as permanent-prod or permanent-dev")
70+
parser.add_argument("--archive-path", help="Archive path in Permanent.")
6971
parser.add_argument(
7072
"--remote-dir",
7173
help="remote subdirectory (defaults to 'test-tree')",
@@ -87,7 +89,13 @@ def parse_cli():
8789
LOG_FILE = args.log_file
8890
if args.omit:
8991
args.omit_files = slurp_if_e(args.omit).strip().split("\n")
90-
RCLONE_REMOTE += args.remote
92+
if args.archive_path:
93+
ARCHIVE_PATH = args.archive_path
94+
if args.remote:
95+
RCLONE_REMOTE = args.remote
96+
else:
97+
log("No rclone remote set. Attempting with default remote `permanent`...", True)
98+
log("If the default remote `permanent` is not configured uploads would fail.", True)
9199

92100
return args
93101

0 commit comments

Comments
 (0)