Compare commits

..

4 Commits
v0.1.1 ... main

Author SHA1 Message Date
ba050cbc79 Implement multipart tests (#4)
All checks were successful
Test Workflow / Lint and test library (push) Successful in 1m59s
Currently, tests do not test multipart uploads (since they use very small files). Implement some large (randomly generated) files as well.

Reviewed-on: #4
2023-12-31 09:02:36 +00:00
ddcbe28eca
Revert "CI broken notice"
All checks were successful
Test Workflow / Lint and test library (push) Successful in 1m43s
This reverts commit 53e6d30e53c7484f406ea85ee1acb3ff85d62fc6.
2023-12-31 13:21:27 +06:00
53e6d30e53
CI broken notice
All checks were successful
Test Workflow / Lint and test library (push) Successful in 17m36s
2023-12-30 23:29:41 +06:00
97f9cc4b2b
Clarify testing only BackupClient in README
All checks were successful
Test Workflow / Lint and test library (push) Successful in 5m54s
2023-12-30 22:56:44 +06:00
2 changed files with 23 additions and 1 deletions

View File

@ -87,6 +87,7 @@ Arguments:
- *Alternative*: use S3 object tags to store the EOCD size, fallback to 22 bytes otherwise. This could be
interesting if we want the backup tool to be able to import existing ZIPs (which could potentially have a comment),
but that is beyond the scope of the instructions.
- Only the `BackupClient` is tested, since by testing it, all other (internal) classes are functions are tested as well.
## Instructions
Create a backup utility that copies files to AWS S3. The utility should take a local directory with files and put it into AWS S3 in the form of one blob file. The reverse behavior should also be possible. We should be able to specify what backup we want to restore and where it should put the files on the local system. The utility should be able to restore one individual file from a backup.

View File

@ -6,6 +6,7 @@ import org.junit.jupiter.api.*
import org.junit.jupiter.api.Assertions.*
import java.io.File
import kotlin.io.path.*
import kotlin.random.Random
val bucketName = System.getenv("BACKUP_BUCKET") ?: "teamcity-executors-test-task"
@ -17,7 +18,7 @@ class BackupClientTest {
fun `before each`() =
runBlocking {
s3 = S3Client.fromEnvironment {}
backupClient = BackupClient(s3, bucketName)
backupClient = BackupClient(s3, bucketName, 1024 * 1024 * 10)
}
@AfterEach
@ -49,6 +50,26 @@ class BackupClientTest {
Path("_test/README.md").apply { writeText("# This is a test directory structure.") },
)
},
"single large file" to {
val bytes = ByteArray(1024 * 1024 * 32)
Random.nextBytes(bytes)
listOf(
Path("_test.txt").apply { writeBytes(bytes) },
)
},
"large directory structure" to {
val bytes1 = ByteArray(1024 * 1024 * 32)
val bytes2 = ByteArray(1024 * 1024 * 48)
listOf(
Path("_test").createDirectory(),
Path("_test/a.txt").apply { writeBytes(bytes1) },
Path("_test/folder").createDirectory(),
Path("_test/another-folder").createDirectory(),
Path("_test/another-folder/b").apply { writeText("This is file B\n") },
Path("_test/another-folder/c.txt").createFile(),
Path("_test/README.md").apply { writeBytes(bytes2) },
)
},
).map { (name, pathsGen) ->
DynamicTest.dynamicTest(name) {
val paths = pathsGen()