@@ -28,9 +28,12 @@ mkdir -p "$RESULT_DIR"
2828# Should be writeable from the docker containers where user is different.
2929chmod ogu+w " $RESULT_DIR "
3030
31- # # @description wait until 3 datanodes are up (or 30 seconds)
31+ # # @description wait until datanodes are up (or 30 seconds)
3232# # @param the docker-compose file
33+ # # @param number of datanodes to wait for (default: 3)
3334wait_for_datanodes (){
35+ local compose_file=$1
36+ local -i datanode_count=${2:- 3}
3437
3538 # Reset the timer
3639 SECONDS=0
@@ -40,30 +43,33 @@ wait_for_datanodes(){
4043
4144 # This line checks the number of HEALTHY datanodes registered in scm over the
4245 # jmx HTTP servlet
43- datanodes=$( docker-compose -f " $1 " exec -T scm curl -s ' http://localhost:9876/jmx?qry=Hadoop:service=SCMNodeManager,name=SCMNodeManagerInfo' | jq -r ' .beans[0].NodeCount[] | select(.key=="HEALTHY") | .value' )
44- if [[ " $datanodes " == " 3" ]]; then
46+ datanodes=$( docker-compose -f " ${compose_file} " exec -T scm curl -s ' http://localhost:9876/jmx?qry=Hadoop:service=SCMNodeManager,name=SCMNodeManagerInfo' | jq -r ' .beans[0].NodeCount[] | select(.key=="HEALTHY") | .value' )
47+ if [[ " $datanodes " ]]; then
48+ if [[ ${datanodes} -ge ${datanode_count} ]]; then
4549
46- # It's up and running. Let's return from the function.
50+ # It's up and running. Let's return from the function.
4751 echo " $datanodes datanodes are up and registered to the scm"
4852 return
49- else
53+ else
5054
51- # Print it only if a number. Could be not a number if scm is not yet started
52- if [[ " $datanodes " ]]; then
53- echo " $datanodes datanode is up and healthy (until now)"
55+ # Print it only if a number. Could be not a number if scm is not yet started
56+ echo " $datanodes datanode is up and healthy (until now)"
5457 fi
55- fi
58+ fi
5659
5760 sleep 2
5861 done
5962 echo " WARNING! Datanodes are not started successfully. Please check the docker-compose files"
6063}
6164
6265# # @description Starts a docker-compose based test environment
66+ # # @param number of datanodes to start and wait for (default: 3)
6367start_docker_env (){
68+ local -i datanode_count=${1:- 3}
69+
6470 docker-compose -f " $COMPOSE_FILE " down
65- docker-compose -f " $COMPOSE_FILE " up -d --scale datanode=3
66- wait_for_datanodes " $COMPOSE_FILE "
71+ docker-compose -f " $COMPOSE_FILE " up -d --scale datanode=" ${datanode_count} "
72+ wait_for_datanodes " $COMPOSE_FILE " " ${datanode_count} "
6773 sleep 10
6874}
6975
0 commit comments