From 74746de0cbc6b868f26b0210a1c1c5e97974a1ff Mon Sep 17 00:00:00 2001 From: Guillaume Tassery Date: Wed, 24 Apr 2019 12:17:21 +0700 Subject: [PATCH] Add functional tests for ipv6 range function --- .../00938_ipv6_cidr_range.reference | 17 ++++++++++ .../0_stateless/00938_ipv6_cidr_range.sql | 31 +++++++++++++++++++ 2 files changed, 48 insertions(+) create mode 100644 dbms/tests/queries/0_stateless/00938_ipv6_cidr_range.reference create mode 100644 dbms/tests/queries/0_stateless/00938_ipv6_cidr_range.sql diff --git a/dbms/tests/queries/0_stateless/00938_ipv6_cidr_range.reference b/dbms/tests/queries/0_stateless/00938_ipv6_cidr_range.reference new file mode 100644 index 00000000000..39802bbb3ff --- /dev/null +++ b/dbms/tests/queries/0_stateless/00938_ipv6_cidr_range.reference @@ -0,0 +1,17 @@ +3 +4 +3 +2 +7 +2001:db8:0:85a3::ac1f:8001 0 :: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff +2001:db8:0:85a3:ffff:ffff:ffff:ffff 32 2001:db8:: 2001:db8:ffff:ffff:ffff:ffff:ffff:ffff +ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff 16 ffff:: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff +2001:df8:0:85a3::ac1f:8001 32 2001:df8:: 2001:df8:ffff:ffff:ffff:ffff:ffff:ffff +2001:db8:85a3:85a3::ac1f:8001 16 2001:: 2001:ffff:ffff:ffff:ffff:ffff:ffff:ffff +:: 8 :: ff:ffff:ffff:ffff:ffff:ffff:ffff:ffff +ffff:: 4 f000:: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff +:: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff +2001:db8:0:85a3::ac1f:8001 2001:db8:0:85a3::ac1f:8001 +ffff:ffff:ffff:ffff:: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff +:: ff:ffff:ffff:ffff:ffff:ffff:ffff:ffff +f000:: ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff diff --git a/dbms/tests/queries/0_stateless/00938_ipv6_cidr_range.sql b/dbms/tests/queries/0_stateless/00938_ipv6_cidr_range.sql new file mode 100644 index 00000000000..7b3b4567780 --- /dev/null +++ b/dbms/tests/queries/0_stateless/00938_ipv6_cidr_range.sql @@ -0,0 +1,31 @@ +USE test; + +DROP TABLE IF EXISTS ipv6_range; +CREATE TABLE ipv6_range(ip FixedString(16), cidr UInt8) ENGINE = Memory; + +INSERT INTO ipv6_range (ip, cidr) VALUES (IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 0), (IPv6StringToNum('2001:0db8:0000:85a3:ffff:ffff:ffff:ffff'), 32), (IPv6StringToNum('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'), 16), (IPv6StringToNum('2001:df8:0:85a3::ac1f:8001'), 32), (IPv6StringToNum('2001:0db8:85a3:85a3:0000:0000:ac1f:8001'), 16), (IPv6StringToNum('0000:0000:0000:0000:0000:0000:0000:0000'), 8), (IPv6StringToNum('ffff:0000:0000:0000:0000:0000:0000:0000'), 4); + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 32) as ip_range SELECT COUNT(*) FROM ipv6_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2); + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 25) as ip_range SELECT COUNT(*) FROM ipv6_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2); + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 26) as ip_range SELECT COUNT(*) FROM ipv6_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2); + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 64) as ip_range SELECT COUNT(*) FROM ipv6_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2); + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 0) as ip_range SELECT COUNT(*) FROM ipv6_range WHERE ip BETWEEN tupleElement(ip_range, 1) AND tupleElement(ip_range, 2); + +WITH IPv6CIDRtoIPv6Range(ip, cidr) as ip_range SELECT IPv6NumToString(ip), cidr, IPv6NumToString(tupleElement(ip_range, 1)), IPv6NumToString(tupleElement(ip_range, 2)) FROM ipv6_range; + +DROP TABLE ipv6_range; + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 0) as ip_range SELECT IPv6NumToString(tupleElement(ip_range, 1)) as lower_range, IPv6NumToString(tupleElement(ip_range, 2)) as higher_range; + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('2001:0db8:0000:85a3:0000:0000:ac1f:8001'), 128) as ip_range SELECT IPv6NumToString(tupleElement(ip_range, 1)) as lower_range, IPv6NumToString(tupleElement(ip_range, 2)) as higher_range; + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff'), 64) as ip_range SELECT IPv6NumToString(tupleElement(ip_range, 1)) as lower_range, IPv6NumToString(tupleElement(ip_range, 2)) as higher_range; + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('0000:0000:0000:0000:0000:0000:0000:0000'), 8) as ip_range SELECT IPv6NumToString(tupleElement(ip_range, 1)) as lower_range, IPv6NumToString(tupleElement(ip_range, 2)) as higher_range; + +WITH IPv6CIDRtoIPv6Range(IPv6StringToNum('ffff:0000:0000:0000:0000:0000:0000:0000'), 4) as ip_range SELECT IPv6NumToString(tupleElement(ip_range, 1)) as lower_range, IPv6NumToString(tupleElement(ip_range, 2)) as higher_range; +