Skip to content
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

[Feature] run a performance test using profile name #6

Merged
merged 6 commits into from
Aug 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ inputs:
default: docker
profile_filename:
description: "Name of the file containing SMP profile"
required: true
profile_name:
description: "Name of the performance profile"

runs:
using: "node12"
Expand Down
16 changes: 6 additions & 10 deletions main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,22 @@ main() {
setupArgs+=(--platform ${INPUT_PLATFORM})
fi

#if [[ -n "${INPUT_SERVICE_MESH:-}" ]]; then
# setupArgs+=(--service-mesh ${INPUT_SERVICE_MESH})
#fi

"$SCRIPT_DIR/meshery.sh" "${setupArgs[@]}"

commandArgs=()
#if [[ -n "${INPUT_SERVICE_MESH:-}" ]]; then
# commandArgs+=(--service-mesh ${INPUT_SERVICE_MESH})
#fi

if [[ -n "${INPUT_PROFILE_FILENAME:-}" ]]; then
commandArgs+=(--profile-name ${INPUT_PROFILE_FILENAME})
commandArgs=(--perf-filename ${INPUT_PROFILE_FILENAME})
fi

if [[ -n "${INPUT_PROFILE_NAME:-}" ]]; then
commandArgs=(--profile-name ${INPUT_PROFILE_NAME})
fi

"$SCRIPT_DIR/mesheryctl.sh" "${commandArgs[@]}"
}

get_dependencies() {
sudo wget https://github.com/mikefarah/yq/releases/download/v4.10.0/yq_linux_amd64 -O /usr/bin/yq --quiet
sudo wget https://github.com/mikefarah/yq/releases/download/v4.10.0/yq_linux_amd64 -O /usr/bin/yq --quiet
sudo chmod +x /usr/bin/yq
}

Expand Down
7 changes: 5 additions & 2 deletions meshery.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

SCRIPT_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}" || realpath "${BASH_SOURCE[0]}")")

main() {
Expand All @@ -10,8 +14,7 @@ main() {
parse_command_line "$@"

echo "Checking if a k8s cluster exits..."
kubectl config current-context
if [[ $? -eq 0 ]]
if kubectl config current-context
then
echo "Cluster found"
else
Expand Down
67 changes: 43 additions & 24 deletions mesheryctl.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,50 +7,69 @@ adapters["istio"]=meshery-istio:10000
adapters["linkerd"]=meshery-linkerd:10001
adapters["consul"]=meshery-consul:10002
adapters["octarine"]=meshery-octarine:10003
adapters["nsm"]=meshery-nsm:10004
adapters["network_service_mesh"]=meshery-nsm:10004
adapters["kuma"]=meshery-kuma:10007
adapters["cpx"]=meshery-cpx:10008
adapters["osm"]=meshery-osm:10009
adapters["traefik-mesh"]=meshery-traefik-mesh:10006
adapters["open_service_mesh"]=meshery-osm:10009
adapters["traefik_mesh"]=meshery-traefik-mesh:10006

main() {
#local service_mesh_adapter=
#local service_mesh=
local perf_filename=
local perf_profile_name=

parse_command_line "$@"
#docker network connect bridge meshery_meshery_1
#docker network connect minikube meshery_meshery_1
#docker network connect minikube meshery_meshery-"$service_mesh"_1
#docker network connect bridge meshery_meshery-"$service_mesh"_1

mesheryctl system config minikube -t ~/auth.json
#echo $spec $service_mesh_adapter
# perform the test given in the provided profile_id
if [ -z "$perf_profile_name" ]
then

mesheryctl perf apply --file $GITHUB_WORKSPACE/.github/$perf_profile_name -t ~/auth.json
mesheryctl perf apply --file $GITHUB_WORKSPACE/.github/$perf_filename -t ~/auth.json

else

# get the mesh name from performance test config
service_mesh=$(mesheryctl perf view $perf_profile_name -t ~/auth.json -o json 2>&1 | jq '."service_mesh"' | tr -d '"')

# deploy the mentioned service mesh if needed
if [[ $service_mesh != "null" ]]
then

shortName=$(echo ${adapters["$service_mesh"]} | cut -d '-' -f2 | cut -d ':' -f1)

docker network connect bridge meshery_meshery_1
docker network connect minikube meshery_meshery_1
docker network connect bridge meshery_meshery-"$shortName"_1
docker network connect minikube meshery_meshery-"$shortName"_1

mesheryctl system config minikube -t ~/auth.json

mesheryctl mesh deploy --adapter ${adapters["$service_mesh"]} -t ~/auth.json "$service_mesh" --watch

fi
mesheryctl perf apply $perf_profile_name -t ~/auth.json

fi
}

parse_command_line() {
while :
do
case "${1:-}" in
#--service-mesh)
# if [[ -n "${2:-}" ]]; then
# # figure out assigning port numbers and adapter names
# service_mesh=$2
# service_mesh_adapter=${adapters["$2"]}
# shift
# else
# echo "ERROR: '--service-mesh' cannot be empty." >&2
# exit 1
# fi
# ;;
--perf-filename)
if [[ -n "${2:-}" ]]; then
perf_filename=$2
shift
else
echo "ERROR: '--profile-name' cannot be empty." >&2
exit 1
fi
;;
--profile-name)
if [[ -n "${2:-}" ]]; then
perf_profile_name=$2
shift
else
echo "ERROR: '--profile-name' cannot be empty." >&2
echo "ERROR: '--profile-id' cannot be empty." >&2
exit 1
fi
;;
Expand Down