#! /bin/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. if [[ $# -eq 1 ]]; then VMS=$1 else VMS=20 fi date #HOSTS=`./bin/getHosts | grep name | wc -l` HOSTS="4" echo "Hosts: ${HOSTS}" echo "Create:" MID=10240000 for i in `seq -w 1 $VMS`; do echo "./scripts/create 2 $i" ID=`./scripts/create 2 $i | grep "id: " | awk '{print $2}'` if [[ ${ID} -lt ${MID} ]]; then MID=${ID} fi done date echo "Wait:" while [[ true ]]; do CNT=`./bin/getInstances | grep -c Running` echo ${CNT} if [[ ${CNT} -eq ${VMS} ]]; then break fi sleep 1 done sleep 20 date echo "Migrate:" for i in `seq 0 $((VMS-1))`; do echo "./bin/migrateVm $((MID+i)) $((((i+1)%HOSTS)+1))" ./bin/migrateVm $((MID+i)) $((((i+1)%HOSTS)+1)) > /dev/null & done for i in `seq 0 $((VMS-1))`; do wait done date echo "Wait:" while [[ true ]]; do CNT=`./bin/getInstances | grep -c Running` echo ${CNT} if [[ ${CNT} -eq ${VMS} ]]; then break fi sleep 1 done date echo "Destroy:" for i in `seq 0 $((VMS-1))`; do echo "./bin/destroyVm $((MID+i))" ./bin/destroyVm $((MID+i)) > /dev/null 2>&1 & done for i in `seq 0 $((VMS-1))`; do wait done date echo "Wait:" while [[ true ]]; do CNT=`./bin/getInstances | wc -l` echo ${CNT} if [[ ${CNT} -eq 1 ]]; then break fi sleep 1 done date