IMPALA-6613: Change TEST_KRPC to DISABLE_KRPC
[impala.git] / bin / run-all-tests.sh
1 #!/usr/bin/env bash
2 #
3 # Licensed to the Apache Software Foundation (ASF) under one
4 # or more contributor license agreements. See the NOTICE file
5 # distributed with this work for additional information
6 # regarding copyright ownership. The ASF licenses this file
7 # to you under the Apache License, Version 2.0 (the
8 # "License"); you may not use this file except in compliance
9 # with the License. You may obtain a copy of the License at
10 #
11 # http://www.apache.org/licenses/LICENSE-2.0
12 #
13 # Unless required by applicable law or agreed to in writing,
14 # software distributed under the License is distributed on an
15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 # KIND, either express or implied. See the License for the
17 # specific language governing permissions and limitations
18 # under the License.
19 #
20 # Runs all the tests. Currently includes FE tests, BE unit tests, and the end-to-end
21 # test suites.
22
23 # Exit on reference to uninitialized variables and non-zero exit codes
24 set -euo pipefail
25 trap 'echo Error in $0 at line $LINENO: $(cd "'$PWD'" && awk "NR == $LINENO" $0)' ERR
26
27 . "$IMPALA_HOME/bin/set-pythonpath.sh"
28
29 # Allow picking up strategy from environment
30 : ${EXPLORATION_STRATEGY:=core}
31 : ${NUM_TEST_ITERATIONS:=1}
32 : ${MAX_PYTEST_FAILURES:=10}
33 KERB_ARGS=""
34
35 . "${IMPALA_HOME}/bin/impala-config.sh" > /dev/null 2>&1
36 . "${IMPALA_HOME}/testdata/bin/run-step.sh"
37 if "${CLUSTER_DIR}/admin" is_kerberized; then
38 KERB_ARGS="--use_kerberos"
39 fi
40
41 # Parametrized Test Options
42 # Disable KRPC for test cluster and test execution
43 : ${DISABLE_KRPC:=false}
44 # Run FE Tests
45 : ${FE_TEST:=true}
46 # Run Backend Tests
47 : ${BE_TEST:=true}
48 # Run End-to-end Tests
49 : ${EE_TEST:=true}
50 : ${EE_TEST_FILES:=}
51 # Run JDBC Test
52 : ${JDBC_TEST:=true}
53 # Run Cluster Tests
54 : ${CLUSTER_TEST:=true}
55 # Extra arguments passed to start-impala-cluster for tests. These do not apply to custom
56 # cluster tests.
57 : ${TEST_START_CLUSTER_ARGS:=}
58 if [[ "${TARGET_FILESYSTEM}" == "local" ]]; then
59 # TODO: Remove abort_on_config_error flag from here and create-load-data.sh once
60 # checkConfiguration() accepts the local filesystem (see IMPALA-1850).
61 TEST_START_CLUSTER_ARGS="${TEST_START_CLUSTER_ARGS} --cluster_size=1 "`
62 `"--impalad_args=--abort_on_config_error=false"
63 FE_TEST=false
64 else
65 TEST_START_CLUSTER_ARGS="${TEST_START_CLUSTER_ARGS} --cluster_size=3"
66 fi
67
68 # If KRPC tests are disabled, pass the flag to disable KRPC during cluster start.
69 if [[ "${DISABLE_KRPC}" == "true" ]]; then
70 TEST_START_CLUSTER_ARGS="${TEST_START_CLUSTER_ARGS} --disable_krpc"
71 fi
72
73 # Indicates whether code coverage reports should be generated.
74 : ${CODE_COVERAGE:=false}
75
76 # parse command line options
77 while getopts "e:n:c" OPTION
78 do
79 case "$OPTION" in
80 e)
81 EXPLORATION_STRATEGY="$OPTARG"
82 ;;
83 n)
84 NUM_TEST_ITERATIONS="$OPTARG"
85 ;;
86 c)
87 CODE_COVERAGE=true
88 ;;
89 ?)
90 echo "run-all-tests.sh [-e <exploration_strategy>] [-n <num_iters>]"
91 echo "[-e] The exploration strategy to use. Default exploration is 'core'."
92 echo "[-n] The number of times to run the tests. Default is 1."
93 echo "[-c] Set this option to generate code coverage reports."
94 exit 1;
95 ;;
96 esac
97 done
98
99 # IMPALA-3947: "Exhaustive" tests are actually based on workload. This
100 # means what we colloquially call "exhaustive" tests are actually
101 # "exhaustive tests whose workloads are in this set below". Not all
102 # workloads are able to be exhaustively run through buildall.sh. For
103 # example, the tpch workload is never run exhaustively, because the
104 # relatively large size of tpch means data loading in all exhaustive
105 # formats takes much longer and data load snapshots containing tpch in
106 # all exhaustive formats are much larger to store and take longer to
107 # load.
108 #
109 # XXX If you change the --workload_exploration_strategy set below,
110 # please update the buildall.sh help text for -testexhaustive.
111 COMMON_PYTEST_ARGS="--maxfail=${MAX_PYTEST_FAILURES} --exploration_strategy=core"`
112 `" --workload_exploration_strategy="`
113 `"functional-query:${EXPLORATION_STRATEGY},"`
114 `"targeted-stress:${EXPLORATION_STRATEGY}"
115
116 if [[ "${TARGET_FILESYSTEM}" == "local" ]]; then
117 # Only one impalad is supported when running against local filesystem.
118 COMMON_PYTEST_ARGS+=" --impalad=localhost:21000"
119 fi
120
121 # If KRPC tests are disabled, pass test_no_krpc flag to pytest.
122 # This includes the end-to-end tests and the custom cluster tests.
123 if [[ "${DISABLE_KRPC}" == "true" ]]; then
124 COMMON_PYTEST_ARGS+=" --test_no_krpc"
125 fi
126
127 # For logging when using run-step.
128 LOG_DIR="${IMPALA_EE_TEST_LOGS_DIR}"
129
130 # Enable core dumps
131 ulimit -c unlimited || true
132
133 if [[ "${TARGET_FILESYSTEM}" == "hdfs" ]]; then
134 # To properly test HBase integeration, HBase regions are split and assigned by this
135 # script. Restarting HBase will change the region server assignment. Run split-hbase.sh
136 # before running any test.
137 run-step "Split and assign HBase regions" split-hbase.log \
138 "${IMPALA_HOME}/testdata/bin/split-hbase.sh"
139 fi
140
141 for i in $(seq 1 $NUM_TEST_ITERATIONS)
142 do
143 TEST_RET_CODE=0
144
145 run-step "Starting Impala cluster" start-impala-cluster.log \
146 "${IMPALA_HOME}/bin/start-impala-cluster.py" --log_dir="${IMPALA_EE_TEST_LOGS_DIR}" \
147 ${TEST_START_CLUSTER_ARGS}
148
149 if [[ "$BE_TEST" == true ]]; then
150 if [[ "$TARGET_FILESYSTEM" == "local" ]]; then
151 # This test will fail the configuration checks on local filesystem.
152 # TODO: Don't skip this test once checkConfiguration() accepts the local
153 # filesystem (see IMPALA-1850).
154 export SKIP_BE_TEST_PATTERN="session*"
155 fi
156 # Run backend tests.
157 if ! "${IMPALA_HOME}/bin/run-backend-tests.sh"; then
158 TEST_RET_CODE=1
159 fi
160 fi
161
162 # Run some queries using run-workload to verify run-workload has not been broken.
163 if ! run-step "Run test run-workload" test-run-workload.log \
164 "${IMPALA_HOME}/bin/run-workload.py" -w tpch --num_clients=2 --query_names=TPCH-Q1 \
165 --table_format=text/none --exec_options="disable_codegen:False" ${KERB_ARGS}; then
166 TEST_RET_CODE=1
167 fi
168
169 if [[ "$FE_TEST" == true ]]; then
170 # Run JUnit frontend tests
171 # Requires a running impalad cluster because some tests (such as DataErrorTest and
172 # JdbcTest) queries against an impala cluster.
173 pushd "${IMPALA_FE_DIR}"
174 MVN_ARGS=""
175 if [[ "${TARGET_FILESYSTEM}" == "s3" ]]; then
176 # When running against S3, only run the S3 frontend tests.
177 MVN_ARGS="-Dtest=S3* "
178 fi
179 if [[ "$CODE_COVERAGE" == true ]]; then
180 MVN_ARGS+="-DcodeCoverage"
181 fi
182 if ! "${IMPALA_HOME}/bin/mvn-quiet.sh" -fae test ${MVN_ARGS}; then
183 TEST_RET_CODE=1
184 fi
185 popd
186 fi
187
188 if [[ "$EE_TEST" == true ]]; then
189 # Run end-to-end tests.
190 # KERBEROS TODO - this will need to deal with ${KERB_ARGS}
191 if ! "${IMPALA_HOME}/tests/run-tests.py" ${COMMON_PYTEST_ARGS} ${EE_TEST_FILES}; then
192 #${KERB_ARGS};
193 TEST_RET_CODE=1
194 fi
195 fi
196
197 if [[ "$JDBC_TEST" == true ]]; then
198 # Run the JDBC tests with background loading disabled. This is interesting because
199 # it requires loading missing table metadata.
200 "${IMPALA_HOME}/bin/start-impala-cluster.py" --log_dir="${IMPALA_EE_TEST_LOGS_DIR}" \
201 --catalogd_args=--load_catalog_in_background=false \
202 ${TEST_START_CLUSTER_ARGS}
203 pushd "${IMPALA_FE_DIR}"
204 if ! "${IMPALA_HOME}/bin/mvn-quiet.sh" test -Dtest=JdbcTest; then
205 TEST_RET_CODE=1
206 fi
207 popd
208 fi
209
210 if [[ "$CLUSTER_TEST" == true ]]; then
211 # For custom cluster tests only, set an unlimited log rotation
212 # policy, for the mini cluster is restarted many times. So as not to
213 # pollute the directory with too many files, remove what was there
214 # before. Also, save the IMPALA_MAX_LOG_FILES value for re-set
215 # later.
216 rm -rf "${IMPALA_CUSTOM_CLUSTER_TEST_LOGS_DIR}"
217 mkdir -p "${IMPALA_CUSTOM_CLUSTER_TEST_LOGS_DIR}"
218 IMPALA_MAX_LOG_FILES_SAVE="${IMPALA_MAX_LOG_FILES:-10}"
219 export IMPALA_MAX_LOG_FILES=0
220 # Run the custom-cluster tests after all other tests, since they will restart the
221 # cluster repeatedly and lose state.
222 # TODO: Consider moving in to run-tests.py.
223 if ! "${IMPALA_HOME}/tests/run-custom-cluster-tests.sh" ${COMMON_PYTEST_ARGS}; then
224 TEST_RET_CODE=1
225 fi
226 export IMPALA_MAX_LOG_FILES="${IMPALA_MAX_LOG_FILES_SAVE}"
227 fi
228
229 # Finally, run the process failure tests.
230 # Disabled temporarily until we figure out the proper timeouts required to make the test
231 # succeed.
232 # ${IMPALA_HOME}/tests/run-process-failure-tests.sh
233 if [[ $TEST_RET_CODE == 1 ]]; then
234 exit $TEST_RET_CODE
235 fi
236 done