auto_create_tb.sim 6.8 KB
Newer Older
S
slguan 已提交
1
system sh/stop_dnodes.sh
S
slguan 已提交
2
system sh/deploy.sh -n dnode1 -i 1
H
hjxilinx 已提交
3
system sh/cfg.sh -n dnode1 -c walLevel -v 0
S
scripts  
slguan 已提交
4
system sh/cfg.sh -n dnode1 -c maxtablesPerVnode -v 2
S
slguan 已提交
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
system sh/exec.sh -n dnode1 -s start

sleep 3000
sql connect
print ======================== dnode1 start

$dbPrefix = ac_db
$tbPrefix = ac_tb
$stbPrefix = ac_stb
$tbNum = 10
$rowNum = 20
$totalNum = 200
$ts0 = 1537146000000

print excuting test script auto_create_tb.sim
print =============== set up
$i = 0
$db = $dbPrefix
$stb = $stbPrefix
$tb = $tbPrefix . $i

sql create database $db
sql use $db

print =========== auto_create_tb.sim case1: test
sql CREATE TABLE $stb (TS TIMESTAMP, C1 INT, C2 BIGINT, C3 FLOAT, C4 DOUBLE, C5 BINARY(10), C6 BOOL, C7 SMALLINT, C8 TINYINT, C9 NCHAR(10)) TAGS (T1 INT)
sql show stables

if $rows != 1 then
  return -1
endi
if $data00 != $stb then 
  return -1
endi

### create table on the fly
sql insert into tb1 using $stb tags (1) values ( $ts0 , 1,1,1,1,'bin',1,1,1,'涛思数据') 
sql select * from tb1
if $rows != 1 then
  return -1
endi
if $data01 != 1 then
  return -1
endi
if $data09 != 涛思数据 then
  return -1
endi
if $data02 != 1 then
  return -1
endi
if $data03 != 1.00000 then
  return -1
endi
if $data04 != 1.000000000 then
  return -1
endi
if $data05 != bin then
  return -1
endi

