create_db.sim 5.9 KB
Newer Older
1 2 3 4
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect
S
Shengliang Guan 已提交
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
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
100
$duration = 10
101 102 103 104 105 106 107 108 109
$keep = 365,365,365
$rows_db = 1000
$cache = 16 # 16MB
$ablocks = 100 
$tblocks = 32 # max=512, automatically trimmed when exceeding
$ctime = 36000 # 10 hours
$wal = 1 # valid value is 1, 2
$comp = 1 # max=32, automatically trimmed when exceeding

110
sql create database $db replica $replica duration $duration keep $keep maxrows $rows_db cache $cache blocks 4 ctime $ctime wal $wal comp $comp
111 112 113 114 115 116 117 118 119 120
sql show databases
if $rows != 1 then
  return -1
endi
if $data00 != $db then 
 return -1
endi
if $data04 != $replica then 
 return -1
endi
121
if $data06 != $duration then 
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 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 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 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
 return -1
endi
if $data07 != 365,365,365 then 
 return -1
endi
print data08 = $data07
if $data08 != $cache then
 print expect $cache, actual:$data08
 return -1
endi
if $data09 != 4 then
 return -1
endi

sql drop database $db

## 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
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
sql_error create database $db keep 8
sql_error create database $db keep 12,11
sql_error create database $db keep 365001,365001,365001
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

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
#sql_error create database $db keep 3651

# rows [200, 10000]
sql_error create database $db maxrows 199
#sql_error create database $db maxrows 10001

# cache [100, 10485760]
sql_error create database $db cache 0
#sql_error create database $db cache 10485761


# blocks [32, 4096 overwriten by 4096 if exceeds, Note added:2018-10-24]
#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

# wal {0, 2}
sql create database testwal wal 0
sql show databases
if $rows != 1 then
  return -1
endi

sql show databases
print wallevel $data12_testwal
if $data12_testwal != 0 then 
  return -1
endi
sql drop database testwal

sql create database testwal wal 1
sql show databases
if $rows != 1 then
  return -1
endi
sql show databases
print wallevel $data12_testwal
if $data12_testwal != 1 then 
  return -1
endi
sql drop database testwal

sql create database testwal wal 2
sql show databases
if $rows != 1 then
  return -1
endi
print wallevel $data12_testwal
if $data12_testwal != 2 then 
  return -1
endi
sql drop database testwal

sql_error create database $db wal -1
sql_error create database $db wal 3

# 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

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