Skip to content

Commit a27a18b

Browse files
authored
Merge pull request #5 from OpenTechStrategies/3-nested-folders
Document tests for nested folders
2 parents d6a682b + 79c71af commit a27a18b

File tree

7 files changed

+64
-20
lines changed

7 files changed

+64
-20
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ test-tree/*
22
!test-tree/misc/
33
__pycache__
44
venv
5+
log*.txt

README.md

+52-16
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ Run `./upload-test.py test-tree/apod --archive-path "/archives/rclone QA 1 (0a0j
3434

3535
## Testing scope
3636

37-
The scope of testing here verifies the possibility of correctly uploading and downloading
38-
a finite set of file types in a particular size range to [Permanent.org](Permanent.org) using [rclone](https://rclone.org/)
37+
The scope of testing via the test cases documented below verifies the possibility of correctly uploading and downloading
38+
a defined set of file types in a particular size range to [Permanent.org](Permanent.org) using [rclone](https://rclone.org/)
3939
which talks to permanent using the [SFTP service](https://github.com/PermanentOrg/sftp-service)
4040

4141
### What file types are tested?
@@ -46,9 +46,9 @@ The scope of testing here verifies the possibility of correctly uploading and do
4646
- Videos in `.mp4`, `.webm`, `.gifs` and `.3gp` common in mobile devices.
4747
- Executable files in `.exe`, `.run`, `.sh`, `.dep` and extension-less bin executables.
4848

49-
### What test cases are covered?
49+
## Test Cases?
5050

51-
#### Challenging Names
51+
### Challenging Names
5252

5353
Run `./generate-tree.py` to generate test data, which will be placed
5454
in a new subdirectory named `test-tree/challenging-names`.
@@ -60,24 +60,24 @@ first, of course). See the long comment at the top of
6060
[upload-test.sh](upload-test.sh) for information about what it's
6161
trying to do and what problems we know about so far.
6262

63-
#### Duplicates
63+
### Duplicates
6464

6565
A duplicate is a file/folder with exactly the same name. Of course this is not possible on regular file systems but Permanent does support it.
6666
There is a deduplication algorithm from Permanent that the `sftp-service` relies to ensure that files with identical names on Permanent won't be
6767
be considered as the same on regular file systems.
6868

69-
##### How test duplicate
69+
#### How test duplicate
7070

7171
- Create a folder in the test archive of the remote (permanent.org or permanent.dev depending on your test target) e.g 'duplicates'.
7272
- Upload at least two copies of multiple identical files into the folder `duplicates` for example (`file.txt`, `file.txt`, `file.txt` and `photo.png`, `photo.png` ...)
7373
- Run the download test script against the duplicate folder. In this case:
7474

7575
```
76-
`./test-download.py --archive-path "/archives/rclone QA 1 (0a0j-0000)/My Files/" --remote-dir "duplicates"`
76+
`./test-download.py --remote=prod --archive-path "/archives/rclone QA 1 (0a0j-0000)/My Files/" --remote-dir=duplicates`
7777
```
78-
##### Expected results
78+
#### Expected results
7979

80-
- Check download folder and ensure that results looks like:
80+
- Check downloads folder in `test-tree/downloads` and ensure that results looks like:
8181

8282
*Result from `tree` program*
8383
```
@@ -89,19 +89,19 @@ There is a deduplication algorithm from Permanent that the `sftp-service` relies
8989
9090
0 directories, 5 files
9191
```
92-
##### Multiple Identical Uploads
92+
#### Multiple Identical Uploads
9393

9494
This test case captures what happens if you sync the same path with unchanged content multiples times.
9595

96-
##### How test identical uploads
96+
#### How test identical uploads
9797

9898
- Generate challenging names if not generated earlier, see [Challenging Names](#challenging-names)
9999

100-
Run `./upload-test.py test-tree/challenging-names --only=414 --remote-dir=test-414 --log-file=duplicate-upload-log.txt --remote=prod --archive-path="/archives/QA (0a21-0000)/My Files/"`
100+
Run `./upload-test.py test-tree/challenging-names --only=414 --remote-dir=test-414 --log-file=log-duplicate-upload.txt --remote=prod --archive-path="/archives/QA (0a21-0000)/My Files/"`
101101

102102
*Notice the use of the `--only` flag which specifies only files containing the number `414` should be uploaded, you can change this number to follow a string pattern in the generated challenging names but the provide example works just fine.*
103103

104-
##### Expected results
104+
#### Expected results
105105

106106
- `rclone` should report `Sizes identical` and `Unchanged skipping`
107107

@@ -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-
##### Large uploads
115-
###### Uploads
114+
#### 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

@@ -136,7 +136,43 @@ and then run `./special-files-downloader.py --my-source my_files.txt`
136136

137137
Once the files are on disk:
138138

139-
Run `./upload-test.py test-tree/special-files/large --remote-dir=large-files --log-file=large-files-log.txt --remote=prod --archive-path="/archives/QA (0a21-0000)/My Files/"`
139+
Run `./upload-test.py test-tree/special-files/large --remote-dir=large-files --log-file=log-large-files.txt --remote=prod --archive-path="/archives/QA (0a21-0000)/My Files/"`
140+
141+
#### Nested folders/files
142+
143+
##### Uploading
144+
145+
We have a default nest of folders that goes down 4 levels.
146+
147+
Run `./upload-test.py test-tree/misc/nested/ --remote-dir=nested --log-file=log-nested.txt --remote=prod --archive-path="/archives/QA (0a21-0000)/My Files/"`
148+
149+
Verify in the Permanent UI that the folder set to remote dir `--remote-dir` in this case `nested` contains the nested folder with the following structure.
150+
151+
*Result from `tree` program*
152+
153+
```
154+
test-tree/misc/nested/
155+
├── nested-level-1
156+
│   ├── nested-level-2
157+
│   │   ├── nested-level-3
158+
│   │   │   └── record-level-3.txt
159+
│   │   └── record-level-2.txt
160+
│   └── record-level-1.txt
161+
└── record-level-0.txt
162+
```
163+
164+
To test a nest with more levels, simply paste a nested folder structure inside `test-tree/misc/nested` or manually create more folder levels in the existing nest.
165+
166+
##### Downloading
167+
168+
*The steps in the upload section above must be completed before this step*
169+
170+
Run
171+
172+
`./test-download.py --remote=prod --archive-path="/archives/rclone QA 1 (0a21-0000)/My Files/" --remote-dir=nested`
173+
174+
Check downloads folder in `test-tree/downloads` and ensure `downloads/nested` that results looks like the structured previous uploaded in the nested folder upload tests above.
175+
140176

141177
### What file types and scenarios are left out?
142178

Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nested record level 3.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nested record level 2.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nested record level 0.
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Nested record level 0.

upload-test.py

+7-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
CHALLENGING_NAMES_DIR = "test-tree/challenging-names"
88
APOD_DIR = "test-tree/apod"
99
MISC_DIR = "test-tree/misc"
10+
NESTED_DIR = "test-tree/misc/nested"
1011

1112
gentree = __import__("generate-tree")
1213

@@ -49,21 +50,23 @@ def main():
4950

5051
# Try to rclone this file
5152
log(f"Trying {fname}...")
52-
out = rclone_upload(os.path.join(CHALLENGING_NAMES_DIR, fname), cli.remote_dir)
53+
rclone_upload(os.path.join(CHALLENGING_NAMES_DIR, fname), cli.remote_dir)
5354
elif os.path.abspath(cli.directory) == os.path.abspath(APOD_DIR):
54-
out = rclone_upload(APOD_DIR, cli.remote_dir, timeout=0)
55+
rclone_upload(APOD_DIR, cli.remote_dir, timeout=0)
5556
elif os.path.abspath(cli.directory) == os.path.abspath(MISC_DIR):
5657
for fname in os.listdir(MISC_DIR):
5758
if skip_p(fname, cli):
5859
continue
5960

6061
# Try to rclone this file
6162
log(f"Trying {fname}...")
62-
out = rclone_upload(os.path.join(MISC_DIR, fname), cli.remote_dir)
63+
rclone_upload(os.path.join(MISC_DIR, fname), cli.remote_dir)
6364

6465
# Upload file 2 twice
6566
if fname[0:3] == "002":
66-
out = rclone_upload(os.path.join(MISC_DIR, fname), cli.remote_dir)
67+
rclone_upload(os.path.join(MISC_DIR, fname), cli.remote_dir)
68+
elif os.path.abspath(cli.directory) == os.path.abspath(NESTED_DIR):
69+
rclone_upload(NESTED_DIR, cli.remote_dir, timeout=0)
6770
else:
6871
sys.exit("Not sure what to do with that directory.")
6972

0 commit comments

Comments
 (0)