|
@@ -86,15 +86,6 @@ do
|
86
|
86
|
done
|
87
|
87
|
|
88
|
88
|
|
89
|
|
-logdir="/tmp/lodel2_cbl_logs"
|
90
|
|
-if [ -d "$logdir" ]
|
91
|
|
-then
|
92
|
|
- echo "WARNING : $logdir allready exists. It's a better idea to delete it before running this script again"
|
93
|
|
- echo "waiting 3s"
|
94
|
|
- sleep 3
|
95
|
|
-fi
|
96
|
|
-mkdir -p $logdir
|
97
|
|
-
|
98
|
89
|
#curl_options='--silent -o /dev/null -s -w %{http_code}:%{time_connect}:%{time_starttransfer}:%{time_total}\n'
|
99
|
90
|
curl_options='--silent -o /dev/null -s -w %{url_effective};%{http_code};%{time_connect};%{time_starttransfer};%{time_total}\n'
|
100
|
91
|
curl_debug_opt='-v -w %{url_effective};%{http_code};%{time_connect};%{time_starttransfer};%{time_total}\n'
|
|
@@ -128,9 +119,14 @@ mass_creation() {
|
128
|
119
|
instance_name=$1
|
129
|
120
|
iteration_count=$2
|
130
|
121
|
base_uri=$(_base_uri $1)
|
131
|
|
- logfile="$logdir/mass_creation_${instance_name}.log"
|
132
|
122
|
cls_list_file=$(fetch_all_classes $1)
|
133
|
123
|
|
|
124
|
+ if [ -z "$(cat $cls_list_file)" ]
|
|
125
|
+ then
|
|
126
|
+ echo "Failed to fetch class list for instance $1. Abording..." >&2
|
|
127
|
+ exit
|
|
128
|
+ fi
|
|
129
|
+
|
134
|
130
|
if [ "$iteration_count" -le "0" ]
|
135
|
131
|
then
|
136
|
132
|
return
|
|
@@ -139,10 +135,9 @@ mass_creation() {
|
139
|
135
|
for i in $(seq $iteration_count)
|
140
|
136
|
do
|
141
|
137
|
cls=$(shuf -n1 $cls_list_file)
|
142
|
|
- $curcurl -d "$(curl_opt_create_$cls)" "${base_uri}$(uri_create $cls)" | tee -a $logfile
|
|
138
|
+ echo "${base_uri}$(uri_create $cls) POST $(curl_opt_create_$cls)"
|
143
|
139
|
done
|
144
|
|
-
|
145
|
|
- rm -v $cls_list_file
|
|
140
|
+ rm -v $cls_list_file >&2
|
146
|
141
|
}
|
147
|
142
|
|
148
|
143
|
mass_link_edit() {
|
|
@@ -152,7 +147,6 @@ mass_link_edit() {
|
152
|
147
|
instance_name=$1
|
153
|
148
|
iteration_count=$2
|
154
|
149
|
base_uri=$(_base_uri $1)
|
155
|
|
- logfile="$logdir/mass_link_edit_${instance_name}.log"
|
156
|
150
|
cls_list_file=$(fetch_all_classes $1)
|
157
|
151
|
|
158
|
152
|
for cls in $(cat $cls_list_file)
|
|
@@ -171,7 +165,7 @@ mass_link_edit() {
|
171
|
165
|
ltext_count=$(shuf -i1-5 -n1)
|
172
|
166
|
alias_param=$(head -n $(expr $alias_count \* $i) $person_ids| tail -n$alias_count|tr -s "\n" "," | sed 's/,$//')
|
173
|
167
|
txt_param=$(head -n $(expr $ltext_count \* $i) $text_ids | tail -n$ltext_count|tr -s "\n" "," | sed 's/,$//')
|
174
|
|
- $curcurl -d "$(curl_opt_create_$cls $alias_param $txt_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
|
|
168
|
+ echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $alias_param $txt_param)&uid=$cur_id"
|
175
|
169
|
done
|
176
|
170
|
rm -v $text_ids $person_ids $section_ids $subsection_ids
|
177
|
171
|
;;
|
|
@@ -184,7 +178,7 @@ mass_link_edit() {
|
184
|
178
|
cur_id=$(shuf -n1 $collections_ids)
|
185
|
179
|
publications_count=$(shuf -i1-5 -n1)
|
186
|
180
|
publication_param=$(head -n $(expr $publications_count \* $i) $publication_ids| tail -n$publications_count|tr -s "\n" ",")
|
187
|
|
- $curcurl -d "$(curl_opt_create_$cls $publication_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
|
|
181
|
+ echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $publication_param)&uid=$cur_id"
|
188
|
182
|
done
|
189
|
183
|
rm -v $collections_ids $publication_ids
|
190
|
184
|
;;
|
|
@@ -197,9 +191,9 @@ mass_link_edit() {
|
197
|
191
|
cur_id=$(shuf -n1 $publication_ids)
|
198
|
192
|
collections_count=$(shuf -i1-5 -n1)
|
199
|
193
|
collection_param=$(head -n $(expr $collections_count \* $i) $collection_ids| tail -n$collections_count|tr -s "\n" ",")
|
200
|
|
- $curcurl -d "$(curl_opt_create_$cls $collection_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
|
|
194
|
+ echo "$base_uri/admin.update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $collection_param)&uid=$cur_id"
|
201
|
195
|
done
|
202
|
|
- rm -v $publication_ids $collection_ids
|
|
196
|
+ rm -v $publication_ids $collection_ids >&2
|
203
|
197
|
;;
|
204
|
198
|
|
205
|
199
|
Section)
|
|
@@ -213,9 +207,9 @@ mass_link_edit() {
|
213
|
207
|
person_count=$(shuf -i1-5 -n1)
|
214
|
208
|
child_param=$(head -n $(expr $child_count \* $i) $child_ids| tail -n$child_count|tr -s "\n" ",")
|
215
|
209
|
person_param=$(head -n $(expr $person_count \* $i) $person_ids| tail -n$person_count|tr -s "\n" ",")
|
216
|
|
- $curcurl -d "$(curl_opt_create_$cls $child_param $person_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
|
|
210
|
+ echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $child_param $person_param)&uid=$cur_id"
|
217
|
211
|
done
|
218
|
|
- rm -v $section_ids $child_ids $person_ids
|
|
212
|
+ rm -v $section_ids $child_ids $person_ids >&2
|
219
|
213
|
;;
|
220
|
214
|
|
221
|
215
|
Subsection)
|
|
@@ -234,16 +228,16 @@ mass_link_edit() {
|
234
|
228
|
child_param=$(head -n $(expr $child_count \* $i) $child_ids| tail -n$child_count|tr -s "\n" ",")
|
235
|
229
|
parent_param=$(head -n $(expr $parent_count \* $i) $parent_ids| tail -n$parent_count|tr -s "\n" ",")
|
236
|
230
|
person_param=$(head -n $(expr $person_count \* $i) $persons_ids| tail -n$person_count|tr -s "\n" ",")
|
237
|
|
- $curcurl -d "$(curl_opt_create_$cls $child_param $person_param $parent_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
|
|
231
|
+ echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $child_param $person_param $parent_param)&uid=$cur_id"
|
238
|
232
|
done
|
239
|
|
- rm -v $subsection_ids $parent_ids $section_ids $persons_ids
|
|
233
|
+ rm -v $subsection_ids $parent_ids $section_ids $persons_ids >&2
|
240
|
234
|
;;
|
241
|
235
|
*)
|
242
|
236
|
;;
|
243
|
237
|
|
244
|
238
|
esac
|
245
|
239
|
done
|
246
|
|
- rm -v $cls_list_file
|
|
240
|
+ rm -v $cls_list_file >&2
|
247
|
241
|
}
|
248
|
242
|
|
249
|
243
|
mass_deletion() {
|
|
@@ -253,7 +247,6 @@ mass_deletion() {
|
253
|
247
|
instance_name=$1
|
254
|
248
|
iteration_count=$2
|
255
|
249
|
base_uri=$(_base_uri $1)
|
256
|
|
- logfile="$logdir/mass_deletion_${instance_name}.log"
|
257
|
250
|
cls_list_file=$(fetch_all_classes $1)
|
258
|
251
|
|
259
|
252
|
for cls in $(cat $cls_list_file)
|
|
@@ -269,7 +262,7 @@ mass_deletion() {
|
269
|
262
|
for i in $(seq $max_iter)
|
270
|
263
|
do
|
271
|
264
|
id=$(tail -n $i $id_list_file | head -n1)
|
272
|
|
- $curcurl "${base_uri}/admin/delete?classname=$cls&lodel_id=$id" | tee -a $logfile
|
|
265
|
+ echo "${base_uri}/admin/delete?classname=$cls&lodel_id=$id"
|
273
|
266
|
done
|
274
|
267
|
rm -v $id_list_file
|
275
|
268
|
done
|
|
@@ -281,6 +274,13 @@ fetch_all_classes() {
|
281
|
274
|
#$1 is intance name
|
282
|
275
|
cls_list_file=$($cmktemp)
|
283
|
276
|
$curl_raw "$(_base_uri $1)/list_classes" | grep -v Abstract |sed -nE 's/^ *<li> +<a href="show_class([^"]+)".*$/\1/p'|cut -d"=" -f2 > $cls_list_file
|
|
277
|
+ if [ -z "$(cat $cls_list_file)" ]
|
|
278
|
+ then
|
|
279
|
+ echo "Unable to fetch class list for $1" >&2
|
|
280
|
+ echo "Request was : $curl_raw '$(_base_uri $1)/list_classes'" >&2
|
|
281
|
+ rm $cls_list_file
|
|
282
|
+ exit 1
|
|
283
|
+ fi
|
284
|
284
|
echo $cls_list_file
|
285
|
285
|
}
|
286
|
286
|
|
|
@@ -353,10 +353,30 @@ run_bg_with_param() {
|
353
|
353
|
rm -v $pidlist
|
354
|
354
|
}
|
355
|
355
|
|
356
|
|
-run_bg_with_param "mass_creation" $instance_list $n_create
|
357
|
|
-run_bg_with_param "mass_link_edit" $instance_list $n_edit
|
358
|
|
-run_bg_with_param "mass_deletion" $instance_list $n_delete
|
|
356
|
+get_queries_with_params() {
|
|
357
|
+ #$1 is the function name to run
|
|
358
|
+ #$2 is the instance_list filename
|
|
359
|
+ #other parameters are given to the function
|
|
360
|
+ fun=$1
|
|
361
|
+ instance_list=$2
|
|
362
|
+ shift;shift
|
|
363
|
+ counter=0
|
|
364
|
+ for iname in $(cat $instance_list| sort)
|
|
365
|
+ do
|
|
366
|
+ echo "Running $fun $iname $@" >&2
|
|
367
|
+ beg=$(date "+%s")
|
|
368
|
+ $fun $iname $@
|
|
369
|
+ tsecs=$(expr $(date "+%s") - $beg)
|
|
370
|
+ left=$(expr $(cat $instance_list |wc -l) - $counter)
|
|
371
|
+ counter=$(expr $counter + 1)
|
|
372
|
+ tleft=$(expr $left \* $tsecs)
|
|
373
|
+ percent_done=$(echo "2k ${counter}.0 100.0 * $(cat $instance_list |wc -l).0 2k/ f" | dc)
|
|
374
|
+ echo -e "Done in ${tsecs}s\t$fun ${percent_done}% done ~$tleft secs" >&2
|
|
375
|
+
|
|
376
|
+ done | shuf
|
|
377
|
+}
|
359
|
378
|
|
360
|
|
-echo ""
|
361
|
|
-echo "Logs can be found in $logdir"
|
|
379
|
+get_queries_with_params "mass_creation" $instance_list $n_create
|
|
380
|
+get_queries_with_params "mass_link_edit" $instance_list $n_edit
|
|
381
|
+get_queries_with_params "mass_deletion" $instance_list $n_delete
|
362
|
382
|
|