Changeset: 990ba92d9e29 for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=990ba92d9e29 Added Files: sql/test/Tests/hot-snapshot-bz2.py sql/test/Tests/hot-snapshot-bz2.stable.err sql/test/Tests/hot-snapshot-bz2.stable.out sql/test/Tests/hot-snapshot-gz.py sql/test/Tests/hot-snapshot-gz.stable.err sql/test/Tests/hot-snapshot-gz.stable.out sql/test/Tests/hot-snapshot-lz4.py sql/test/Tests/hot-snapshot-lz4.stable.err sql/test/Tests/hot-snapshot-lz4.stable.out sql/test/Tests/hot-snapshot-xz.py sql/test/Tests/hot-snapshot-xz.stable.err sql/test/Tests/hot-snapshot-xz.stable.out sql/test/Tests/hot_snapshot_compression.py Modified Files: sql/test/Tests/All Branch: Jun2020 Log Message:
Verify that compressed snapshots are actually compressed diffs (257 lines): diff --git a/sql/test/Tests/All b/sql/test/Tests/All --- a/sql/test/Tests/All +++ b/sql/test/Tests/All @@ -123,3 +123,8 @@ unicode window_functions HAVE_PYMONETDB?hot-snapshot +HAVE_PYMONETDB&HAVE_LIBZ?hot-snapshot-gz +HAVE_PYMONETDB&HAVE_LIBBZ2?hot-snapshot-bz2 +HAVE_PYMONETDB&HAVE_LIBLZMA?hot-snapshot-xz +HAVE_PYMONETDB&HAVE_LIBLZ4?hot-snapshot-lz4 + diff --git a/sql/test/Tests/hot-snapshot-bz2.py b/sql/test/Tests/hot-snapshot-bz2.py new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-bz2.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +# Test if the snapshot data is actually compressed. + +from hot_snapshot_compression import check_compression + +import sys + +complaint = check_compression('bz2', b'BZh') +if complaint: + print(complaint) + sys.exit(1) diff --git a/sql/test/Tests/hot-snapshot-bz2.stable.err b/sql/test/Tests/hot-snapshot-bz2.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-bz2.stable.err @@ -0,0 +1,12 @@ +stderr of test 'hot-snapshot-bz2` in directory 'sql/test` itself: + + +# 11:10:18 > +# 11:10:18 > "/usr/bin/python3" "hot-snapshot-bz2.py" "hot-snapshot-bz2" +# 11:10:18 > + + +# 11:10:18 > +# 11:10:18 > "Done." +# 11:10:18 > + diff --git a/sql/test/Tests/hot-snapshot-bz2.stable.out b/sql/test/Tests/hot-snapshot-bz2.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-bz2.stable.out @@ -0,0 +1,12 @@ +stdout of test 'hot-snapshot-bz2` in directory 'sql/test` itself: + + +# 11:10:18 > +# 11:10:18 > "/usr/bin/python3" "hot-snapshot-bz2.py" "hot-snapshot-bz2" +# 11:10:18 > + + +# 11:10:18 > +# 11:10:18 > "Done." +# 11:10:18 > + diff --git a/sql/test/Tests/hot-snapshot-gz.py b/sql/test/Tests/hot-snapshot-gz.py new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-gz.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +# Test if the snapshot data is actually compressed. + +from hot_snapshot_compression import check_compression + +import sys + +complaint = check_compression('gz', b'\x1F\x8B') +if complaint: + print(complaint) + sys.exit(1) diff --git a/sql/test/Tests/hot-snapshot-gz.stable.err b/sql/test/Tests/hot-snapshot-gz.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-gz.stable.err @@ -0,0 +1,12 @@ +stderr of test 'hot-snapshot-gz` in directory 'sql/test` itself: + + +# 11:10:15 > +# 11:10:15 > "/usr/bin/python3" "hot-snapshot-gz.py" "hot-snapshot-gz" +# 11:10:15 > + + +# 11:10:15 > +# 11:10:15 > "Done." +# 11:10:15 > + diff --git a/sql/test/Tests/hot-snapshot-gz.stable.out b/sql/test/Tests/hot-snapshot-gz.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-gz.stable.out @@ -0,0 +1,12 @@ +stdout of test 'hot-snapshot-gz` in directory 'sql/test` itself: + + +# 11:10:15 > +# 11:10:15 > "/usr/bin/python3" "hot-snapshot-gz.py" "hot-snapshot-gz" +# 11:10:15 > + + +# 11:10:15 > +# 11:10:15 > "Done." +# 11:10:15 > + diff --git a/sql/test/Tests/hot-snapshot-lz4.py b/sql/test/Tests/hot-snapshot-lz4.py new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-lz4.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +# Test if the snapshot data is actually compressed. + +from hot_snapshot_compression import check_compression + +import sys + +complaint = check_compression('lz4', b'\x04\x22\x4D\x18') +if complaint: + print(complaint) + sys.exit(1) diff --git a/sql/test/Tests/hot-snapshot-lz4.stable.err b/sql/test/Tests/hot-snapshot-lz4.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-lz4.stable.err @@ -0,0 +1,12 @@ +stderr of test 'hot-snapshot-lz4` in directory 'sql/test` itself: + + +# 11:10:24 > +# 11:10:24 > "/usr/bin/python3" "hot-snapshot-lz4.py" "hot-snapshot-lz4" +# 11:10:24 > + + +# 11:10:24 > +# 11:10:24 > "Done." +# 11:10:24 > + diff --git a/sql/test/Tests/hot-snapshot-lz4.stable.out b/sql/test/Tests/hot-snapshot-lz4.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-lz4.stable.out @@ -0,0 +1,12 @@ +stdout of test 'hot-snapshot-lz4` in directory 'sql/test` itself: + + +# 11:10:24 > +# 11:10:24 > "/usr/bin/python3" "hot-snapshot-lz4.py" "hot-snapshot-lz4" +# 11:10:24 > + + +# 11:10:24 > +# 11:10:24 > "Done." +# 11:10:24 > + diff --git a/sql/test/Tests/hot-snapshot-xz.py b/sql/test/Tests/hot-snapshot-xz.py new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-xz.py @@ -0,0 +1,12 @@ +#!/usr/bin/env python3 + +# Test if the snapshot data is actually compressed. + +from hot_snapshot_compression import check_compression + +import sys + +complaint = check_compression('xz', b'\xFD7zXZ\x00') +if complaint: + print(complaint) + sys.exit(1) diff --git a/sql/test/Tests/hot-snapshot-xz.stable.err b/sql/test/Tests/hot-snapshot-xz.stable.err new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-xz.stable.err @@ -0,0 +1,12 @@ +stderr of test 'hot-snapshot-xz` in directory 'sql/test` itself: + + +# 11:10:21 > +# 11:10:21 > "/usr/bin/python3" "hot-snapshot-xz.py" "hot-snapshot-xz" +# 11:10:21 > + + +# 11:10:21 > +# 11:10:21 > "Done." +# 11:10:21 > + diff --git a/sql/test/Tests/hot-snapshot-xz.stable.out b/sql/test/Tests/hot-snapshot-xz.stable.out new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot-snapshot-xz.stable.out @@ -0,0 +1,12 @@ +stdout of test 'hot-snapshot-xz` in directory 'sql/test` itself: + + +# 11:10:21 > +# 11:10:21 > "/usr/bin/python3" "hot-snapshot-xz.py" "hot-snapshot-xz" +# 11:10:21 > + + +# 11:10:21 > +# 11:10:21 > "Done." +# 11:10:21 > + diff --git a/sql/test/Tests/hot_snapshot_compression.py b/sql/test/Tests/hot_snapshot_compression.py new file mode 100644 --- /dev/null +++ b/sql/test/Tests/hot_snapshot_compression.py @@ -0,0 +1,36 @@ +#!/usr/bin/env python3 + +# Helper module for hot_snapshot_{gz,bz2,xz,lz4}.py + +import tempfile +import os, sys +try: + from MonetDBtesting import process +except ImportError: + import process + + +TSTTRGBASE = os.environ['TSTTRGBASE'] + + +def check_compression(extension, expected_first_bytes): + if not extension.startswith('.'): + extension = '.' + extension + # destfile = os.path.join(TSTTRGBASE, 'hot-snapshot.tar' + extension) + h, destfile = tempfile.mkstemp('hot_snapshot.tar' + extension) + os.close(h) + with process.client('sql', stdin = process.PIPE, stdout=process.PIPE, stderr=process.PIPE) as c: + c.stdin.write(f"CALL sys.hot_snapshot(r'{destfile}');") + out, err = c.communicate() + sys.stdout.write(out) + sys.stderr.write(err) + if c.returncode: + return f"Client exited with status {c.returncode}" + + contents = open(destfile, "rb").read() + first_bytes = contents[:len(expected_first_bytes)] + if first_bytes != expected_first_bytes: + return f"Content validation failed.\nFile: {destfile}\nFirst bytes: {repr(first_bytes)},\nExpected: {repr(expected_first_bytes)}" + + os.remove(destfile) + return None _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list