|
1 | 1 | load helpers.bash |
2 | 2 |
|
3 | 3 | @test "Either -migrate or -rmi is specified" { |
4 | | - run \ |
5 | | - "$PARALLAX_BINARY" |
6 | | - [ "$status" -ne 0 ] |
7 | | - [[ "$output" =~ "Must specify either -migrate or -rmi" ]] |
| 4 | + run \ |
| 5 | + "$PARALLAX_BINARY" |
| 6 | + [ "$status" -ne 0 ] |
| 7 | + [[ "$output" =~ "Must specify either -migrate or -rmi" ]] |
8 | 8 | } |
9 | 9 |
|
10 | 10 | @test "Fails if both -migrate and -rmi are passed" { |
11 | | - run \ |
12 | | - "$PARALLAX_BINARY" -migrate -rmi -image ubuntu:latest |
13 | | - [ "$status" -ne 0 ] |
14 | | - [[ "$output" =~ "Must specify either -migrate or -rmi" ]] |
| 11 | + run \ |
| 12 | + "$PARALLAX_BINARY" -migrate -rmi -image ubuntu:latest |
| 13 | + [ "$status" -ne 0 ] |
| 14 | + [[ "$output" =~ "Must specify either -migrate or -rmi" ]] |
15 | 15 | } |
16 | 16 |
|
17 | 17 | @test "Fails if --image is missing" { |
18 | | - run \ |
19 | | - "$PARALLAX_BINARY" -migrate |
20 | | - [ "$status" -ne 0 ] |
21 | | - [[ "$output" =~ "Must specify -image" ]] |
| 18 | + run \ |
| 19 | + "$PARALLAX_BINARY" -migrate |
| 20 | + [ "$status" -ne 0 ] |
| 21 | + [[ "$output" =~ "Must specify -image" ]] |
22 | 22 | } |
23 | 23 |
|
24 | 24 | @test "Checks version" { |
25 | | - run \ |
26 | | - "$PARALLAX_BINARY" -version |
27 | | - [ "$status" -eq 0 ] |
28 | | - [[ "$output" =~ "Parallax version" ]] |
| 25 | + run \ |
| 26 | + "$PARALLAX_BINARY" -version |
| 27 | + [ "$status" -eq 0 ] |
| 28 | + [[ "$output" =~ "Parallax version" ]] |
29 | 29 | } |
30 | 30 |
|
31 | 31 | @test "Usage is printed" { |
32 | | - run \ |
33 | | - "$PARALLAX_BINARY" -help |
34 | | - [ "$status" -eq 0 ] |
35 | | - [[ "$output" =~ "OCI image migration tool" ]] |
36 | | - [[ "$output" =~ "Usage" ]] |
37 | | - [[ "$output" =~ "-migrate" ]] |
38 | | - [[ "$output" =~ "-image" ]] |
| 32 | + run \ |
| 33 | + "$PARALLAX_BINARY" -help |
| 34 | + [ "$status" -eq 0 ] |
| 35 | + [[ "$output" =~ "OCI image migration tool" ]] |
| 36 | + [[ "$output" =~ "Usage" ]] |
| 37 | + [[ "$output" =~ "-migrate" ]] |
| 38 | + [[ "$output" =~ "-image" ]] |
39 | 39 | } |
40 | 40 |
|
41 | 41 | @test "Checks unknown flag message" { |
42 | | - run \ |
43 | | - "$PARALLAX_BINARY" -unknownflag |
44 | | - [ "$status" -ne 0 ] |
45 | | - [[ "$output" =~ "flag provided but not defined" ]] |
| 42 | + run \ |
| 43 | + "$PARALLAX_BINARY" -unknownflag |
| 44 | + [ "$status" -ne 0 ] |
| 45 | + [[ "$output" =~ "flag provided but not defined" ]] |
| 46 | +} |
| 47 | + |
| 48 | +@test "Fails migration when --roStoragePath directory is non-empty" { |
| 49 | + # Populate the storage dir with a dummy file |
| 50 | + # This way the directory is neither empty or with a store structure |
| 51 | + touch "$RO_STORAGE/dummy-file" |
| 52 | + |
| 53 | + run "$PARALLAX_BINARY" \ |
| 54 | + --podmanRoot "$PODMAN_ROOT" \ |
| 55 | + --roStoragePath "$RO_STORAGE" \ |
| 56 | + --mksquashfsPath "$MKSQUASHFS_PATH" \ |
| 57 | + --log-level info \ |
| 58 | + --migrate \ |
| 59 | + --image ubuntu:latest |
| 60 | + |
| 61 | + # Expect a non-zero exit code and a validation error |
| 62 | + [ "$status" -ne 0 ] |
| 63 | + [[ "$output" =~ "Storage validation failed" ]] |
| 64 | +} |
| 65 | + |
| 66 | +@test "Advanced --roStoragePath directory is initialized" { |
| 67 | + # Populate the storage dir with a dummy file |
| 68 | + # This way the directory is neither empty or with a store structure |
| 69 | + touch "$RO_STORAGE/dummy-file" |
| 70 | + |
| 71 | + run "$PARALLAX_BINARY" \ |
| 72 | + --podmanRoot "$PODMAN_ROOT" \ |
| 73 | + --roStoragePath "$RO_STORAGE" \ |
| 74 | + --mksquashfsPath "$MKSQUASHFS_PATH" \ |
| 75 | + --log-level info \ |
| 76 | + --migrate \ |
| 77 | + --image alpine:latest |
| 78 | + |
| 79 | + # Expect a non-zero exit code and a validation error |
| 80 | + [ "$status" -ne 0 ] |
| 81 | + [[ "$output" =~ "Storage validation failed" ]] |
| 82 | + |
| 83 | + # Bootstrap RO_STORAGE with a pulled image, this satisfies the dir structure validation |
| 84 | + run "$PODMAN_BINARY" \ |
| 85 | + --root "$RO_STORAGE" \ |
| 86 | + --runroot "$PODMAN_RUNROOT" \ |
| 87 | + pull alpine:latest |
| 88 | + [ "$status" -eq 0 ] |
| 89 | + |
| 90 | + run "$PODMAN_BINARY" \ |
| 91 | + --root "$PODMAN_ROOT" \ |
| 92 | + --runroot "$PODMAN_RUNROOT" \ |
| 93 | + pull ubuntu:latest |
| 94 | + [ "$status" -eq 0 ] |
| 95 | + |
| 96 | + # Now migration should pass check, and also complete a ubuntu migration |
| 97 | + run "$PARALLAX_BINARY" \ |
| 98 | + --podmanRoot "$PODMAN_ROOT" \ |
| 99 | + --roStoragePath "$RO_STORAGE" \ |
| 100 | + --mksquashfsPath "$MKSQUASHFS_PATH" \ |
| 101 | + --log-level info \ |
| 102 | + --migrate \ |
| 103 | + --image ubuntu:latest |
| 104 | + |
| 105 | + [ "$status" -eq 0 ] |
| 106 | + [[ "$output" =~ "Migration successfully completed" ]] |
| 107 | +} |
| 108 | + |
| 109 | +@test "Fails RMI when --roStoragePath directory is non-empty" { |
| 110 | + # Populate the storage dir with a dummy file |
| 111 | + # This way the directory is neither empty or with a store structure |
| 112 | + touch "$RO_STORAGE/dummy-file" |
| 113 | + |
| 114 | + run "$PARALLAX_BINARY" \ |
| 115 | + --podmanRoot "$PODMAN_ROOT" \ |
| 116 | + --roStoragePath "$RO_STORAGE" \ |
| 117 | + --mksquashfsPath "$MKSQUASHFS_PATH" \ |
| 118 | + --log-level info \ |
| 119 | + --rmi \ |
| 120 | + --image ubuntu:latest |
| 121 | + |
| 122 | + # Expect a non-zero exit code and a validation error |
| 123 | + [ "$status" -ne 0 ] |
| 124 | + [[ "$output" =~ "Storage validation failed" ]] |
46 | 125 | } |
47 | 126 |
|
0 commit comments