forked from layer5io/meshery-performance-action
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mesheryctl.sh
150 lines (137 loc) · 4.11 KB
/
mesheryctl.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/usr/bin/env bash
SCRIPT_DIR=$(dirname -- "$(readlink -f "${BASH_SOURCE[0]}" || realpath "${BASH_SOURCE[0]}")")
declare -A adapters
adapters["istio"]=meshery-istio:10000
adapters["linkerd"]=meshery-linkerd:10001
adapters["consul"]=meshery-consul:10002
adapters["network_service_mesh"]=meshery-nsm:10004
adapters["kuma"]=meshery-kuma:10007
adapters["open_service_mesh"]=meshery-osm:10009
adapters["traefik_mesh"]=meshery-traefik-mesh:10006
main() {
local perf_filename=
local perf_profile_name=
local endpoint_url=
local service_mesh=
local test_name=
local load_generator=
parse_command_line "$@"
# perform the test given in the provided profile_id
if [ -z "$perf_filename" ]
then
# 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 '"')
echo "Checking service mesh list from given profile..."
#echo $service_mesh
if [[ -n $service_mesh ]]
then
echo "Service mesh is present from profile."
shortName=$(echo ${adapters[$service_mesh]} | cut -d ':' -f1)
echo $shortName
shortName=${shortName#meshery-} #remove the prefix "meshery-"
if [[ -z $shortName ]]
then
echo "'shortName' value is empty. Provide a valid profile containing with service mesh name, else contact us to raise an issue!"
exit 1
else
docker network connect bridge meshery_meshery-"$shortName"_1
docker network connect minikube meshery_meshery-"$shortName"_1
fi
docker network connect bridge meshery_meshery_1
docker network connect minikube meshery_meshery_1
mesheryctl system config minikube -t ~/auth.json
else
echo "Service mesh not found from profile. Invalid profile name has been provided"
exit 1
fi
#rand_string=$(openssl rand -hex 3)
#perf_profile_name="$rand_string-$perf_profile_name"
echo "Running test with performance profile $perf_profile_name"
mesheryctl perf apply $perf_profile_name -t ~/auth.json --yes
else
echo "Executing from given test config file..."
#echo $service_mesh
shortName=$(echo ${adapters[$service_mesh]} | cut -d ':' -f1)
shortName=${shortName#meshery-} #remove the prefix "meshery-"
docker network connect bridge meshery_meshery-"$shortName"_1
docker network connect minikube meshery_meshery-"$shortName"_1
docker network connect bridge meshery_meshery_1
docker network connect minikube meshery_meshery_1
mesheryctl system config minikube -t ~/auth.json
perf_profile_name="smp-$perf_profile_name"
echo "Configuration file: $perf_filename"
echo "Endpoint URL: $endpoint_url"
echo "Service Mesh: $service_mesh"
echo "Test Name: $test_name"
echo "Load Generator: $load_generator"
echo "Profile name: $perf_profile_name"
echo "Running test with test configuration file $perf_filename"
mesheryctl perf apply --file $GITHUB_WORKSPACE/.github/$perf_filename -t ~/auth.json --url "$endpoint_url" --mesh "$service_mesh" --name "$test_name" --load-generator "$load_generator" $perf_profile_name -y
fi
}
parse_command_line() {
while :
do
case "${1:-}" in
--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-id' cannot be empty." >&2
exit 1
fi
;;
--endpoint-url)
if [[ -n "${2:-}" ]]; then
endpoint_url=$2
shift
else
echo "ERROR: '--endpoint-url' cannot be empty." >&2
exit 1
fi
;;
--service-mesh)
if [[ -n "${2:-}" ]]; then
service_mesh=$2
shift
else
echo "ERROR: '--service-mesh' cannot be empty." >&2
exit 1
fi
;;
--test-name)
if [[ -n "${2:-}" ]]; then
test_name=$2
shift
else
echo "ERROR: '--test-name' cannot be empty." >&2
exit 1
fi
;;
--load-generator)
if [[ -n "${2:-}" ]]; then
load_generator=$2
shift
else
echo "ERROR: '--load-generator' cannot be empty." >&2
exit 1
fi
;;
*)
break
;;
esac
shift
done
}
main "$@"