|
9 | 9 | pkgs = config.nodes.client.nixpkgs.pkgs;
|
10 | 10 |
|
11 | 11 | pkgA = pkgs.cowsay;
|
| 12 | + pkgB = pkgs.busybox; |
| 13 | + pkgC = pkgs.hello; |
12 | 14 |
|
13 | 15 | accessKey = "BKIKJAA5BMMU2RHO6IBB";
|
14 | 16 | secretKey = "V7f1CwQqAcwo80UEIJEjc5gVQUSSx5ohQ9GSrr12";
|
|
32 | 34 | }:
|
33 | 35 | {
|
34 | 36 | virtualisation.writableStore = true;
|
35 |
| - virtualisation.additionalPaths = [ pkgA ]; |
| 37 | + virtualisation.additionalPaths = [ |
| 38 | + pkgA |
| 39 | + pkgB |
| 40 | + pkgC |
| 41 | + ]; |
36 | 42 | environment.systemPackages = [ pkgs.minio-client ];
|
37 | 43 | nix.extraOptions = ''
|
38 | 44 | experimental-features = nix-command
|
|
227 | 233 | print("Debug output:")
|
228 | 234 | print(concurrent_output)
|
229 | 235 | raise Exception(f"FAILED: Expected at least 5 FileTransfer instances for 5 concurrent fetches, but got {concurrent_transfers}")
|
| 236 | +
|
| 237 | + # Test S3-specific compression functionality |
| 238 | + print("Testing S3 compression features") |
| 239 | +
|
| 240 | + # Create a separate bucket for compression tests |
| 241 | + server.succeed("mc mb minio/compressed-cache") |
| 242 | + compressed_store_url = "s3://compressed-cache?endpoint=http://server:9000®ion=eu-west-1" |
| 243 | +
|
| 244 | + # Test 1: Upload with narinfo compression (gzip) |
| 245 | + print("TEST: S3 narinfo compression (gzip)") |
| 246 | + server.succeed(f"${env} nix copy --to '{compressed_store_url}&narinfo-compression=gzip' ${pkgB}") |
| 247 | +
|
| 248 | + # Verify the .narinfo file has Content-Encoding header |
| 249 | + pkgB_hash = "${pkgB}".split("/")[-1].split("-")[0] |
| 250 | + narinfo_path = pkgB_hash + ".narinfo" |
| 251 | + stat_output = server.succeed("mc stat minio/compressed-cache/" + narinfo_path) |
| 252 | + if "Content-Encoding" not in stat_output or "gzip" not in stat_output: |
| 253 | + print("mc stat output:") |
| 254 | + print(stat_output) |
| 255 | + raise Exception("Expected Content-Encoding: gzip header on .narinfo file") |
| 256 | + print("PASS: .narinfo has Content-Encoding: gzip") |
| 257 | +
|
| 258 | + # Verify client can download and decompress |
| 259 | + client.succeed(f"${env} nix copy --from '{compressed_store_url}' --no-check-sigs ${pkgB}") |
| 260 | + client.succeed("nix path-info ${pkgB}") |
| 261 | + print("PASS: Client downloaded and decompressed .narinfo successfully") |
| 262 | +
|
| 263 | + # Test 2: Upload with multiple compression methods |
| 264 | + print("TEST: S3 mixed compression (narinfo=xz, ls=gzip)") |
| 265 | + server.succeed( |
| 266 | + f"${env} nix copy --to '{compressed_store_url}&narinfo-compression=xz&write-nar-listing=true&ls-compression=gzip' ${pkgC}" |
| 267 | + ) |
| 268 | +
|
| 269 | + # Verify .narinfo has xz Content-Encoding |
| 270 | + pkgC_hash = "${pkgC}".split("/")[-1].split("-")[0] |
| 271 | + narinfo_stat = server.succeed("mc stat minio/compressed-cache/" + pkgC_hash + ".narinfo") |
| 272 | + if "Content-Encoding" not in narinfo_stat or "xz" not in narinfo_stat: |
| 273 | + print("mc stat output:") |
| 274 | + print(narinfo_stat) |
| 275 | + raise Exception("Expected Content-Encoding: xz header on .narinfo file") |
| 276 | + print("PASS: .narinfo has Content-Encoding: xz") |
| 277 | +
|
| 278 | + # Verify .ls file has gzip Content-Encoding |
| 279 | + ls_stat = server.succeed("mc stat minio/compressed-cache/" + pkgC_hash + ".ls") |
| 280 | + if "Content-Encoding" not in ls_stat or "gzip" not in ls_stat: |
| 281 | + print("mc stat output:") |
| 282 | + print(ls_stat) |
| 283 | + raise Exception("Expected Content-Encoding: gzip header on .ls file") |
| 284 | + print("PASS: .ls has Content-Encoding: gzip") |
| 285 | +
|
| 286 | + # Verify client can download with mixed compression |
| 287 | + client.succeed(f"${env} nix copy --from '{compressed_store_url}' --no-check-sigs ${pkgC}") |
| 288 | + client.succeed("nix path-info ${pkgC}") |
| 289 | + print("PASS: Client downloaded package with mixed compression") |
| 290 | +
|
| 291 | + # Test 3: No compression by default (reuse pkgA which is already in additionalPaths) |
| 292 | + print("TEST: S3 no compression by default") |
| 293 | + server.succeed("mc mb minio/uncompressed-cache") |
| 294 | + uncompressed_url = "s3://uncompressed-cache?endpoint=http://server:9000®ion=eu-west-1" |
| 295 | + server.succeed(f"${env} nix copy --to '{uncompressed_url}' ${pkgA}") |
| 296 | +
|
| 297 | + # Verify .narinfo does NOT have Content-Encoding header |
| 298 | + pkgA_hash = "${pkgA}".split("/")[-1].split("-")[0] |
| 299 | + narinfo_uncompressed = server.succeed("mc stat minio/uncompressed-cache/" + pkgA_hash + ".narinfo") |
| 300 | + if "Content-Encoding" in narinfo_uncompressed and ("gzip" in narinfo_uncompressed or "xz" in narinfo_uncompressed): |
| 301 | + print("mc stat output:") |
| 302 | + print(narinfo_uncompressed) |
| 303 | + raise Exception(".narinfo should not have compression Content-Encoding by default") |
| 304 | + print("PASS: No compression applied by default") |
| 305 | +
|
| 306 | + print("All S3 compression tests passed!") |
230 | 307 | '';
|
231 | 308 | }
|
0 commit comments