From 097357799d6104f8fc6d0a0ca356ba80152c0992 Mon Sep 17 00:00:00 2001 From: proller Date: Tue, 3 Oct 2017 21:31:32 +0300 Subject: [PATCH] Tests: --random option; set some env variables for .sh tests --- dbms/tests/clickhouse-test | 11 ++++++++++- dbms/tests/queries/0_stateless/00501_http_head.sh | 8 +++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dbms/tests/clickhouse-test b/dbms/tests/clickhouse-test index 8a2d547cd0c..c55b8d13186 100755 --- a/dbms/tests/clickhouse-test +++ b/dbms/tests/clickhouse-test @@ -18,6 +18,7 @@ from datetime import datetime from time import sleep from errno import ESRCH from termcolor import colored +from random import random OP_SQUARE_BRACKET = colored("[", attrs=['bold']) @@ -89,6 +90,11 @@ def main(args): failures_total = 0 + os.environ.setdefault("CLICKHOUSE_CLIENT", args.client) + os.environ.setdefault("CLICKHOUSE_BINARY", "clickhouse") + os.environ.setdefault("CLICKHOUSE_URL", "http://localhost:8123/") + os.environ.setdefault("CLICKHOUSE_CONFIG", "/etc/clickhouse-server/config.xml") + for suite in sorted(os.listdir(base_dir)): if SERVER_DIED: break @@ -109,6 +115,8 @@ def main(args): # Reverse sort order: we want run newest test first. # And not reverse subtests def key_func(item): + if args.random: + return random() prefix, suffix = item.split('_', 1) return -int(prefix), suffix for case in sorted(filter(lambda case: re.search(args.test, case) if args.test else True, os.listdir(suite_dir)), key=key_func): @@ -262,7 +270,8 @@ if __name__ == '__main__': parser.add_argument('-o', '--output', help = 'Output xUnit compliant test report directory') parser.add_argument('-t', '--timeout', type = int, default = 600, help = 'Timeout for each test case in seconds') parser.add_argument('test', nargs = '?', help = 'Optional test case name regex') - parser.add_argument('--stop', action = 'store_true', default = None, dest = 'stop', help = 'Stop on network errors ') + parser.add_argument('--stop', action = 'store_true', default = None, dest = 'stop', help = 'Stop on network errors') + parser.add_argument('--random', action = 'store_true', default = None, dest = 'random', help = 'Randomize tests order') group = parser.add_mutually_exclusive_group(required = False) group.add_argument('--zookeeper', action = 'store_true', default = None, dest = 'zookeeper', help = 'Run zookeeper related tests') diff --git a/dbms/tests/queries/0_stateless/00501_http_head.sh b/dbms/tests/queries/0_stateless/00501_http_head.sh index f6e7e10c6a8..75093295f21 100755 --- a/dbms/tests/queries/0_stateless/00501_http_head.sh +++ b/dbms/tests/queries/0_stateless/00501_http_head.sh @@ -1,8 +1,10 @@ #!/usr/bin/env bash -( curl -s --head "${CLICKHOUSE_URL:=http://localhost:8123/}?query=SELECT%201"; - curl -s --head "${CLICKHOUSE_URL:=http://localhost:8123/}?query=select+*+from+system.numbers+limit+1000000" ) | grep -v "Date:" +CLICKHOUSE_URL=${CLICKHOUSE_URL:=http://localhost:8123/} -if [[ `curl -sS -X POST -I "http://127.0.0.1:8123?query=SELECT+1" | grep -c '411 Length Required'` -ne 1 ]]; then +( curl -s --head "${CLICKHOUSE_URL}?query=SELECT%201"; + curl -s --head "${CLICKHOUSE_URL}?query=select+*+from+system.numbers+limit+1000000" ) | grep -v "Date:" + +if [[ `curl -sS -X POST -I "${CLICKHOUSE_URL}?query=SELECT+1" | grep -c '411 Length Required'` -ne 1 ]]; then echo FAIL fi