steveloughran commented on a change in pull request #2278: URL: https://github.com/apache/hadoop/pull/2278#discussion_r507929259
########## File path: hadoop-tools/hadoop-azure/dev-support/testrun-scripts/testsupport.sh ########## @@ -0,0 +1,146 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + Review comment: set -eu for error reporting and rejection of uninited vars ########## File path: hadoop-tools/hadoop-azure/dev-support/testrun-scripts/testsupport.sh ########## @@ -0,0 +1,146 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +conffile=src/test/resources/azure-auth-keys.xml +bkpconffile=src/test/resources/azure-auth-keys_BKP.xml +logdir=target/testlogs +testresultsregex="Results:(\n|.)*?Tests run:" +testresultsfilename= +starttime= +threadcount= +defaultthreadcount=8 + +validate() { + if ! [ -s "$conffile" ] ; then + echo "Exiting. conf file is empty" + exit -1 + fi + if ! xmlstarlet val --well-formed "$conffile" ; then + echo "Exiting. conf file is not well formed xml" + exit -1 + fi + if [ -z "$threadcount" ] ; then + threadcount=$defaultthreadcount + fi + numberegex='^[0-9]+$' + if ! [[ $threadcount =~ $numberegex ]] ; then + echo "Exiting. The script param (threadcount) should be a number" + exit -1 + fi + if [ -z "$scenario" ]; then + echo "Exiting. scenario cannot be empty" + exit -1 + fi + propertiessize=${#properties[@]} + valuessize=${#values[@]} + if [ "$propertiessize" -lt 1 ] || [ "$valuessize" -lt 1 ] || [ "$propertiessize" -ne "$valuessize" ]; then + echo "Exiting. Both properties and values arrays has to be populated and of same size. Please check for scenario $scenario" + exit -1 + fi + + if ! [ -f "$conffile" ]; then + echo "Exiting. $conffile missing" + exit -1 + fi +} + +checkdependencies() { + if ! [ "$(command -v pcregrep)" ]; then + echo "Exiting. pcregrep is required to run the script." + exit -1 + fi + if ! [ "$(command -v xmlstarlet)" ]; then + echo "Exiting. xmlstarlet is required to run the script." + exit -1 + fi +} + +changeconf() { + xmlstarlet ed -P -L -d "/configuration/property[name='$1']" $conffile + xmlstarlet ed -P -L -s /configuration -t elem -n propertyTMP -v "" -s /configuration/propertyTMP -t elem -n name -v "$1" -r /configuration/propertyTMP -v property $conffile + if ! xmlstarlet ed -P -L -s "/configuration/property[name='$1']" -t elem -n value -v "$2" $conffile + then + echo "Exiting. Changing config property failed." + exit -1 + fi +} + +removeproperties() { + propertiessize=${#properties[@]} + for ((i = 0; i < propertiessize; i++)); do + key=${properties[$i]} + xmlstarlet ed -P -L -d "/configuration/property[name='$key']" $conffile + done +} + +testwithconfs() { + propertiessize=${#properties[@]} + valuessize=${#values[@]} + if [ "$propertiessize" -ne "$valuessize" ]; then + echo "Exiting. Number of properties and values differ for $scenario" + exit -1 + fi + for ((i = 0; i < propertiessize; i++)); do + key=${properties[$i]} + val=${values[$i]} + changeconf "$key" "$val" + done + mvn -T 1C -Dparallel-tests=abfs -Dscale -DtestsThreadCount=$threadcount verify >> "$testlogfilename" Review comment: only one scenario needs to run mvn test. Maybe set -Dtest=undefined and so they get skipped At the very least, let the caller declare a set of options to go down to maven ########## File path: hadoop-tools/hadoop-azure/src/site/markdown/testing_azure.md ########## @@ -872,7 +872,7 @@ To run CheckAccess test cases you must register an app with no RBAC and set the following configurations. ```xml <!--=========================== FOR CheckAccess =========================--> -<!-- To run ABFS CheckAccess SAS tests, you must register an app, with no role +<!-- To run ABFS CheckAccess tests, you must register an app, with no role Review comment: can you pull these instructions up from the XML into the text including URLs becoming links. I will be using these instructions to get my token ########## File path: hadoop-tools/hadoop-azure/src/site/markdown/testing_azure.md ########## @@ -935,3 +935,30 @@ http[s]://[account][domain-suffix]/[filesystem], please use the following: <value>{IP}:{PORT}</value> </property> ``` + +##Run different combinations of tests using the runtests.sh script Review comment: if this is going to be the policy. pull it up to the top of the document after the "no test no review" textHey ########## File path: hadoop-tools/hadoop-azure/dev-support/testrun-scripts/testsupport.sh ########## @@ -0,0 +1,146 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +conffile=src/test/resources/azure-auth-keys.xml +bkpconffile=src/test/resources/azure-auth-keys_BKP.xml +logdir=target/testlogs +testresultsregex="Results:(\n|.)*?Tests run:" +testresultsfilename= +starttime= +threadcount= +defaultthreadcount=8 + +validate() { + if ! [ -s "$conffile" ] ; then + echo "Exiting. conf file is empty" + exit -1 + fi + if ! xmlstarlet val --well-formed "$conffile" ; then Review comment: add comments to explain what these phases are ########## File path: hadoop-tools/hadoop-azure/dev-support/testrun-scripts/testsupport.sh ########## @@ -0,0 +1,146 @@ +#!/usr/bin/env bash + +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +conffile=src/test/resources/azure-auth-keys.xml +bkpconffile=src/test/resources/azure-auth-keys_BKP.xml +logdir=target/testlogs +testresultsregex="Results:(\n|.)*?Tests run:" +testresultsfilename= +starttime= +threadcount= +defaultthreadcount=8 + +validate() { + if ! [ -s "$conffile" ] ; then + echo "Exiting. conf file is empty" + exit -1 + fi + if ! xmlstarlet val --well-formed "$conffile" ; then + echo "Exiting. conf file is not well formed xml" + exit -1 + fi + if [ -z "$threadcount" ] ; then + threadcount=$defaultthreadcount + fi + numberegex='^[0-9]+$' + if ! [[ $threadcount =~ $numberegex ]] ; then + echo "Exiting. The script param (threadcount) should be a number" + exit -1 + fi + if [ -z "$scenario" ]; then + echo "Exiting. scenario cannot be empty" + exit -1 + fi + propertiessize=${#properties[@]} + valuessize=${#values[@]} + if [ "$propertiessize" -lt 1 ] || [ "$valuessize" -lt 1 ] || [ "$propertiessize" -ne "$valuessize" ]; then + echo "Exiting. Both properties and values arrays has to be populated and of same size. Please check for scenario $scenario" + exit -1 + fi + + if ! [ -f "$conffile" ]; then + echo "Exiting. $conffile missing" + exit -1 + fi +} + +checkdependencies() { + if ! [ "$(command -v pcregrep)" ]; then + echo "Exiting. pcregrep is required to run the script." + exit -1 + fi + if ! [ "$(command -v xmlstarlet)" ]; then + echo "Exiting. xmlstarlet is required to run the script." + exit -1 + fi +} + +changeconf() { + xmlstarlet ed -P -L -d "/configuration/property[name='$1']" $conffile + xmlstarlet ed -P -L -s /configuration -t elem -n propertyTMP -v "" -s /configuration/propertyTMP -t elem -n name -v "$1" -r /configuration/propertyTMP -v property $conffile + if ! xmlstarlet ed -P -L -s "/configuration/property[name='$1']" -t elem -n value -v "$2" $conffile + then + echo "Exiting. Changing config property failed." + exit -1 + fi +} + +removeproperties() { + propertiessize=${#properties[@]} + for ((i = 0; i < propertiessize; i++)); do + key=${properties[$i]} + xmlstarlet ed -P -L -d "/configuration/property[name='$key']" $conffile + done +} + +testwithconfs() { + propertiessize=${#properties[@]} + valuessize=${#values[@]} + if [ "$propertiessize" -ne "$valuessize" ]; then + echo "Exiting. Number of properties and values differ for $scenario" + exit -1 + fi + for ((i = 0; i < propertiessize; i++)); do + key=${properties[$i]} + val=${values[$i]} + changeconf "$key" "$val" + done + mvn -T 1C -Dparallel-tests=abfs -Dscale -DtestsThreadCount=$threadcount verify >> "$testlogfilename" + removeproperties +} + +summary() { + { + echo "" + echo "$scenario" + echo "========================" + pcregrep -M "$testresultsregex" "$testlogfilename" + } >> "$testresultsfilename" + printf "\n----- Test results -----\n" + pcregrep -M "$testresultsregex" "$testlogfilename" + + secondstaken=$((ENDTIME - STARTTIME)) + mins=$((secondstaken / 60)) + secs=$((secondstaken % 60)) + printf "\nTime taken: %s mins %s secs.\n" "$mins" "$secs" + echo "Find test logs for the scenario ($scenario) in: $testlogfilename" + echo "Find consolidated test results in: $testresultsfilename" + echo "----------" +} + +runtestwithconfs() { + validate + cp $conffile $bkpconffile + if [ -z "$starttime" ]; then + checkdependencies + mvn clean install -DskipTests + starttime=$(date +"%Y-%m-%d_%H-%M-%S") + mkdir -p "$logdir" + testresultsfilename="$logdir/Test-$starttime-Results.log" Review comment: can you just use .txt as a suffix for text files. IDEs and things often use .log as a format for structured output ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
