-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Introduce test-scale script #2578
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 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 hidden or 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 hidden or 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,164 @@ | ||
| #!/bin/bash | ||
|
|
||
| # This test script deploys the following: | ||
| # - 1 Linkerd control-plane | ||
| # - 5 NAMESPACES x 5 REPLICAS of each: | ||
| # - Emojivoto demo app | ||
| # - Books demo app | ||
| # - Lifecycle / bb test environment | ||
| # | ||
| # Usage: | ||
| # test-scale /path/to/linkerd [namespace] | ||
|
|
||
| set -e | ||
|
|
||
| NAMESPACES=5 | ||
| REPLICAS=5 | ||
|
|
||
| # TODO: share these functions with test-run | ||
|
|
||
| function check_linkerd_binary(){ | ||
| printf "Checking the linkerd binary..." | ||
| if [[ "$linkerd_path" != /* ]]; then | ||
| printf "\\n[%s] is not an absolute path\\n" "$linkerd_path" | ||
| exit 1 | ||
| fi | ||
| if [ ! -x "$linkerd_path" ]; then | ||
| printf "\\n[%s] does not exist or is not executable\\n" "$linkerd_path" | ||
| exit 1 | ||
| fi | ||
| exit_code=0 | ||
| "$linkerd_path" version --client > /dev/null 2>&1 || exit_code=$? | ||
| if [ $exit_code -ne 0 ]; then | ||
| printf "\\nFailed to run linkerd version command\\n" | ||
| exit $exit_code | ||
| fi | ||
| printf "[ok]\\n" | ||
| } | ||
|
|
||
| function check_if_k8s_reachable(){ | ||
| printf "Checking if there is a Kubernetes cluster available..." | ||
| exit_code=0 | ||
| kubectl --request-timeout=5s get ns > /dev/null 2>&1 || exit_code=$? | ||
| if [ $exit_code -ne 0 ]; then | ||
| printf "\\nFailed to connect to Kubernetes cluster\\n" | ||
| exit $exit_code | ||
| fi | ||
| printf "[ok]\\n" | ||
| } | ||
|
|
||
| linkerd_path=$1 | ||
|
|
||
| if [ -z "$linkerd_path" ]; then | ||
| echo "usage: $(basename "$0") /path/to/linkerd [namespace]" >&2 | ||
| exit 64 | ||
| fi | ||
|
|
||
| check_linkerd_binary | ||
| check_if_k8s_reachable | ||
|
|
||
| linkerd_version=$($linkerd_path version --client --short) | ||
| linkerd_namespace=${2:-l5d-scale} | ||
|
|
||
| # | ||
| # Deploy Linkerd | ||
| # | ||
|
|
||
| $linkerd_path -l $linkerd_namespace install | kubectl apply -f - | ||
| $linkerd_path -l $linkerd_namespace check --expected-version=$linkerd_version | ||
| $linkerd_path -l $linkerd_namespace install-sp | kubectl apply -f - | ||
|
|
||
| # | ||
| # Deploy Books | ||
| # | ||
|
|
||
| BOOKS_BACKEND=$(curl -s https://raw.githubusercontent.com/BuoyantIO/booksapp/master/k8s/mysql-backend.yml) | ||
|
|
||
| AUTHORS_SP=$(curl -s https://run.linkerd.io/booksapp/authors.swagger) | ||
| BOOKS_SP=$(curl -s https://run.linkerd.io/booksapp/books.swagger) | ||
| WEBAPP_SP=$(curl -s https://run.linkerd.io/booksapp/webapp.swagger) | ||
|
|
||
| # deploy books backend and service profiles to N namespaces | ||
| for i in $(eval echo {1..$NAMESPACES}); do | ||
| booksns=$linkerd_namespace-books-$i | ||
| kubectl create ns $booksns | ||
| echo "$BOOKS_BACKEND" | kubectl apply -n $booksns -f - | ||
|
|
||
| echo "$AUTHORS_SP" | bin/linkerd profile -n $booksns authors --open-api - | kubectl apply -f - | ||
| echo "$BOOKS_SP" | bin/linkerd profile -n $booksns books --open-api - | kubectl apply -f - | ||
| echo "$WEBAPP_SP" | bin/linkerd profile -n $booksns webapp --open-api - | kubectl apply -f - | ||
| done | ||
|
|
||
| BOOKS_APP=$(curl -s https://raw.githubusercontent.com/BuoyantIO/booksapp/master/k8s/mysql-app.yml) | ||
|
|
||
| # add "-sleep=10ms" param to the traffic app (~100rps) | ||
| traffic_param=" - \"webapp:7000\"" | ||
| sleep_param=$(cat <<-END | ||
| - "-sleep=10ms" | ||
| - "webapp:7000" | ||
| END | ||
| ) | ||
| BOOKS_APP=$(echo "${BOOKS_APP/$traffic_param/$sleep_param}") | ||
|
|
||
| # inject | ||
| BOOKS_APP=$(echo "$BOOKS_APP" | $linkerd_path -l $linkerd_namespace inject -) | ||
|
|
||
| # deploy books apps to N namespaces | ||
| for i in $(eval echo {1..$NAMESPACES}); do | ||
| booksns=$linkerd_namespace-books-$i | ||
| echo "waiting for $booksns mysql-init to complete..." | ||
| kubectl -n $booksns wait --for=condition=complete --timeout=5m job/mysql-init | ||
|
|
||
| echo "$BOOKS_APP" | kubectl apply -n $booksns -f - | ||
| kubectl -n $booksns scale --replicas=$REPLICAS deploy/authors deploy/books deploy/webapp | ||
| done | ||
|
|
||
| # | ||
| # Deploy Emojivoto | ||
| # | ||
|
|
||
| EMOJIVOTO=$(curl -s https://run.linkerd.io/emojivoto.yml) | ||
|
|
||
| # delete namespace | ||
| EMOJIVOTO=$(echo "$EMOJIVOTO" | tail -n +6) | ||
| emojins="namespace: emojivoto" | ||
| EMOJIVOTO=$(echo "${EMOJIVOTO//$emojins/}") | ||
| emojins=".emojivoto:" | ||
| newns=":" | ||
| EMOJIVOTO=$(echo "${EMOJIVOTO//$emojins/$newns}") | ||
|
|
||
| # inject | ||
| EMOJIVOTO=$(echo "$EMOJIVOTO" | $linkerd_path -l $linkerd_namespace inject -) | ||
|
|
||
| for i in $(eval echo {1..$NAMESPACES}); do | ||
| emojins=$linkerd_namespace-emoji-$i | ||
|
|
||
| kubectl create ns $emojins | ||
| echo "$EMOJIVOTO" | kubectl apply -n $emojins -f - | ||
|
|
||
| kubectl -n $emojins scale --replicas=$REPLICAS deploy/emoji deploy/voting deploy/web | ||
| done | ||
|
|
||
| # | ||
| # Lifecyle / bb | ||
| # | ||
|
|
||
| LIFECYCLE=$(curl -s https://raw.githubusercontent.com/linkerd/linkerd-examples/master/lifecycle/lifecycle.yml) | ||
|
|
||
| # inject | ||
| LIFECYCLE=$(echo "$LIFECYCLE" | $linkerd_path -l $linkerd_namespace inject -) | ||
|
|
||
| for i in $(eval echo {1..$NAMESPACES}); do | ||
| lifecyclens=$linkerd_namespace-lifecycle-$i | ||
|
|
||
| kubectl create ns $lifecyclens | ||
| echo "$LIFECYCLE" | kubectl apply -n $lifecyclens -f - | ||
|
|
||
| kubectl -n $lifecyclens scale --replicas=$REPLICAS deploy/bb-broadcast deploy/bb-p2p deploy/bb-terminus | ||
| done | ||
|
|
||
| # | ||
| # Watch performance | ||
| # | ||
|
|
||
| watch $linkerd_path -l $linkerd_namespace stat ns | ||
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.
Because of
set -eu, if no args args are provided to the script it fails at line 50 without a chance to output the usage message.