|
@@ -28,9 +28,12 @@ mkdir -p "$RESULT_DIR"
|
|
|
#Should be writeable from the docker containers where user is different.
|
|
|
chmod ogu+w "$RESULT_DIR"
|
|
|
|
|
|
-## @description wait until 3 datanodes are up (or 30 seconds)
|
|
|
+## @description wait until datanodes are up (or 30 seconds)
|
|
|
## @param the docker-compose file
|
|
|
+## @param number of datanodes to wait for (default: 3)
|
|
|
wait_for_datanodes(){
|
|
|
+ local compose_file=$1
|
|
|
+ local -i datanode_count=${2:-3}
|
|
|
|
|
|
#Reset the timer
|
|
|
SECONDS=0
|
|
@@ -40,19 +43,19 @@ wait_for_datanodes(){
|
|
|
|
|
|
#This line checks the number of HEALTHY datanodes registered in scm over the
|
|
|
# jmx HTTP servlet
|
|
|
- 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')
|
|
|
- if [[ "$datanodes" == "3" ]]; then
|
|
|
+ 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')
|
|
|
+ if [[ "$datanodes" ]]; then
|
|
|
+ if [[ ${datanodes} -ge ${datanode_count} ]]; then
|
|
|
|
|
|
- #It's up and running. Let's return from the function.
|
|
|
+ #It's up and running. Let's return from the function.
|
|
|
echo "$datanodes datanodes are up and registered to the scm"
|
|
|
return
|
|
|
- else
|
|
|
+ else
|
|
|
|
|
|
- #Print it only if a number. Could be not a number if scm is not yet started
|
|
|
- if [[ "$datanodes" ]]; then
|
|
|
- echo "$datanodes datanode is up and healthy (until now)"
|
|
|
+ #Print it only if a number. Could be not a number if scm is not yet started
|
|
|
+ echo "$datanodes datanode is up and healthy (until now)"
|
|
|
fi
|
|
|
- fi
|
|
|
+ fi
|
|
|
|
|
|
sleep 2
|
|
|
done
|
|
@@ -60,10 +63,13 @@ wait_for_datanodes(){
|
|
|
}
|
|
|
|
|
|
## @description Starts a docker-compose based test environment
|
|
|
+## @param number of datanodes to start and wait for (default: 3)
|
|
|
start_docker_env(){
|
|
|
+ local -i datanode_count=${1:-3}
|
|
|
+
|
|
|
docker-compose -f "$COMPOSE_FILE" down
|
|
|
- docker-compose -f "$COMPOSE_FILE" up -d --scale datanode=3
|
|
|
- wait_for_datanodes "$COMPOSE_FILE"
|
|
|
+ docker-compose -f "$COMPOSE_FILE" up -d --scale datanode="${datanode_count}"
|
|
|
+ wait_for_datanodes "$COMPOSE_FILE" "${datanode_count}"
|
|
|
sleep 10
|
|
|
}
|
|
|
|