-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automatically start e2e testing #105
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
#!/usr/bin/env bash | ||
|
||
### Only support gcloud | ||
### Please ensure gcloud is installed before run this script | ||
GRS_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. | ||
|
||
source "${GRS_ROOT}/hack/test-config.sh" | ||
source "${GRS_ROOT}/hack/lib/util.sh" | ||
|
||
function start-service { | ||
local name="$1" | ||
local urls="$2" | ||
local zone="$3" | ||
local log_level="${4:-}" | ||
local extra_args="${5:-}" | ||
echo "Starting resource management service on ${name}" | ||
cmd="cd ${SERVER_CODE_ROOT}" | ||
cmd+=" && mkdir -p ${SERVER_LOG_DIR}" | ||
args=" --master_ip=${name}" | ||
args+=" --resource_urls=${urls}" | ||
if [ ${log_level} != "" ]; then | ||
args+=" -v=${log_level}" | ||
fi | ||
args+=" ${extra_args}" | ||
log_file="${name}.log" | ||
cmd+=" && /usr/local/go/bin/go run resource-management/cmds/service-api/service-api.go ${args} > ${SERVER_LOG_DIR}/${log_file} 2>&1 " | ||
ssh-config "${cmd}" "${name}" "${SERVICE_ZONE}" | ||
} | ||
|
||
|
||
function start-simulator { | ||
local name="$1" | ||
local region_name="$2" | ||
local rp_num="$3" | ||
local nodes_per_rp="$4" | ||
local sim_port="$5" | ||
local zone="$6" | ||
local log_level="${7:-}" | ||
local extra_args="${8:-}" | ||
echo "Starting simulator on ${name}" | ||
cmd="cd ${SIM_CODE_ROOT}" | ||
cmd+=" && mkdir -p ${SIM_LOG_DIR}" | ||
args=" --region_name=${region_name}" | ||
args+=" --rp_num=${rp_num}" | ||
args+=" --nodes_per_rp=${nodes_per_rp}" | ||
args+=" --master_port=${sim_port}" | ||
if [ ${log_level} != "" ]; then | ||
args+=" -v=${log_level}" | ||
fi | ||
args+=" ${extra_args}" | ||
log_file="${name}.log" | ||
cmd+=" && /usr/local/go/bin/go run resource-management/test/resourceRegionMgrSimulator/main.go ${args} > ${SIM_LOG_DIR}/${log_file} 2>&1 " | ||
ssh-config "${cmd}" "${name}" "${zone}" | ||
|
||
} | ||
|
||
function start-scheduler { | ||
local name="$1" | ||
local zone="$2" | ||
local service_num="$3" | ||
local service_url="$4" | ||
local request_machines="$5" | ||
local limit="$6" | ||
local log_level="${7:-}" | ||
local extra_args="${8:-}" | ||
echo "Starting ${service_num} schedluer service on ${name}" | ||
cmd="cd ${CLIENT_CODE_ROOT}" | ||
cmd+=" && mkdir -p ${CLIENT_LOG_DIR}" | ||
args=" --service_url=${service_url}" | ||
args+=" --request_machines=${request_machines}" | ||
args+=" --limit=${limit}" | ||
args+=" --action=watch" | ||
args+=" --repeats=1" | ||
if [ ${log_level} != "" ]; then | ||
args+=" -v=${log_level}" | ||
fi | ||
args+=" ${extra_args}" | ||
log_file="${name}.log" | ||
for (( i=0; i<${service_num}; i++ )); do | ||
sleep 1 | ||
gocmd=" && /usr/local/go/bin/go run resource-management/test/e2e/singleClientTest.go ${args} > ${SIM_LOG_DIR}/${log_file}.$i 2>&1 &" | ||
sshcmd="${cmd}${gocmd}" | ||
ssh-config "${sshcmd}" "${name}" "${zone}" | ||
done | ||
} | ||
|
||
############### | ||
# main function | ||
############### | ||
|
||
#IFS=','; INSTANCE_SERVER_ZONE=($SERVER_ZONE); unset IFS; | ||
IFS=','; INSTANCE_SIM_ZONE=($SIM_ZONE); unset IFS; | ||
IFS=','; INSTANCE_CLIENT_ZONE=($CLIENT_ZONE); unset IFS; | ||
IFS=','; SIM_REGION_LIST=($SIM_REGIONS); unset IFS; | ||
|
||
###TODO | ||
###using go run to start all component for now | ||
###will add build and start from bin | ||
|
||
##Only support to start service on one resource management server | ||
if [ ${SERVER_NUM} -gt 0 ]; then | ||
if [[ "${MASTER_IP}" != "" && "${RESOURCE_URLS}" != "" ]]; then | ||
start-service "${MASTER_IP}" "${RESOURCE_URLS}" "${SERVICE_ZONE}" "${SERVER_LOG_LEVEL}" "${SERVICE_EXTRA_ARGS}" | ||
else | ||
echo "Failed to start service, Please ensure MASTER_IP: ${MASTER_IP} and RESOURCE_URLS: ${RESOURCE_URLS} set correctly" | ||
fi | ||
fi | ||
|
||
echo "Waiting 10 seconds to get resource management service running" | ||
sleep 10 | ||
|
||
if [ ${SIM_NUM} -gt 0 ]; then | ||
if [[ "${#SIM_REGION_LIST[@]}" == "${SIM_NUM}" ]]; then | ||
if [ ${#INSTANCE_SIM_ZONE[@]} == 1 ]; then | ||
instance_names=() | ||
instance_names=($(gcloud compute instance-groups managed list-instances \ | ||
"${SIM_INSTANCE_PREFIX}-${INSTANCE_SIM_ZONE[0]}-mig" --zone "${INSTANCE_SIM_ZONE[0]}" --project "${PROJECT}" \ | ||
--format='value(instance)')) | ||
|
||
index=0 | ||
for name in "${instance_names[@]}"; do | ||
start-simulator "${name}" "${SIM_REGION_LIST[$index]}" "${SIM_RP_NUM}" "${NODES_PER_RP}" "${SIM_PORT}" "${INSTANCE_SIM_ZONE[0]}" "${SIM_LOG_LEVEL}" "${SIM_EXTRA_ARGS}" | ||
index=$(($index + 1)) | ||
done | ||
else | ||
index=0 | ||
for zone in "${INSTANCE_SIM_ZONE[@]}"; do | ||
start-simulator "${SIM_INSTANCE_PREFIX}-${zone}-${index}" "${SIM_REGION_LIST[$index]}" "${SIM_RP_NUM}" "${NODES_PER_RP}" "${SIM_PORT}" "${zone}" "${SIM_LOG_LEVEL}" "${SIM_EXTRA_ARGS}" | ||
index=$(($index + 1)) | ||
done | ||
|
||
fi | ||
else | ||
echo "Failed to start simulator service, Please ensure SIM_REGIONS: ${SIM_REGIONS} has same number with SIM_NUM: ${SIM_NUM}" | ||
fi | ||
fi | ||
|
||
echo "Waiting 60 seconds to get simulator running" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. that seems too long for the wait.... on my local dev, a few seconds is more than enough to have simulator up to go. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed to 10 seconds |
||
sleep 60 | ||
|
||
if [ ${CLIENT_NUM} -gt 0 ]; then | ||
if [[ "${SERVICE_URL}" != "" ]]; then | ||
if [ ${#INSTANCE_CLIENT_ZONE[@]} == 1 ]; then | ||
instance_names=() | ||
instance_names=($(gcloud compute instance-groups managed list-instances \ | ||
"${CLIENT_INSTANCE_PREFIX}-${INSTANCE_CLIENT_ZONE[0]}-mig" --zone "${INSTANCE_CLIENT_ZONE[0]}" --project "${PROJECT}" \ | ||
--format='value(instance)')) | ||
|
||
index=0 | ||
service_num=$((${SCHEDULER_NUM} / ${CLIENT_NUM} + 1)) | ||
for name in "${instance_names[@]}"; do | ||
if [ $index == $((${CLIENT_NUM} - 1)) ]; then | ||
done_num=$((${service_num} * ${index} )) | ||
service_num=$((${SCHEDULER_NUM} - ${done_num})) | ||
fi | ||
start-scheduler "${name}" "${INSTANCE_CLIENT_ZONE[0]}" "${service_num}" "${SERVICE_URL}" "${SCHEDULER_REQUEST_MACHINE}" "${SCHEDULER_REQUEST_LIMIT}" "${CLIENT_LOG_LEVEL}" "${CLIENT_EXTRA_ARGS}" | ||
index=$(($index + 1)) | ||
done | ||
else | ||
index=0 | ||
service_num=$((${SCHEDULER_NUM} / ${CLIENT_NUM} + 1)) | ||
for zone in "${INSTANCE_CLIENT_ZONE[@]}"; do | ||
if [ $index == $((${CLIENT_NUM} - 1)) ]; then | ||
done_num=$((${service_num} * ${index} )) | ||
service_num=$((${SCHEDULER_NUM} - ${done_num})) | ||
fi | ||
start-scheduler "${CLIENT_INSTANCE_PREFIX}-${zone}-${index}" "${zone}" "${service_num}" "${SERVICE_URL}" "${SCHEDULER_REQUEST_MACHINE}" "${SCHEDULER_REQUEST_LIMIT}" "${CLIENT_LOG_LEVEL}" "${CLIENT_EXTRA_ARGS}" | ||
index=$(($index + 1)) | ||
done | ||
|
||
fi | ||
else | ||
echo "Failed to start scheduler service, Please ensure SERVICE_URL: ${SERVICE_URL} is correct" | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
any reason default to 16? and also, is 14 scheduler instances per machine too many ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we have default 2 sim and total 400k nodes, CHEDULER_REQUEST_MACHINE is 25000, so set to 16 scheduler to meet with total nodes.
for this setup, scheduler number per machine are dynamic assigned based on total scheduler_num and client machine numbers.
so far, out testing using 3 client machines and 40 schedulers are working well.