create_db.sim 5.4 KB
Newer Older
S
slguan 已提交
1 2
system sh/stop_dnodes.sh

S
slguan 已提交
3 4

system sh/deploy.sh -n dnode1 -i 1
5
system sh/cfg.sh -n dnode1 -c walLevel -v 1
S
slguan 已提交
6 7
system sh/exec.sh -n dnode1 -s start

H
Haojun Liao 已提交
8
sleep 100
S
slguan 已提交
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
sql connect
print ======================== dnode1 start

$dbPrefix = fi_in_db
$tbPrefix = fi_in_tb
$mtPrefix = fi_in_mt
$tbNum = 10
$rowNum = 20
$totalNum = 200

print excuting test script create_db.sim
print =============== set up
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i

sql_error createdatabase $db
sql create database $db
sql use $db
sql show databases

if $rows != 1 then 
  return -1
endi
if $data00 != $db then 
  return -1
endi
sql drop database $db

# case1: case_insensitivity test
print =========== create_db.sim case1: case insensitivity test
sql_error CREATEDATABASE $db
sql CREATE DATABASE $db
sql use $db
sql show databases

if $rows != 1 then
  return -1
endi
if $data00 != $db then 
  return -1
endi
sql drop database $db
print case_insensitivity test passed

# case2: illegal_db_name test
print =========== create_db.sim case2: illegal_db_name test
$illegal_db1 = 1db
$illegal_db2 = d@b

sql_error create database $illegal_db1
sql_error create database $illegal_db2
print illegal_db_name test passed

# case3: chinese_char_in_db_name test
print ========== create_db.sim case3: chinese_char_in_db_name test
$CN_db1 = 数据库
$CN_db2 = 数据库1
$CN_db3 = db数据库1
sql_error create database $CN_db1
sql_error create database $CN_db2
sql_error create database $CN_db3
#sql show databases
#if $rows != 3 then
#  return -1
#endi
#if $data00 != $CN_db1 then
#  return -1
#endi
#if $data10 != $CN_db2 then
#  return -1
#endi
#if $data20 != $CN_db3 then
#  return -1
#endi
#sql drop database $CN_db1
#sql drop database $CN_db2
#sql drop database $CN_db3
print case_chinese_char_in_db_name test passed

# case4: db_already_exists
print create_db.sim case4: db_already_exists
sql create database db0
sql create database db0
sql show databases
if $rows != 1 then
  return -1
endi
sql drop database db0
print db_already_exists test passed

# case5: db_meta_data
print create_db.sim case5: db_meta_data test
# cfg params
$replica = 1 # max=3
$days = 10
D
dapan1121 已提交
105
$keep = 365,365,365
S
slguan 已提交
106
$rows_db = 1000
H
Haojun Liao 已提交
107
$cache = 16 # 16MB
S
slguan 已提交
108 109 110
$ablocks = 100 
$tblocks = 32 # max=512, automatically trimmed when exceeding
$ctime = 36000 # 10 hours
111
$wal = 1 # valid value is 1, 2
S
slguan 已提交
112 113
$comp = 1 # max=32, automatically trimmed when exceeding

114
sql create database $db replica $replica days $days keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp
S
slguan 已提交
115 116 117 118 119 120 121 122 123 124
sql show databases
if $rows != 1 then
  return -1
endi
if $data00 != $db then 
 return -1
endi
if $data04 != $replica then 
 return -1
endi
S
scripts  
Shengliang Guan 已提交
125
if $data06 != $days then 
S
slguan 已提交
126 127
 return -1
endi
S
scripts  
Shengliang Guan 已提交
128
if $data07 != 365,365,365 then 
S
slguan 已提交
129 130
 return -1
endi
S
scripts  
Shengliang Guan 已提交
131 132 133
print data08 = $data07
if $data08 != $cache then
 print expect $cache, actual:$data08
S
slguan 已提交
134 135
 return -1
endi
S
scripts  
Shengliang Guan 已提交
136
if $data09 != 4 then
S
slguan 已提交
137 138 139
 return -1
endi

140
sql drop database $db
S
slguan 已提交
141 142 143 144 145 146 147 148 149 150 151 152

## param range tests
# replica [1,3]
#sql_error create database $db replica 0
sql_error create database $db replica 4

# day [1, 3650]
sql_error create database $db day 0
sql_error create database $db day 3651 

# keep [1, infinity]
sql_error create database $db keep 0
D
dapan1121 已提交
153 154 155 156 157 158 159 160 161
sql_error create database $db keep 0,0,0
sql_error create database $db keep 3,3,3
sql_error create database $db keep 11.0
sql_error create database $db keep 11.0,11.0,11.0
sql_error create database $db keep "11","11","11"
sql_error create database $db keep "11"
sql_error create database $db keep 13,12,11
sql_error create database $db keep 11,12,11
sql_error create database $db keep 12,11,12
D
dapan1121 已提交
162 163
sql_error create database $db keep 8
sql_error create database $db keep 12,11
D
dapan1121 已提交
164
sql_error create database $db keep 365001,365001,365001
D
dapan1121 已提交
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
sql create database dbk0 keep 19
sql show databases
if $rows != 1 then
  return -1
endi
if $data07 != 19,19,19 then 
 return -1
endi
sql drop database dbk0
sql create database dbka keep 19,20
sql show databases
if $rows != 1 then
  return -1
endi
if $data07 != 19,20,20 then 
 return -1
endi
sql drop database dbka

D
dapan1121 已提交
184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219
sql create database dbk1 keep 11,11,11
sql show databases
if $rows != 1 then
  return -1
endi
if $data07 != 11,11,11 then 
 return -1
endi
sql drop database dbk1
sql create database dbk2 keep 11,12,13
sql show databases
if $rows != 1 then
  return -1
endi
if $data07 != 11,12,13 then 
 return -1
endi
sql drop database dbk2
sql create database dbk3 keep 11,11,13
sql show databases
if $rows != 1 then
  return -1
endi
if $data07 != 11,11,13 then 
 return -1
endi
sql drop database dbk3
sql create database dbk4 keep 11,13,13
sql show databases
if $rows != 1 then
  return -1
endi
if $data07 != 11,13,13 then 
 return -1
endi
sql drop database dbk4
S
slguan 已提交
220 221 222
#sql_error create database $db keep 3651

# rows [200, 10000]
sangshuduo's avatar
sangshuduo 已提交
223 224
sql_error create database $db maxrows 199
#sql_error create database $db maxrows 10001
S
slguan 已提交
225 226

# cache [100, 10485760]
227
sql_error create database $db cache 0
S
slguan 已提交
228 229 230
#sql_error create database $db cache 10485761


231
# blocks [32, 4096 overwriten by 4096 if exceeds, Note added:2018-10-24]
S
slguan 已提交
232 233 234 235 236 237 238
#sql_error create database $db tblocks 31
#sql_error create database $db tblocks 4097

# ctime [30, 40960]
sql_error create database $db ctime 29
sql_error create database $db ctime 40961

239 240
# wal {0, 2}
#sql_error create database $db wal 0
sangshuduo's avatar
sangshuduo 已提交
241
sql_error create database $db wal -1
242
sql_error create database $db wal 3
S
slguan 已提交
243 244 245 246 247 248 249 250 251 252

# comp {0, 1, 2}
sql_error create database $db comp -1
sql_error create database $db comp 3

sql_error drop database $db
sql show databases
if $rows != 0 then 
  return -1
endi
S
scripts  
Shengliang Guan 已提交
253 254

system sh/exec.sh -n dnode1 -s stop -x SIGINT