### insert into an existing table
$ts1 = $ts0 + 1000
$ts2 = $ts0 + 2000
sql insert into tb1 using $stb tags (1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar')
sql select * from $stb
if $rows != 3 then
  return -1
endi
if $data19 != 涛思数据 then
  return -1
endi
if $data11 != 1 then
  return -1
endi
if $data22 != 2 then
  return -2
endi
if $data23 != 2.00000 then
  return -1
endi
if $data25 != binar then
  return -1
endi
if $data29 != nchar then
  return -1
endi

### [TBASE-410] auto create table with a negative tag value
$ts1 = $ts0 + 1000
$ts2 = $ts0 + 2000
sql insert into tb_1 using $stb tags (-1) values ( $ts1 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts2 , 2,2,2,2,'binar', 1,1,1,'nchar')
sql select * from $stb
S
Shengliang Guan 已提交
97
if $rows != 5 then
S
slguan 已提交
98 99
  return -1
endi
S
Shengliang Guan 已提交
100
if $data09 != 涛思数据 then
S
slguan 已提交
101 102
  return -1
endi
S
Shengliang Guan 已提交
103
if $data01 != 1 then
S
slguan 已提交
104 105
  return -1
endi
S
Shengliang Guan 已提交
106
if $data42 != 2 then
S
slguan 已提交
107 108
  return -2
endi
S
Shengliang Guan 已提交
109
if $data43 != 2.00000 then
S
slguan 已提交
110 111
  return -1
endi
S
Shengliang Guan 已提交
112
if $data45 != binar then
S
slguan 已提交
113 114
  return -1
endi
S
Shengliang Guan 已提交
115
if $data49 != nchar then
S
slguan 已提交
116 117 118 119 120 121 122 123 124 125 126 127
  return -1
endi
sql drop table tb_1

#### insert into an existing table with wrong tags
$ts3 = $ts0 + 3000
$ts4 = $ts0 + 4000
sql insert into tb1 using $stb tags (2) values ( $ts3 , 1,1,1,1,'bin',1,1,1,'涛思数据') ( $ts4 , 2,2,2,2,'binar', 1,1,1,'nchar')
sql select * from $stb
if $rows != 5 then
  return -1
endi
S
Shengliang Guan 已提交
128
if $data09 != 涛思数据 then
S
slguan 已提交
129 130
  return -1
endi
S
Shengliang Guan 已提交
131
if $data01 != 1 then
S
slguan 已提交
132 133
  return -1
endi
S
Shengliang Guan 已提交
134
if $data42 != 2 then
S
slguan 已提交
135 136
  return -2
endi
S
Shengliang Guan 已提交
137
if $data43 != 2.00000 then
S
slguan 已提交
138 139
  return -1
endi
S
Shengliang Guan 已提交
140
if $data45 != binar then
S
slguan 已提交
141 142
  return -1
endi
S
Shengliang Guan 已提交
143
if $data49 != nchar then
S
slguan 已提交
144 145 146 147 148 149 150 151
  return -1
endi

sql drop table tb1

#### auto create multiple tables
sql insert into tb1 using $stb tags(1) values ( $ts0 , 1, 1, 1, 1, 'bin1', 1, 1, 1, '涛思数据1') tb2 using $stb tags(2) values ( $ts0 , 2, 2, 2, 2, 'bin2', 2, 2, 2, '涛思数据2') tb3 using $stb tags(3) values ( $ts0 , 3, 3, 3, 3, 'bin3', 3, 3, 3, '涛思数据3')
sql show tables
S
scripts  
Shengliang Guan 已提交
152
print $rows $data00 $data10 $data20
S
slguan 已提交
153 154 155
if $rows != 3 then
  return -1
endi
S
scripts  
Shengliang Guan 已提交
156
if $data00 != tb1 then
S
slguan 已提交
157 158 159 160 161
  return -1
endi
if $data10 != tb2 then
  return -1
endi
S
scripts  
Shengliang Guan 已提交
162
if $data20 != tb3 then
S
slguan 已提交
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
  return -1
endi

sql select ts,c1,c2,c3,c4,c5,c7,c8,c9 from $stb
if $rows != 3 then
  return -1
endi
#if $data00 != @18-09-17 09:00:00.000@ then
#  return -1
#endi
if $data01 != 1 then
  return -1
endi
if $data08 != 涛思数据1 then
  return -1
endi
if $data14 != 2.000000000 then
  return -1
endi
if $data18 != 涛思数据2 then
  return -1
endi
if $data28 != 涛思数据3 then
  return -1
endi

sql select count(*), first(c9) from $stb group by t1 order by t1 asc slimit 2 soffset 1
if $rows != 2 then
  return -1
endi
if $data00 != 1 then
  return -1
endi
if $data01 != 涛思数据2 then
  return -1
endi
if $data02 != 2 then
  return -1
endi
if $data11 != 涛思数据3 then
  return -1
endi
if $data12 != 3 then
  return -1
endi

print ================== restart server to commit data into disk
system sh/exec.sh -n dnode1 -s stop -x SIGINT
S
scripts  
Shengliang Guan 已提交
211
sleep 5000
S
slguan 已提交
212 213 214 215 216 217 218 219 220 221 222 223
system sh/exec.sh -n dnode1 -s start
print ================== server restart completed
sql connect
sleep 3000
sql use $db

#### auto create multiple tables
sql insert into tb1 using $stb tags(1) values ( $ts0 , 1, 1, 1, 1, 'bin1', 1, 1, 1, '涛思数据1') tb2 using $stb tags(2) values ( $ts0 , 2, 2, 2, 2, 'bin2', 2, 2, 2, '涛思数据2') tb3 using $stb tags(3) values ( $ts0 , 3, 3, 3, 3, 'bin3', 3, 3, 3, '涛思数据3')
sql show tables
if $rows != 3 then
  return -1
endi
S
scripts  
Shengliang Guan 已提交
224
if $data00 != tb1 then
S
slguan 已提交
225 226 227 228 229
  return -1
endi
if $data10 != tb2 then
  return -1
endi
S
scripts  
Shengliang Guan 已提交
230
if $data20 != tb3 then
S
slguan 已提交
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 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302
  return -1
endi

sql select ts,c1,c2,c3,c4,c5,c7,c8,c9 from $stb
if $rows != 3 then
  return -1
endi
#if $data00 != @18-09-17 09:00:00.000@ then
#  return -1
#endi
if $data01 != 1 then
  return -1
endi
if $data08 != 涛思数据1 then
  return -1
endi
if $data14 != 2.000000000 then
  return -1
endi
if $data18 != 涛思数据2 then
  return -1
endi
if $data28 != 涛思数据3 then
  return -1
endi

sql select count(*), first(c9) from $stb group by t1 order by t1 asc slimit 2 soffset 1
if $rows != 2 then
  return -1
endi
if $data00 != 1 then
  return -1
endi
if $data01 != 涛思数据2 then
  return -1
endi
if $data02 != 2 then
  return -1
endi
if $data11 != 涛思数据3 then
  return -1
endi
if $data12 != 3 then
  return -1
endi

print ======= too many columns in auto create tables
sql create table tick (ts timestamp , last_prc double , volume int, amount double, oi int , bid_prc1 double, ask_prc1 double, bid_vol1 int, ask_vol1 int , bid_prc2 double, ask_prc2 double, bid_vol2 int, ask_vol2 int , bid_prc3 double, ask_prc3 double, bid_vol3 int, ask_vol3 int , bid_prc4 double, ask_prc4 double, bid_vol4 int, ask_vol4 int , bid_prc5 double, ask_prc5 double, bid_vol5 int, ask_vol5 int , open_prc double, highest_prc double, low_prc double, close_prc double , upper_limit double, lower_limit double) TAGS (ticker BINARY(32), product BINARY(8));
sql show stables

if $rows != 2 then
  return -1
endi

sql insert into tick_000001 ('ts', 'last_prc', 'volume', 'amount', 'oi', 'bid_prc1', 'ask_prc1') using tick tags (000001, Stocks) VALUES (1546391700000, 0.000000, 0, 0.000000, 0, 0.000000, 10.320000);
sql select tbname from tick
if $rows != 1 then
   return -1
endi

#sql drop database $db
#sql show databases
#if $rows != 0 then 
#  return -1
#endi

#[tbase-673]
sql create table tu(ts timestamp, k int);
sql_error create table txu using tu tags(0) values(now, 1);

#[TBASE-675]
sql insert into tu values(1565971200000, 1) (1565971200000,2) (1565971200001, 3)(1565971200001, 4)
S
scripts  
Shengliang Guan 已提交
303
sql select * from tu
S
slguan 已提交
304 305 306
if $rows != 2 then
    return -1
endi
S
scripts  
Shengliang Guan 已提交
307 308

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