diff --git a/action.yml b/action.yml index 2e7f671..39e3d46 100644 --- a/action.yml +++ b/action.yml @@ -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" diff --git a/main.sh b/main.sh index b601ced..7f2d540 100755 --- a/main.sh +++ b/main.sh @@ -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 } diff --git a/meshery.sh b/meshery.sh index c59b8e5..9701a05 100755 --- a/meshery.sh +++ b/meshery.sh @@ -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() { @@ -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 diff --git a/mesheryctl.sh b/mesheryctl.sh index 2eea8bc..cb510b4 100755 --- a/mesheryctl.sh +++ b/mesheryctl.sh @@ -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 ;;