Browse Source

Changes name of create_datas

prieto 8 years ago
parent
commit
2e5d9e10d6
2 changed files with 505 additions and 0 deletions
  1. 0
    0
      progs/create_datas_simpleem.sh
  2. 505
    0
      scripts/cbl_em2.sh

progs/create_datas.sh → progs/create_datas_simpleem.sh View File


+ 505
- 0
scripts/cbl_em2.sh View File

@@ -0,0 +1,505 @@
1
+#!/bin/bash
2
+#
3
+# CBL : Curl Benchmark on Lodel
4
+#
5
+# Usage : $0 [HOSTNAME] [INSTANCE_LIST_FILE] [N_CREATE] [N_EDIT] [N_DELETE]
6
+#
7
+# Instance_list_file is expected to be a file containing instances name (1 per
8
+# line). Uses by default /tmp/lodel2_instance_list.txt
9
+#
10
+# Instances base URL are generated given the current webui implementation :
11
+# http://HOST/INSTANCE_NAME/
12
+#
13
+#
14
+# Scenario description :
15
+#
16
+# mass_creation instance_name iteration_count :
17
+#	Create iteration_count time a random leobject in given instance_name
18
+#	note : do note create relation between objects, only populate content
19
+#	
20
+#	step 1 : fetch all non abstract class name
21
+# 	step 2 : loop on creation (using bash function curl_opt_create_CLSNAME)
22
+#		that return the POST fields (populated with random values)
23
+#
24
+# mass_deletion instance_name iteration_count :
25
+#	Foreach non asbtracty class delete iteration_count time an object of
26
+#	current class in current instance
27
+#
28
+#	step 1 : fetch all non abstract class name
29
+#	step 2 : loop on non abstract class name
30
+#	step 3 : loop iteration_count time on deletion
31
+#
32
+# mass_link_edit instance_name iteration_count :
33
+#	Foreach non abstract class make iteration_count time edition of an
34
+#	object in current class
35
+#	note : only implemented for Person for the moment
36
+#	note : can maybe ask for invalid modifications
37
+#
38
+#	step 1 : fetch all non abstract class name
39
+#	step 2 : loop on non abstract class name
40
+#	step 3 : depends on curent class :
41
+#		- fetch all existing id of current class
42
+#		- fetch all existing id in class that can be linked with
43
+#		  current class
44
+#	step 4 : loop iteration_count time :
45
+#		- choose a random id in current class
46
+#		- choose random ids from linkable classes
47
+#		- trigger edition using curl (with datas from the same
48
+#		  bash function than creation : curl_opt_create_CLSNAME)
49
+#
50
+# Current way to run scenarios :
51
+#
52
+# using the function run_bg_with_param FUNCTION_NAME INSTANCE_LIST_FILE *ARGS
53
+#
54
+# The function name can be one of the scenario functions
55
+# INSTANCE_LIST_FILE is the file containing instances list
56
+# *ARGS are args given as it to FUNCTION_NAME after the instance_name argument
57
+#
58
+# function call : FUN_NAME INSTANCE_NAME *ARGS
59
+#
60
+# The run_bg_with_param run a scenario in background for each instance allowing
61
+# to send a lot of request at the same time
62
+#
63
+#
64
+
65
+usage() {
66
+	echo "Usage : $0 [HOSTNAME] [INSTANCE_LIST_FILE] [CREATE_COUNT] [EDIT_COUNT] [DELETE_COUNT]"
67
+	exit
68
+}
69
+
70
+host=$1
71
+host=${host:=localhost}
72
+instance_list=$2
73
+instance_list=${instance_list:=/tmp/lodel2_instance_list.txt}
74
+#A modifier for requests count
75
+n_create=$3
76
+n_create=${n_create:=50}
77
+n_edit=$4
78
+n_edit=${n_edit:=10}
79
+n_delete=$5
80
+n_delete=${n_delete:=10}
81
+
82
+for i in $(seq $#)
83
+do
84
+	echo $1 |grep -E "^-?-h" &>/dev/null
85
+	shift
86
+done
87
+logdir="/tmp/lodel2_cbl_logs"
88
+if [ -d "$logdir" ]
89
+then
90
+	echo "WARNING : $logdir allready exists. It's a better idea to delete it before running this script again"
91
+	echo "waiting 3s"
92
+	sleep 3
93
+fi
94
+mkdir -p $logdir
95
+
96
+#curl_options='--silent -o /dev/null -s -w %{http_code}:%{time_connect}:%{time_starttransfer}:%{time_total}\n'
97
+curl_options='--silent -o /dev/null -s -w %{url_effective};%{http_code};%{time_connect};%{time_starttransfer};%{time_total}\n'
98
+curl_debug_opt='-v -w %{url_effective};%{http_code};%{time_connect};%{time_starttransfer};%{time_total}\n'
99
+curl_cmd="curl $curl_options"
100
+curl_raw="curl --silent"
101
+curl_debug="curl $curl_debug_opt"
102
+
103
+curcurl="$curl_cmd"
104
+
105
+cmktemp="mktemp -t lodel2_cbl_XXXXXXXX"
106
+
107
+_base_uri() {
108
+	echo -n "http://$host/$1"
109
+}
110
+
111
+rnd_str() {
112
+	len=$1
113
+	cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $len | head -n 1
114
+}
115
+
116
+rnd_str_len() {
117
+	minlen=$1
118
+	maxlen=$2
119
+	cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w $(shuf -i${minlen}-${maxlen} -n1) | head -n 1
120
+}
121
+
122
+rnd_date() {
123
+    M=$(shuf -e '01' '02' '03' '04' '05' '06' '07' '08' '09' '10' '11' '12' | head -n 1)
124
+    JJ=$(shuf -e '01' '02' '03' '04' '05' '06' '07' '08' '09' '10' '11' '12' '13' '14' '15' '16' '17' '18' '19' '20' '21' '22' '23' '24' '25' '26' '27' '28'  | head -n 1)
125
+    AA=$(shuf -e '2012' '2005' '2010' '2015' '2016'| head -n 1)
126
+    echo -n "$AA-$M-$JJ"
127
+}
128
+
129
+mass_creation() {
130
+	#mass creation scenario
131
+	#$1 is instance name
132
+	#$2 is iteration count (1 iteration is 1 creation of a random class)
133
+	instance_name=$1
134
+	iteration_count=$2
135
+	base_uri=$(_base_uri $1)
136
+    logfile="$logdir/mass_creation_${instance_name}.log"
137
+	cls_list_file=$(fetch_all_classes $1)
138
+
139
+	if [ -z "$(cat $cls_list_file)" ]
140
+	then
141
+		echo "Failed to fetch class list for instance $1. Abording..." >&2
142
+		exit
143
+	fi
144
+
145
+	if [ "$iteration_count" -le "0" ]
146
+	then
147
+		return
148
+	fi
149
+
150
+	for i in $(seq $iteration_count)
151
+	do
152
+		cls=$(shuf -n1 $cls_list_file)
153
+        $curcurl -d "$(curl_opt_create_$cls)" "${base_uri}$(uri_create $cls)" | tee -a $logfile
154
+		# echo "${base_uri}$(uri_create $cls) POST $(curl_opt_create_$cls)"
155
+	done
156
+	rm -v $cls_list_file >&2
157
+}
158
+
159
+mass_link_edit() {
160
+	#mass linking & edition scenario
161
+	#$1 is instance name
162
+	#$2 is iteration count
163
+	instance_name=$1
164
+	iteration_count=$2
165
+	base_uri=$(_base_uri $1)
166
+    logfile="$logdir/mass_link_edit_${instance_name}.log"
167
+	cls_list_file=$(fetch_all_classes $1)
168
+
169
+	for cls in $(cat $cls_list_file)
170
+	do
171
+		case $cls in
172
+            Entry)
173
+                entries_ids=$(fetch_all_ids $1 Entry)
174
+                articles_ids=$(fetch_all_ids $1 Article)
175
+				reviews_ids=$(fetch_all_ids $1 Review)
176
+				text_ids=$($cmktemp)
177
+				cat $articles_ids $reviews_ids | shuf > $text_ids
178
+				for i in $(seq $iteration_count)
179
+				do
180
+					cur_id=$(shuf -n1 $entries_ids)
181
+					ltext_count=$(shuf -i1-5 -n1)
182
+					txt_param=$(head -n $(expr $ltext_count \* $i) $text_ids | tail -n$ltext_count|tr -s "\n" "," | sed 's/,$//')
183
+					role=$(shuf -e 'geography' 'subject' | head -n 1)
184
+					$curcurl -d "$(curl_opt_create_$cls  $txt_param $role)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
185
+                    #echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $txt_param $role)&uid=$cur_id"| tee -a $logfile
186
+				done
187
+				rm -v $text_ids $entries_ids $reviews_ids $articles_ids
188
+				;;
189
+                
190
+			Person)
191
+				person_ids=$(fetch_all_ids $1 Person)
192
+				issues_ids=$(fetch_all_ids $1 Issue)
193
+				parts_ids=$(fetch_all_ids $1 Part)
194
+				publication_ids=$($cmktemp)
195
+				cat $issues_ids $parts_ids | shuf > $publication_ids
196
+                articles_ids=$(fetch_all_ids $1 Article)
197
+				reviews_ids=$(fetch_all_ids $1 Review)
198
+				text_ids=$($cmktemp)
199
+				cat $articles_ids $reviews_ids | shuf > $text_ids
200
+				for i in $(seq $iteration_count)
201
+				do
202
+					cur_id=$(shuf -n1 $person_ids)
203
+					pub_count=$(shuf -i1-5 -n1)
204
+					ltext_count=$(shuf -i1-5 -n1)
205
+					pub_param=$(head -n $(expr $ltext_count \* $i) $publication_ids | tail -n$pub_count|tr -s "\n" "," | sed 's/,$//')
206
+					txt_param=$(head -n $(expr $ltext_count \* $i) $text_ids | tail -n$ltext_count|tr -s "\n" "," | sed 's/,$//')
207
+                    $curcurl -d "$(curl_opt_create_$cls  $txt_param $pub_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
208
+					#echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $txt_param $pub_param)&uid=$cur_id"
209
+				done
210
+				rm -v $parts_ids $text_ids $person_ids $issues_ids $reviews_ids $articles_ids $publication_ids
211
+				;;
212
+            
213
+            Collection)
214
+                collections_ids=$(fetch_all_ids $1 Collection)
215
+                issues_ids=$(fetch_all_ids $1 Issue)
216
+                persons_ids=$(fetch_all_ids $1 Person)
217
+                for i in $(seq $iteration_count)
218
+                do
219
+                    cur_id=$(shuf -n1 $collections_ids)
220
+                    publications_count=$(shuf -i1-5 -n1)
221
+                    persons_count=$(shuf -i1-5 -n1)
222
+                    publication_param=$(head -n $(expr $publications_count \* $i) $issues_ids| tail -n$publications_count|tr -s "\n" ",")
223
+                    person_param=$(head -n $(expr $persons_count \* $i) $persons_ids| tail -n$persons_count|tr -s "\n" ",")
224
+                    $curcurl -d "$(curl_opt_create_$cls $person_param $publication_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
225
+		            #echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $person_param $publication_param)&uid=$cur_id"
226
+                done
227
+                rm -v $collections_ids $issues_ids $persons_ids
228
+                ;;
229
+
230
+            Issue)
231
+                issues_ids=$(fetch_all_ids $1 Issue)
232
+                parts_ids=$(fetch_all_ids $1 Part)
233
+                collection_ids=$(fetch_all_ids $1 Collection)
234
+                persons_ids=$(fetch_all_ids $1 Person)
235
+                reviews_ids=$(fetch_all_ids $1 Review)
236
+                articles_ids=$(fetch_all_ids $1 Article)
237
+                text_ids=$($cmktemp)
238
+				cat $articles_ids $reviews_ids | shuf > $text_ids
239
+                for i in $(seq $iteration_count)
240
+                do
241
+                    cur_id=$(shuf -n1 $issues_ids)
242
+                    collections_count=1
243
+                    collection_param=$(head -n $(expr $collections_count \* $i) $collection_ids| tail -n$collections_count|tr -s "\n")
244
+                    persons_count=$(shuf -i1-5 -n1)
245
+                    person_param=$(head -n $(expr $persons_count \* $i) $persons_ids| tail -n$persons_count|tr -s "\n" ",")
246
+                    parts_count=$(shuf -i1-5 -n1)
247
+                    parts_param=$(head -n $(expr $parts_count \* $i) $parts_ids| tail -n$parts_count|tr -s "\n" ",")
248
+                    ltext_count=$(shuf -i1-5 -n1)
249
+                    txt_param=$(head -n $(expr $ltext_count \* $i) $text_ids | tail -n$ltext_count|tr -s "\n" "," | sed 's/,$//')
250
+                    $curcurl -d "$(curl_opt_create_$cls $person_param $collection_param $parts_param $txt_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
251
+		            #echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $person_param $collection_param $parts_param)&uid=$cur_id"
252
+                done
253
+                rm -v $persons_ids $collection_ids $issues_ids $parts_ids $reviews_ids $articles_ids $text_ids >&2
254
+                ;;
255
+			
256
+			Part)
257
+                issues_ids=$(fetch_all_ids $1 Issue)
258
+                parts_ids=$(fetch_all_ids $1 Part)
259
+                containers_ids=$($cmktemp)
260
+				cat $issues_ids $parts_ids | shuf > $containers_ids
261
+                person_ids=$(fetch_all_ids $1 Person)
262
+                reviews_ids=$(fetch_all_ids $1 Review)
263
+                articles_ids=$(fetch_all_ids $1 Article)
264
+                text_ids=$($cmktemp)
265
+				cat $articles_ids $reviews_ids | shuf > $text_ids
266
+                for i in $(seq $iteration_count)
267
+                do
268
+                    cur_id=$(shuf -n1 $parts_ids)
269
+                    container_count=1
270
+                    person_count=$(shuf -i1-5 -n1)
271
+                    container_param=$(head -n $(expr $container_count \* $i) $containers_ids| tail -n$container_count|tr -s "\n")
272
+                    person_param=$(head -n $(expr $person_count \* $i) $person_ids| tail -n$person_count|tr -s "\n" ",")
273
+                    ltext_count=$(shuf -i1-5 -n1)
274
+                    txt_param=$(head -n $(expr $ltext_count \* $i) $text_ids | tail -n$ltext_count|tr -s "\n" "," | sed 's/,$//')
275
+                    linked_part=''
276
+                    $curcurl -d "$(curl_opt_create_$cls $person_param $container_param $linked_part $txt_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
277
+		            #echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $person_param $container_param $linked_part $txt_param)&uid=$cur_id"
278
+                done
279
+                rm -v $containers_ids $text_ids $person_ids $issues_ids $parts_ids $reviews_ids $articles_ids >&2
280
+                ;;
281
+                
282
+            Article)
283
+                articles_ids=$(fetch_all_ids $1 Article)
284
+                entries_ids=$(fetch_all_ids $1 Entry)
285
+                issues_ids=$(fetch_all_ids $1 Issue)
286
+                parts_ids=$(fetch_all_ids $1 Part)
287
+                containers_ids=$($cmktemp)
288
+				cat $issues_ids $parts_ids | shuf > $containers_ids
289
+                persons_ids=$(fetch_all_ids $1 Person)
290
+                for i in $(seq $iteration_count)
291
+                do
292
+                    cur_id=$(shuf -n1 $articles_ids)
293
+                    entries_count=$(shuf -i1-10 -n1)
294
+                    containers_count=1
295
+                    person_count=$(shuf -i1-5 -n1)
296
+                    entries_param=$(head -n $(expr $entries_count \* $i) $entries_ids| tail -n$entries_count|tr -s "\n" ",")
297
+                    container_param=$(head -n $(expr $containers_count \* $i) $containers_ids| tail -n$containers_count|tr -s "\n")
298
+                    person_param=$(head -n $(expr $person_count \* $i) $persons_ids| tail -n$person_count|tr -s "\n" ",")
299
+                    $curcurl -d "$(curl_opt_create_$cls $entries_param $person_param $container_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
300
+		            #echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $entries_param $person_param $container_param)&uid=$cur_id"
301
+                done
302
+                rm -v $articles_ids $entries_ids $issues_ids $persons_ids $parts_ids $containers_ids >&2
303
+                ;;
304
+                
305
+            Review)
306
+                reviews_ids=$(fetch_all_ids $1 Review)
307
+                entries_ids=$(fetch_all_ids $1 Entry)
308
+                issues_id=$(fetch_all_ids $1 Issue)
309
+                parts_id=$(fetch_all_ids $1 Part)
310
+                containers_ids=$($cmktemp)
311
+				cat $issues_id $parts_id | shuf > $containers_ids
312
+                persons_ids=$(fetch_all_ids $1 Person)
313
+                for i in $(seq $iteration_count)
314
+                do
315
+                    cur_id=$(shuf -n1 $reviews_ids)
316
+                    entries_count=$(shuf -i1-10 -n1)
317
+                    containers_count=1
318
+                    person_count=$(shuf -i1-5 -n1)
319
+                    entries_param=$(head -n $(expr $entries_count \* $i) $entries_ids| tail -n$entries_count|tr -s "\n" ",")
320
+                    container_param=$(head -n $(expr $containers_count \* $i) $containers_ids| tail -n$containers_count|tr -s "\n")
321
+                    person_param=$(head -n $(expr $person_count \* $i) $persons_ids| tail -n$person_count|tr -s "\n" ",")
322
+                    $curcurl -d "$(curl_opt_create_$cls $entries_param $person_param $container_param)&uid=$cur_id" "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id" | tee -a $logfile
323
+		            #echo "$base_uri/admin/update?classname=$cls&lodel_id=$cur_id POST $(curl_opt_create_$cls $entries_param $person_param $container_param)&uid=$cur_id"
324
+                done
325
+                rm -v $reviews_ids $entries_ids $issues_id $persons_ids $parts_id $containers_ids >&2
326
+                ;;
327
+			*)
328
+				;;
329
+			
330
+		esac
331
+	done
332
+	rm -v $cls_list_file >&2
333
+}
334
+
335
+mass_deletion() {
336
+	#mass deletion scenario
337
+	#$1 is instance name
338
+	#$2 number of deletion per classes !
339
+	instance_name=$1
340
+	iteration_count=$2
341
+	base_uri=$(_base_uri $1)
342
+    logfile="$logdir/mass_deletion_${instance_name}.log"
343
+	cls_list_file=$(fetch_all_classes $1)
344
+	
345
+	for cls in $(cat $cls_list_file)
346
+	do
347
+		id_list_file=$(fetch_all_ids $1 $cls)
348
+		if [ "$iteration_count" -gt "$(wc -l $id_list_file | cut -d " " -f1)" ]
349
+		then
350
+			max_iter=$(wc -l $id_list_file | cut -d " " -f1)
351
+		else
352
+			max_iter="$iteration_count"
353
+		fi
354
+
355
+		for i in $(seq $max_iter)
356
+		do
357
+			id=$(tail -n $i $id_list_file | head -n1)
358
+            $curcurl "${base_uri}/admin/delete?classname=$cls&lodel_id=$id" | tee -a $logfile
359
+			#echo "${base_uri}/admin/delete?classname=$cls&lodel_id=$id"
360
+		done
361
+		rm -v $id_list_file
362
+	done
363
+	rm -v $cls_list_file
364
+}
365
+
366
+
367
+fetch_all_classes() {
368
+	#$1 is intance name
369
+	cls_list_file=$($cmktemp)
370
+	$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
371
+	if [ -z "$(cat $cls_list_file)" ]
372
+	then
373
+		echo "Unable to fetch class list for $1" >&2
374
+		echo "Request was : $curl_raw '$(_base_uri $1)/list_classes'" >&2
375
+		rm $cls_list_file
376
+		exit 1
377
+	fi
378
+	echo $cls_list_file
379
+}
380
+
381
+fetch_all_ids() {
382
+	# Fetch all ids of a class in an instance and shuffle them
383
+	instance_name=$1
384
+	classname=$2
385
+	idfile=$($cmktemp)
386
+	$curl_raw "$(_base_uri $1)/show_class?classname=$2" | sed -nE 's/^.*<li><a href="[^=]+=[^=]+=([0-9]+)".*$/\1/p' |shuf > $idfile
387
+	echo $idfile
388
+}
389
+
390
+uri_create() {
391
+	clsname=$1
392
+	echo -n "/admin/create?classname=$1"
393
+}
394
+
395
+curl_opt_create_Person() {
396
+	#$1 is linked_texts ids (comma separated)
397
+	#$2 is containers ids(comma separated)
398
+	echo "field_input_lastname=$(rnd_str_len 10 20)&field_input_firstname=$(rnd_str_len 10 20)&field_input_linked_texts=$1&field_input_linked_containers=$2&classname=Person"
399
+}
400
+
401
+curl_opt_create_User() {
402
+	echo "field_input_lastname=$(rnd_str_len 10 20)&field_input_firstname=$(rnd_str_len 10 20)&field_input_password=$(rnd_str 50)&field_input_login=$(rnd_str_len 5 20)&classname=User"
403
+}
404
+curl_opt_create_Entry() {
405
+    #$1 texts ids, separated by comma
406
+    #$2 string
407
+	echo "field_input_linked_texts=$1&field_input_name=$(rnd_str_len 10 20)&field_input_role=$2&field_input_description=$(rnd_str_len 100 500)&classname=Entry"
408
+}
409
+
410
+curl_opt_create_Collection() {
411
+    #$1 is persons ids, separated by comma
412
+    #$2 is issues ids, separated by comma
413
+    issn=$(</dev/urandom tr -dc 0-9 | head -c8;echo;)
414
+    lg=$(shuf -e 'fr' 'en' 'es' 'ger' 'it'| head -n 1)
415
+	echo "field_input_title=$(rnd_str_len 20 100)&field_input_subtitle=$(rnd_str_len 20 100)&field_input_language=$lg&field_input_linked_directors=$1&field_input_linked_issues=$2&field_input_description=$(rnd_str_len 100 500)&field_input_publisher_note=$(rnd_str_len 100 500)&field_input_issn=$issn&classname=Collection"
416
+}
417
+
418
+curl_opt_create_Issue() {
419
+    #$1 persons ids, separated by comma
420
+    #$2 collection id
421
+    #$3 parts ids, separated by comma
422
+    #$4 texts ids, separated by comma
423
+    lg=$(shuf -e 'fr' 'en' 'es' 'ger' 'it'| head -n 1)
424
+    isbn=$(</dev/urandom tr -dc 0-9 | head -c10;echo;)
425
+    pisbn=$(</dev/urandom tr -dc 0-9 | head -c10;echo;)
426
+	echo "field_input_title=$(rnd_str_len 20 100)&field_input_subtitle=$(rnd_str_len 20 100)&field_input_language=$lg&field_input_linked_directors=$1&field_input_description=$(rnd_str_len 100 500)&field_input_publisher_note=$(rnd_str_len 100 500)&field_input_isbn=$isbn&field_input_print_isbn=$pisbn&field_input_number=$(rnd_str_len 10 50)&field_input_cover=$(rnd_str_len 20 50)&field_input_print_pub_date=$(rnd_date)&field_input_e_pub_date=$(rnd_date)&field_input_abstract=$(rnd_str_len 5000 20000)&field_input_collection=$2&field_input_linked_parts=$3&field_input_linked_texts=$4&classname=Issue"
427
+}
428
+
429
+curl_opt_create_Part() {
430
+    #$1 persons ids, separated by comma
431
+    #$2 publication id (issue id or part id)
432
+    #$3 parts ids, separated by comma
433
+    #$4 text ids, separated by comma
434
+    lg=$(shuf -e 'fr' 'en' 'es' 'ger' 'it'| head -n 1)
435
+	echo "field_input_title=$(rnd_str_len 20 100)&field_input_subtitle=$(rnd_str_len 20 100)&field_input_language=$lg&field_input_linked_directors=$1&field_input_description=$(rnd_str_len 100 500)&field_input_publisher_note=$(rnd_str_len 100 500)&field_input_publication=$2&field_input_linked_parts=$3&field_input_linked_texts=$4&classname=Part"
436
+}
437
+
438
+curl_opt_create_Article() {
439
+	#$1 entries ids (comma separated)
440
+	#$2 linked_persons ids (comma separated)
441
+	#$3 container id
442
+    lg=$(shuf -e 'fr' 'en' 'es' 'ger' 'it'| head -n 1)
443
+	echo "field_input_title=$(rnd_str_len 20 100)&field_input_linked_entries=$1&field_input_linked_persons=$2&field_input_linked_container=$3&field_input_subtitle=$(rnd_str_len 20 100)&field_input_language=$lg&field_input_text=$(rnd_str_len 10000 50000)&field_input_pub_date=$(rnd_date)&field_input_footnotes=$(rnd_str_len 5000 20000)&field_input_abstract=$(rnd_str_len 1000 5000)&field_input_appendix=$(rnd_str_len 5000 20000)&field_input_bibliography=$(rnd_str_len 5000 20000)&field_input_author_note=$(rnd_str_len 5000 20000)&classname=Article"
444
+}
445
+
446
+curl_opt_create_Review() {
447
+	#$1 entries ids (comma separated)
448
+	#$2 linked_persons ids (comma separated)
449
+	#$3 container id
450
+    lg=$(shuf -e 'fr' 'en' 'es' 'ger' 'it'| head -n 1)
451
+	echo "field_input_title=$(rnd_str_len 20 50)&field_input_subtitle=$(rnd_str_len 20 50)&field_input_language=$lg&field_input_text=$(rnd_str_len 10000 50000)&field_input_pub_date=$(rnd_date)&field_input_footnotes=$(rnd_str_len 5000 20000)&field_input_linked_entries=$1&field_input_linked_persons=$2&field_input_linked_container=$3&field_input_reference=$(rnd_str_len 5000 20000)&classname=Review"
452
+}
453
+
454
+run_bg_with_param() {
455
+	#$1 is the function name to run
456
+	#$2 is the instance_list filename
457
+	#other parameters are given to the function
458
+	fun=$1
459
+	instance_list=$2
460
+	shift;shift
461
+
462
+	pidlist=$($cmktemp)
463
+	for iname in $(cat $instance_list)
464
+	do
465
+		$fun $iname $@ &
466
+		echo $! >> $pidlist
467
+		sleep 1
468
+	done
469
+	for pid in $(cat $pidlist)
470
+	do
471
+		wait $pid
472
+	done
473
+	rm -v $pidlist
474
+}
475
+
476
+get_queries_with_params() {
477
+	#$1 is the function name to run
478
+	#$2 is the instance_list filename
479
+	#other parameters are given to the function
480
+	fun=$1
481
+	instance_list=$2
482
+	shift;shift
483
+	counter=0
484
+	for iname in $(cat $instance_list| sort)
485
+	do
486
+		echo "Running $fun $iname $@" >&2
487
+		beg=$(date "+%s")
488
+		$fun $iname $@
489
+		tsecs=$(expr $(date "+%s") - $beg)
490
+		left=$(expr $(cat $instance_list |wc -l) - $counter)
491
+		counter=$(expr $counter + 1)
492
+		tleft=$(expr $left \* $tsecs)
493
+		percent_done=$(echo "2k ${counter}.0 100.0 * $(cat $instance_list |wc -l).0 2k/ f" | dc)
494
+		echo -e "Done in ${tsecs}s\t$fun ${percent_done}% done ~$tleft secs" >&2
495
+
496
+	done | shuf
497
+}
498
+
499
+#run_bg_with_param "mass_creation" $instance_list $n_create
500
+#run_bg_with_param "mass_link_edit" $instance_list $n_edit
501
+#run_bg_with_param "mass_deletion" $instance_list $n_delete
502
+
503
+#get_queries_with_params "mass_creation" $instance_list $n_create
504
+get_queries_with_params "mass_link_edit" $instance_list $n_edit
505
+#get_queries_with_params "mass_deletion" $instance_list $n_delete

Loading…
Cancel
Save