|
| 1 | +#!/bin/sh |
| 2 | + |
| 3 | +test_description='gvfs-helper basic tests' |
| 4 | + |
| 5 | +. ./test-lib.sh |
| 6 | + |
| 7 | +. "$TEST_DIRECTORY"/lib-gvfs-helper.sh |
| 8 | + |
| 9 | +################################################################# |
| 10 | +# Basic tests to confirm the happy path works. |
| 11 | +################################################################# |
| 12 | + |
| 13 | +test_expect_success 'basic: GET origin multi-get no-auth' ' |
| 14 | + test_when_finished "per_test_cleanup" && |
| 15 | + start_gvfs_protocol_server && |
| 16 | +
|
| 17 | + # Connect to the origin server (w/o auth) and make a series of |
| 18 | + # single-object GET requests. |
| 19 | + # |
| 20 | + git -C "$REPO_T1" gvfs-helper \ |
| 21 | + --cache-server=disable \ |
| 22 | + --remote=origin \ |
| 23 | + get \ |
| 24 | + <"$OIDS_FILE" >OUT.output && |
| 25 | +
|
| 26 | + # Stop the server to prevent the verification steps from faulting-in |
| 27 | + # any missing objects. |
| 28 | + # |
| 29 | + stop_gvfs_protocol_server && |
| 30 | +
|
| 31 | + # gvfs-helper prints a "loose <oid>" message for each received object. |
| 32 | + # Verify that gvfs-helper received each of the requested objects. |
| 33 | + # |
| 34 | + sed "s/loose //" <OUT.output | sort >OUT.actual && |
| 35 | + test_cmp "$OIDS_FILE" OUT.actual && |
| 36 | +
|
| 37 | + verify_objects_in_shared_cache "$OIDS_FILE" && |
| 38 | + verify_connection_count 1 |
| 39 | +' |
| 40 | + |
| 41 | +test_expect_success 'basic: GET cache-server multi-get trust-mode' ' |
| 42 | + test_when_finished "per_test_cleanup" && |
| 43 | + start_gvfs_protocol_server && |
| 44 | +
|
| 45 | + # Connect to the cache-server and make a series of |
| 46 | + # single-object GET requests. |
| 47 | + # |
| 48 | + git -C "$REPO_T1" gvfs-helper \ |
| 49 | + --cache-server=trust \ |
| 50 | + --remote=origin \ |
| 51 | + get \ |
| 52 | + <"$OIDS_FILE" >OUT.output && |
| 53 | +
|
| 54 | + # Stop the server to prevent the verification steps from faulting-in |
| 55 | + # any missing objects. |
| 56 | + # |
| 57 | + stop_gvfs_protocol_server && |
| 58 | +
|
| 59 | + # gvfs-helper prints a "loose <oid>" message for each received object. |
| 60 | + # Verify that gvfs-helper received each of the requested objects. |
| 61 | + # |
| 62 | + sed "s/loose //" <OUT.output | sort >OUT.actual && |
| 63 | + test_cmp "$OIDS_FILE" OUT.actual && |
| 64 | +
|
| 65 | + verify_objects_in_shared_cache "$OIDS_FILE" && |
| 66 | + verify_connection_count 1 |
| 67 | +' |
| 68 | + |
| 69 | +test_expect_success 'basic: GET gvfs/config' ' |
| 70 | +# test_when_finished "per_test_cleanup" && |
| 71 | + start_gvfs_protocol_server && |
| 72 | +
|
| 73 | + # Connect to the cache-server and make a series of |
| 74 | + # single-object GET requests. |
| 75 | + # |
| 76 | + git -C "$REPO_T1" gvfs-helper \ |
| 77 | + --cache-server=disable \ |
| 78 | + --remote=origin \ |
| 79 | + config \ |
| 80 | + <"$OIDS_FILE" >OUT.output && |
| 81 | +
|
| 82 | + # Stop the server to prevent the verification steps from faulting-in |
| 83 | + # any missing objects. |
| 84 | + # |
| 85 | + stop_gvfs_protocol_server && |
| 86 | +
|
| 87 | + # The cache-server URL should be listed in the gvfs/config output. |
| 88 | + # We confirm this before assuming error-mode will work. |
| 89 | + # |
| 90 | + test_grep "$CACHE_URL" OUT.output |
| 91 | +' |
| 92 | + |
| 93 | +test_expect_success 'basic: GET cache-server multi-get error-mode' ' |
| 94 | + test_when_finished "per_test_cleanup" && |
| 95 | + start_gvfs_protocol_server && |
| 96 | +
|
| 97 | + # Connect to the cache-server and make a series of |
| 98 | + # single-object GET requests. |
| 99 | + # |
| 100 | + git -C "$REPO_T1" gvfs-helper \ |
| 101 | + --cache-server=error \ |
| 102 | + --remote=origin \ |
| 103 | + get \ |
| 104 | + <"$OIDS_FILE" >OUT.output && |
| 105 | +
|
| 106 | + # Stop the server to prevent the verification steps from faulting-in |
| 107 | + # any missing objects. |
| 108 | + # |
| 109 | + stop_gvfs_protocol_server && |
| 110 | +
|
| 111 | + # gvfs-helper prints a "loose <oid>" message for each received object. |
| 112 | + # Verify that gvfs-helper received each of the requested objects. |
| 113 | + # |
| 114 | + sed "s/loose //" <OUT.output | sort >OUT.actual && |
| 115 | + test_cmp "$OIDS_FILE" OUT.actual && |
| 116 | +
|
| 117 | + verify_objects_in_shared_cache "$OIDS_FILE" && |
| 118 | +
|
| 119 | + # Technically, we have 1 connection to the origin server |
| 120 | + # for the "gvfs/config" request and 1 to cache server to |
| 121 | + # get the objects, but because we are using the same port |
| 122 | + # for both, keep-alive will handle it. So 1 connection. |
| 123 | + # |
| 124 | + verify_connection_count 1 |
| 125 | +' |
| 126 | + |
| 127 | +# The GVFS Protocol POST verb behaves like GET for non-commit objects |
| 128 | +# (in that it just returns the requested object), but for commit |
| 129 | +# objects POST *also* returns all trees referenced by the commit. |
| 130 | +# |
| 131 | +# The goal of this test is to confirm that gvfs-helper can send us |
| 132 | +# a packfile at all. So, this test only passes blobs to not blur |
| 133 | +# the issue. |
| 134 | +# |
| 135 | +test_expect_success 'basic: POST origin blobs' ' |
| 136 | + test_when_finished "per_test_cleanup" && |
| 137 | + start_gvfs_protocol_server && |
| 138 | +
|
| 139 | + # Connect to the origin server (w/o auth) and make |
| 140 | + # multi-object POST request. |
| 141 | + # |
| 142 | + git -C "$REPO_T1" gvfs-helper \ |
| 143 | + --cache-server=disable \ |
| 144 | + --remote=origin \ |
| 145 | + --no-progress \ |
| 146 | + post \ |
| 147 | + <"$OIDS_BLOBS_FILE" >OUT.output && |
| 148 | +
|
| 149 | + # Stop the server to prevent the verification steps from faulting-in |
| 150 | + # any missing objects. |
| 151 | + # |
| 152 | + stop_gvfs_protocol_server && |
| 153 | +
|
| 154 | + # gvfs-helper prints a "packfile <path>" message for each received |
| 155 | + # packfile. We verify the number of expected packfile(s) and we |
| 156 | + # individually verify that each requested object is present in the |
| 157 | + # shared cache (and index-pack already verified the integrity of |
| 158 | + # the packfile), so we do not bother to run "git verify-pack -v" |
| 159 | + # and do an exact matchup here. |
| 160 | + # |
| 161 | + verify_received_packfile_count 1 && |
| 162 | +
|
| 163 | + verify_objects_in_shared_cache "$OIDS_BLOBS_FILE" && |
| 164 | + verify_connection_count 1 |
| 165 | +' |
| 166 | + |
| 167 | +# Request a single blob via POST. Per the GVFS Protocol, the server |
| 168 | +# should implicitly send a loose object for it. Confirm that. |
| 169 | +# |
| 170 | +test_expect_success 'basic: POST-request a single blob' ' |
| 171 | + test_when_finished "per_test_cleanup" && |
| 172 | + start_gvfs_protocol_server && |
| 173 | +
|
| 174 | + # Connect to the origin server (w/o auth) and request a single |
| 175 | + # blob via POST. |
| 176 | + # |
| 177 | + git -C "$REPO_T1" gvfs-helper \ |
| 178 | + --cache-server=disable \ |
| 179 | + --remote=origin \ |
| 180 | + --no-progress \ |
| 181 | + post \ |
| 182 | + <"$OID_ONE_BLOB_FILE" >OUT.output && |
| 183 | +
|
| 184 | + # Stop the server to prevent the verification steps from faulting-in |
| 185 | + # any missing objects. |
| 186 | + # |
| 187 | + stop_gvfs_protocol_server && |
| 188 | +
|
| 189 | + # gvfs-helper prints a "loose <oid>" message for each received |
| 190 | + # loose object. |
| 191 | + # |
| 192 | + sed "s/loose //" <OUT.output | sort >OUT.actual && |
| 193 | + test_cmp "$OID_ONE_BLOB_FILE" OUT.actual && |
| 194 | +
|
| 195 | + verify_connection_count 1 |
| 196 | +' |
| 197 | + |
| 198 | +# Request a single commit via POST. Per the GVFS Protocol, the server |
| 199 | +# should implicitly send us a packfile containing the commit and the |
| 200 | +# trees it references. Confirm that properly handled the receipt of |
| 201 | +# the packfile. (Here, we are testing that asking for a single commit |
| 202 | +# via POST yields a packfile rather than a loose object.) |
| 203 | +# |
| 204 | +# We DO NOT verify that the packfile contains commits/trees and no blobs |
| 205 | +# because our test helper doesn't implement the filtering. |
| 206 | +# |
| 207 | +test_expect_success 'basic: POST-request a single commit' ' |
| 208 | + test_when_finished "per_test_cleanup" && |
| 209 | + start_gvfs_protocol_server && |
| 210 | +
|
| 211 | + # Connect to the origin server (w/o auth) and request a single |
| 212 | + # commit via POST. |
| 213 | + # |
| 214 | + git -C "$REPO_T1" gvfs-helper \ |
| 215 | + --cache-server=disable \ |
| 216 | + --remote=origin \ |
| 217 | + --no-progress \ |
| 218 | + post \ |
| 219 | + <"$OID_ONE_COMMIT_FILE" >OUT.output && |
| 220 | +
|
| 221 | + # Stop the server to prevent the verification steps from faulting-in |
| 222 | + # any missing objects. |
| 223 | + # |
| 224 | + stop_gvfs_protocol_server && |
| 225 | +
|
| 226 | + # gvfs-helper prints a "packfile <path>" message for each received |
| 227 | + # packfile. |
| 228 | + # |
| 229 | + verify_received_packfile_count 1 && |
| 230 | +
|
| 231 | + verify_connection_count 1 |
| 232 | +' |
| 233 | + |
| 234 | +test_expect_success 'basic: PREFETCH w/o arg gets all' ' |
| 235 | + test_when_finished "per_test_cleanup" && |
| 236 | + start_gvfs_protocol_server && |
| 237 | +
|
| 238 | + # Without a "since" argument gives us all "ct-*.pack" since the EPOCH |
| 239 | + # because we do not have any prefetch packs locally. |
| 240 | + # |
| 241 | + git -C "$REPO_T1" gvfs-helper \ |
| 242 | + --cache-server=disable \ |
| 243 | + --remote=origin \ |
| 244 | + --no-progress \ |
| 245 | + prefetch >OUT.output && |
| 246 | +
|
| 247 | + # gvfs-helper prints a "packfile <path>" message for each received |
| 248 | + # packfile. |
| 249 | + # |
| 250 | + verify_received_packfile_count 3 && |
| 251 | + verify_prefetch_keeps 1200000000 && |
| 252 | +
|
| 253 | + stop_gvfs_protocol_server && |
| 254 | + verify_connection_count 1 |
| 255 | +' |
| 256 | + |
| 257 | +test_expect_success 'basic: PREFETCH w/ arg' ' |
| 258 | + test_when_finished "per_test_cleanup" && |
| 259 | + start_gvfs_protocol_server && |
| 260 | +
|
| 261 | + # Ask for cached packfiles NEWER THAN the given time. |
| 262 | + # |
| 263 | + git -C "$REPO_T1" gvfs-helper \ |
| 264 | + --cache-server=disable \ |
| 265 | + --remote=origin \ |
| 266 | + --no-progress \ |
| 267 | + prefetch --since="1000000000" >OUT.output && |
| 268 | +
|
| 269 | + # gvfs-helper prints a "packfile <path>" message for each received |
| 270 | + # packfile. |
| 271 | + # |
| 272 | + verify_received_packfile_count 2 && |
| 273 | + verify_prefetch_keeps 1200000000 && |
| 274 | +
|
| 275 | + stop_gvfs_protocol_server && |
| 276 | + verify_connection_count 1 |
| 277 | +' |
| 278 | + |
| 279 | +test_expect_success 'basic: PREFETCH mayhem no_prefetch_idx' ' |
| 280 | + test_when_finished "per_test_cleanup" && |
| 281 | + start_gvfs_protocol_server_with_mayhem no_prefetch_idx && |
| 282 | +
|
| 283 | + # Request prefetch packs, but tell server to not send any |
| 284 | + # idx files and force gvfs-helper to compute them. |
| 285 | + # |
| 286 | + git -C "$REPO_T1" gvfs-helper \ |
| 287 | + --cache-server=disable \ |
| 288 | + --remote=origin \ |
| 289 | + --no-progress \ |
| 290 | + prefetch --since="1000000000" >OUT.output && |
| 291 | +
|
| 292 | + # gvfs-helper prints a "packfile <path>" message for each received |
| 293 | + # packfile. |
| 294 | + # |
| 295 | + verify_received_packfile_count 2 && |
| 296 | + verify_prefetch_keeps 1200000000 && |
| 297 | +
|
| 298 | + stop_gvfs_protocol_server && |
| 299 | + verify_connection_count 1 |
| 300 | +' |
| 301 | + |
| 302 | +test_expect_success 'basic: PREFETCH up-to-date' ' |
| 303 | + test_when_finished "per_test_cleanup" && |
| 304 | + start_gvfs_protocol_server && |
| 305 | +
|
| 306 | + # Ask for cached packfiles NEWER THAN the given time. |
| 307 | + # |
| 308 | + git -C "$REPO_T1" gvfs-helper \ |
| 309 | + --cache-server=disable \ |
| 310 | + --remote=origin \ |
| 311 | + --no-progress \ |
| 312 | + prefetch --since="1000000000" >OUT.output && |
| 313 | +
|
| 314 | + # gvfs-helper prints a "packfile <path>" message for each received |
| 315 | + # packfile. |
| 316 | + # |
| 317 | + verify_received_packfile_count 2 && |
| 318 | + verify_prefetch_keeps 1200000000 && |
| 319 | +
|
| 320 | + # Ask again for any packfiles newer than what we have cached locally. |
| 321 | + # |
| 322 | + git -C "$REPO_T1" gvfs-helper \ |
| 323 | + --cache-server=disable \ |
| 324 | + --remote=origin \ |
| 325 | + --no-progress \ |
| 326 | + prefetch >OUT.output && |
| 327 | +
|
| 328 | + # gvfs-helper prints a "packfile <path>" message for each received |
| 329 | + # packfile. |
| 330 | + # |
| 331 | + verify_received_packfile_count 0 && |
| 332 | + verify_prefetch_keeps 1200000000 && |
| 333 | +
|
| 334 | + stop_gvfs_protocol_server && |
| 335 | + verify_connection_count 2 |
| 336 | +' |
| 337 | + |
| 338 | +test_done |
0 commit comments