-
Notifications
You must be signed in to change notification settings - Fork 301
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
Script to run local e2e test #1110
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#/bin/bash | ||
|
||
# Run glbc. First run `run-local.sh` to set things up. | ||
# | ||
# Files touched: /tmp/kubectl-proxy.log /tmp/glbc.log | ||
|
||
GOOGLE_APPLICATION_CREDENTIALS="${HOME}/.config/gcloud/application_default_credentials.json" | ||
|
||
if [ ! -r ${GOOGLE_APPLICATION_CREDENTIALS} ]; then | ||
echo "You must login your application default credentials" | ||
echo "$ gcloud auth application-default login" | ||
exit 1 | ||
fi | ||
|
||
GCECONF=${GCECONF:-/tmp/gce.conf} | ||
GLBC=${GLBC:-./glbc} | ||
PORT=${PORT:-7127} | ||
V=${V:-3} | ||
|
||
echo "GCECONF=${GCECONF} GLBC=${GLBC} PORT=${PORT} V=${V}" | ||
|
||
if [ ! -x "${GLBC}" ]; then | ||
echo "ERROR: No ${GLBC} executable found" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo "$(date) start" >> /tmp/kubectl-proxy.log | ||
kubectl proxy --port="${PORT}" \ | ||
>> /tmp/kubectl-proxy.log & | ||
|
||
PROXY_PID=$! | ||
cleanup() { | ||
echo "Killing proxy (pid=${PROXY_PID})" | ||
kill ${PROXY_PID} | ||
} | ||
trap cleanup EXIT | ||
|
||
kubectl apply -f docs/deploy/resources/default-http-backend.yaml | ||
|
||
sleep 2 # Wait for proxy to start up | ||
${GLBC} \ | ||
--apiserver-host=http://localhost:${PORT} \ | ||
--running-in-cluster=false \ | ||
--logtostderr --v=${V} \ | ||
--config-file-path=${GCECONF} \ | ||
| tee -a /tmp/glbc.log |
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,72 @@ | ||
#/bin/bash | ||
|
||
# Setup the environment for running the e2e tests from your | ||
# desktop. | ||
|
||
set -e | ||
|
||
parseCluster() { | ||
# These are all globals. | ||
net=$1 | ||
subnet=$2 | ||
zone=$3 | ||
selfLink=$4 | ||
net=$(echo ${net} | sed 's+.*networks/\([-a-z]*\).*$+\1+') | ||
subnet=$(echo ${subnet} | sed 's+.*subnetworks/\([-a-z]*\)$+\1+') | ||
project=$(echo ${selfLink} | sed 's+.*/projects/\([-a-z]*\)/.*+\1+') | ||
} | ||
|
||
parseInstance() { | ||
local name=$1 | ||
local zone=$2 | ||
# Globals. | ||
nodeTag=$(gcloud compute instances describe ${name} --zone ${zone} --format='value(tags.items[0])') | ||
} | ||
|
||
clusterName="$1" | ||
clusterLocation="$2" | ||
|
||
if [ -z "${clusterName}" ]; then | ||
echo "Usage: $0 CLUSTER_NAME [LOCATION]" | ||
echo | ||
echo "LOCATION is optional if there is only one cluster with CLUSTER_NAME" | ||
exit 1 | ||
fi | ||
|
||
fmt='value(networkConfig.network,networkConfig.subnetwork,zone,selfLink,name)' | ||
if [ -z "$clusterLocation" ]; then | ||
clusters=$(gcloud container clusters list --format="${fmt}" --filter="name=${clusterName}") | ||
else | ||
clusters=$(gcloud container clusters list --format="${fmt}" --filter="name=${clusterName} location=${clusterLocation}") | ||
fi | ||
if [ $(echo "${cluster}" | wc -l) -gt 1 ]; then | ||
echo "ERROR: more than one cluster matches '${clusterName}'" | ||
fi | ||
parseCluster ${clusters} | ||
if [ -z "${clusters}" ]; then | ||
echo "ERROR: No cluster '${clusterName}' found" | ||
exit 1 | ||
fi | ||
|
||
instance=$(gcloud compute instances list --format='value(name,zone)' | grep ${clusterName} | tail -n 1) | ||
parseInstance ${instance} | ||
if [ -z "${instance}" ]; then | ||
echo "ERROR: No nodes matching '${clusterName}' found" | ||
exit 1 | ||
fi | ||
|
||
gceConf="/tmp/gce.conf" | ||
echo "Writing ${gceConf}" | ||
echo "----" | ||
cat <<EOF | tee ${gceConf} | ||
[global] | ||
token-url = nil | ||
project-id = ${project} | ||
network-name = ${net} | ||
subnetwork-name = ${subnet} | ||
node-instance-prefix = ${clusterName} | ||
node-tags = ${nodeTag} | ||
local-zone = ${zone} | ||
EOF | ||
|
||
echo "Run glbc with hack/run-glbc.sh" |
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.
this seems to assume the glbc executable is in this directory? If you run the script as is, it won't work unless you build first and move the executable here.
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.
you can do that by
GLBC=mypath/xxx hack/run-local-glbc.sh