When appending to a compressed archive (gzip, brotli, zstd), the tool now handles compression automatically. Since some compression formats don't support appending to compressed files in place, we write a new compressed file with all the data and atomically rename it to replace the original (assuming there is enough space on that filesystem). This means you can work with compressed archives the same way as uncompressed ones. Point the tool at your .json.gz file and append values. No manual decompression/recompression needed.
2.1 KiB
2.1 KiB
Compression Integration Tests
Manual integration tests for compressed archive functionality.
These scripts exercise the tool's ability to:
- Read archives that were compressed by external programs (gzip, brotli, zstd)
- Append new observations to compressed archives
- Produce correct results whether reading compressed or uncompressed
Scripts
generate_state.py <n>
Generates a JSON state file with n items in each array. Output goes to stdout.
./generate_state.py 3
# Output: {"colors":["color_1","color_2","color_3"],"numbers":["number_1","number_2","number_3"],"animals":["animal_1","animal_2","animal_3"]}
generate_state_files.py <count> <output_dir>
Generates a series of state files (state_1.json through state_N.json) with progressively more items.
./generate_state_files.py 9 ./data
# Creates: data/state_1.json, data/state_2.json, ... data/state_9.json
run_gzip_test.sh
Tests the gzip compression workflow:
- Create archive from first state file
- Compress with gzip
- Append remaining 8 state files to the compressed archive
- Decompress and inspect
run_brotli_test.sh
Same workflow but with brotli compression.
run_zstd_test.sh
Same workflow but with zstd compression.
run_all.sh
Runs all compression tests in sequence.
validate.sh (optional)
Smoke test to verify the final state matches expectations.
Usage
cd tests/compression-integration
# Run all tests (generates data, builds, runs all compression formats)
./run_all.sh
# Or run individual steps:
./generate_state_files.py 9 ./data
./run_gzip_test.sh
./run_brotli_test.sh
./run_zstd_test.sh
# Optional: validate outputs match
./validate.sh
What to look for
After running the tests, you can manually verify:
- The compressed archives were created
- Appending to compressed archives worked (check file sizes grew)
- The
infocommand shows the same observation count for compressed and decompressed versions - The
statecommand returns the same final state
Dependencies
- gzip (usually pre-installed)
- brotli (
brew install brotli) - zstd (
brew install zstd)