Skip to content

Commit

Permalink
Merge pull request #6 from DelusionalOptimist/perf-profile-name
Browse files Browse the repository at this point in the history
  • Loading branch information
leecalcote authored Aug 4, 2021
2 parents 57ba78c + f8a8192 commit dd42345
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 37 deletions.
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

0 comments on commit dd42345

Please sign in to comment.