client-06.sim 3.7 KB
Newer Older
H
Hui Li 已提交
1 2 3 4 5 6 7 8
# create database db1
# create table tb ()
# loop insert disorder data, drop some tables and create new tables, sleep , 
###############################################################
################ set script parameters ################
$tblStart = 0
$tblEnd   = 10000
$tsStart  = 1325347200000  # 2012-01-01 00:00:00.000
H
Hui Li 已提交
9
$preBinary = ' . client-06-
H
Hui Li 已提交
10 11
$numPerUpdateTbl = 2000
###############################################################
H
Hui Li 已提交
12
$testCnt = 0
H
Hui Li 已提交
13

H
Hui Li 已提交
14 15
$totalRows    = 0  
$dropTblStart = $tblStart
H
Hui Li 已提交
16
$dropTblEnd   = $dropTblStart
H
Hui Li 已提交
17 18 19 20 21 22 23 24 25

sql connect

print ================ create db
$db = db
sql create database if not exists $db replica 2 
sql use $db

init_lable:
H
Hui Li 已提交
26
print ================ create table $tb [ from $tblStart to $tblEnd ] (ts timestamp, c1 int, c2 binary(16))
H
Hui Li 已提交
27 28 29 30 31 32 33 34 35

$i = $tblStart
while $i < $tblEnd
  $tb = tb . $i
#  print create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) )
  sql create table if not exists $tb ( ts timestamp , c1 int , c2 binary(16) )
  $i = $i + 1
endw 

H
Hui Li 已提交
36 37
$dropTblStart = $dropTblEnd
$dropTblEnd   = $dropTblStart + $numPerUpdateTbl
H
Hui Li 已提交
38 39 40 41 42 43 44 45 46 47 48

$tblStart = $tblEnd
$tblEnd   = $tblEnd + $numPerUpdateTbl

$rowsPerTbl  = 0
$ts          = $tsStart
$rowsPerLoop = 160

$loopCnt = 0
 
loop_run:
H
Hui Li 已提交
49
print ================ client-06 start loop insert data from $dropTblStart to $tblStart ( loopCnt: $loopCnt )
H
Hui Li 已提交
50 51
$i = $dropTblStart
while $i < $tblStart
H
Hui Li 已提交
52 53
  $tb = tb . $i
  
H
Hui Li 已提交
54
  $c2Binary = $preBinary . $i
H
Hui Li 已提交
55 56 57 58 59 60 61 62 63
  $c2Binary = $c2Binary . '

  $x = 0
  while $x < $rowsPerLoop
    sql insert into $tb values ( $ts + 0a , $x , $c2Binary ) ( $ts + 2a , $x , $c2Binary ) ( $ts + 4a , $x , $c2Binary ) ( $ts + 6a , $x , $c2Binary ) ( $ts + 8a , $x , $c2Binary ) ( $ts + 10a , $x , $c2Binary ) ( $ts + 12a , $x , $c2Binary ) ( $ts + 14a , $x , $c2Binary ) ( $ts + 16a , $x , $c2Binary ) ( $ts + 18a , $x , $c2Binary ) ( $ts + 20a , $x , $c2Binary ) ( $ts + 22a , $x , $c2Binary ) ( $ts + 24a , $x , $c2Binary ) ( $ts + 26a , $x , $c2Binary ) ( $ts + 28a , $x , $c2Binary ) ( $ts + 30a , $x , $c2Binary ) ( $ts + 32a , $x , $c2Binary ) ( $ts + 34a , $x , $c2Binary ) ( $ts + 36a , $x , $c2Binary ) ( $ts + 38a , $x , $c2Binary )
    sql insert into $tb values ( $ts + 1a , $x , $c2Binary ) ( $ts + 3a , $x , $c2Binary ) ( $ts + 5a , $x , $c2Binary ) ( $ts + 7a , $x , $c2Binary ) ( $ts + 9a , $x , $c2Binary ) ( $ts + 11a , $x , $c2Binary ) ( $ts + 13a , $x , $c2Binary ) ( $ts + 15a , $x , $c2Binary ) ( $ts + 17a , $x , $c2Binary ) ( $ts + 19a , $x , $c2Binary ) ( $ts + 21a , $x , $c2Binary ) ( $ts + 23a , $x , $c2Binary ) ( $ts + 25a , $x , $c2Binary ) ( $ts + 27a , $x , $c2Binary ) ( $ts + 29a , $x , $c2Binary ) ( $ts + 31a , $x , $c2Binary ) ( $ts + 33a , $x , $c2Binary ) ( $ts + 35a , $x , $c2Binary ) ( $ts + 37a , $x , $c2Binary ) ( $ts + 39a , $x , $c2Binary )
    $x = $x + 40
    $ts = $ts + 40a
  endw 
H
Hui Li 已提交
64
  if $i == $dropTblStart then
H
Hui Li 已提交
65 66
    $rowsPerTbl = $rowsPerTbl + $x   
  endi
H
Hui Li 已提交
67 68 69 70 71 72

  $totalRows = $totalRows + $x
  $i = $i + 1
  
endw 

H
Hui Li 已提交
73 74
sql select count(*) from $tb
print data00 $data00 rowsPerTbl $rowsPerTbl
H
Hui Li 已提交
75
if $data00 != $rowsPerTbl then
H
Hui Li 已提交
76 77 78
  print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  print ************ client-06 insert data into $tb error ***** *****
  print ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
H
Hui Li 已提交
79 80 81 82 83
  return -1
endi

$loopCnt = $loopCnt + 1

H
Hui Li 已提交
84
if $loopCnt > 2 then
H
Hui Li 已提交
85
  print ================ client-06 drop table from $dropTblStart to $dropTblEnd
H
Hui Li 已提交
86 87 88 89 90 91 92 93
  $i = $dropTblStart
  while $i < $dropTblEnd
    $tb = tb . $i
    sql drop table if exists $tb
    $i = $i + 1
    $totalRows = $totalRows - $rowsPerTbl
  endw  
  sleep 20000
H
Hui Li 已提交
94
  $testCnt = $testCnt + 1
H
Hui Li 已提交
95 96 97
  goto init_lable 
endi

H
Hui Li 已提交
98 99 100
if $testCnt > 10 then
  return 0
endi
H
Hui Li 已提交
101
goto loop_run