nchar.sim 7.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
H
hjxilinx 已提交
5
system sh/cfg.sh -n dnode1 -c walLevel -v 0
S
slguan 已提交
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
system sh/exec.sh -n dnode1 -s start

sleep 3000
sql connect

print ======================== dnode1 start

$dbPrefix = nchar_db
$tbPrefix = nchar_tb
$mtPrefix = nchar_stb
$tbNum = 10
$rowNum = 20
$totalNum = 200
$col = NCHAR

print =============== set up
$i = 0
$db = $dbPrefix . $i
$mt = $mtPrefix . $i
$tb = $tbPrefix . $i
sql create database $db
sql use $db

# case1: create_metric_with_nchar_data
print ========== nchar.sim case1: create_table_with_nchar_data test

# unspecified nchar length
sql_error create table $mt (ts timestamp, col nchar)
sql_error create table $mt (ts timestamp, col int) tags (tg nchar)
# nchar as column or tag names
sql_error create table $mt (ts timestamp, nchar int)
sql_error create table $mt (ts timestamp, col int) tags (nchar int)
sql create table $mt (ts timestamp, col nchar(60)) tags (tg nchar(60))
sql show stables
if $rows != 1 then 
  return -1
endi
if $data00 != $mt then
  return -1
endi
sql describe $mt
if $rows != 3 then 
  return -1
endi
if $data11 != NCHAR then
  return -1
endi
sql create table $tb using $mt tags ('tag1')
sql describe $tb
if $data11 != NCHAR then
  return -1
endi
if $data21 != NCHAR then
  return -1
endi
sql drop table $tb
sql drop table $mt
print create_metric_with_nchar_data test passed

# case2 : insert_nchar_data
#print ========== nchar.sim case2: insert_nchar_data
sql create table $mt (ts timestamp, col nchar(10)) tags(tg nchar(10))
sql create table $tb using $mt tags ('tag1')
sql describe $mt
#print expected: NCHAR
#print returned: $data11
if $data11 != NCHAR then
  return -1
endi

# insert nchar data with a pair of single quotes
$col = 'NCHAR'
$col_ = NCHAR
S
scripts  
Shengliang Guan 已提交
79
sql insert into $tb values (now+1s, $col )
S
slguan 已提交
80 81 82 83 84 85 86 87 88 89
sql select * from $tb order by ts desc
print expected: $col_
print returned: $data01
if $data01 != $col_ then
  return -1
endi

# insert nchar data with a pair of double quotes
$col = "NCHAR"
$col_ = NCHAR
S
scripts  
Shengliang Guan 已提交
90
sql insert into $tb values (now+2s, $col )
S
slguan 已提交
91 92 93 94 95 96 97 98 99 100
sql select * from $tb order by ts desc
print expected: $col_
print returned: $data01
if $data01 != $col_ then
  return -1
endi

# insert nchar data without quotes
$col = NCHAR
$col_ = nchar
S
scripts  
Shengliang Guan 已提交
101
sql_error insert into $tb values (now+3s, $col )
S
slguan 已提交
102 103 104 105 106 107 108 109
sql select * from $tb order by ts desc
#print expected: $col_
#print returned: $data01
#if $data01 != $col_ then
#  return -1
#endi

# insert nchar data with space and no quotes
S
scripts  
Shengliang Guan 已提交
110
sql_error insert into $tb values (now+4s, n char )
S
slguan 已提交
111 112

# insert nchar data with space and a pair of single quotes
S
scripts  
Shengliang Guan 已提交
113
sql insert into $tb values (now+5s, 'NCHAR' )
S
slguan 已提交
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
sql select * from $tb order by ts desc
print expected: NCHAR
print returned: $data01
$quote = '
$ret1 = $quote . $data01
$ret2 = $ret1 . $quote
print $ret2

if $ret2 != 'NCHAR' then
  return -1
endi

label1:

# insert nchar data with space and a pair of double quotes
S
scripts  
Shengliang Guan 已提交
129
sql insert into $tb values (now+6s, "NCHAR" )
S
slguan 已提交
130 131 132 133 134 135 136 137 138 139 140 141 142 143
sql select * from $tb order by ts desc
print expected: N CHAR
print returned: $data01
$quote = "
$ret1 = $quote . $data01
$ret2 = $ret1 . $quote
print $ret2 
if $ret2 = "NCHAR" then
  goto label2
else
  return -1
endi
label2:

S
scripts  
Shengliang Guan 已提交
144
sql insert into $tb values (now+7s, "涛思" )
S
slguan 已提交
145 146 147 148 149 150 151 152
sql select * from $tb order by ts desc
print expected: 涛思
print returned: $data01
if $data01 != 涛思 then 
  return -1
endi

# insert nchar data with a single quote and a double quote
S
scripts  
Shengliang Guan 已提交
153 154 155
#sql insert into $tb values (now+8s, 'NCHAR")
sql_error insert into $tb values (now+9s, 'NCHAR")
sql_error insert into $tb values (now+10s, 'NCHAR])
S
slguan 已提交
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

sql drop table $tb
sql drop table $mt
sql reset query cache
# create multiple metrics and tables and insert nchar type data
sql create table $mt (ts timestamp, tbcol nchar(10), tbcol1 int) TAGS(tgcol nchar(10))
$i = 0
while $i < 5
  $tb = $tbPrefix . $i
  sql create table $tb using $mt tags( '0' )  
  $x = 0
  while $x < $rowNum
    $ms = $x . m 
    sql insert into $tb values (now + $ms , '0', $x ) 
    $x = $x + 1
  endw  
  $i = $i + 1
endw 
while $i < 10
  $tb = $tbPrefix . $i
  sql create table $tb using $mt tags( '1' )  
  $x = 0
  while $x < $rowNum
    $ms = $x . m 
    sql insert into $tb values (now + $ms , '1', $x ) 
    $x = $x + 1
  endw  
  $i = $i + 1
endw 

# case5: query_with_tag_filtering
print ========== nchar.sim case5: query test
# simple query with nchar tag filtering
sql select * from $mt where tgcol = '1' -x step1
  goto step2
step1:
print reset query cache
sql reset query cache
sql select * from $mt where tgcol = '1'
step2:
if $rows != 100  then
H
hjxilinx 已提交
197
  print expect 100, actual: $rows
S
slguan 已提交
198 199
  return -1
endi
H
hjxilinx 已提交
200

H
Haojun Liao 已提交
201 202 203 204 205 206 207 208 209
#sql select * from $mt where tgcol > '0'
##print rows = $rows
#if $rows != 100 then
#  return -1
#endi
##print $data03
#if $data03 != 1 then
#  return -1
#endi
S
slguan 已提交
210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225

# cumulative query with nchar tag filtering
sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tgcol = '1'
if $rows != 1 then 
  return -1
endi
sql select count(tbcol1), avg(tbcol1), sum(tbcol1), min(tbcol1), max(tbcol1), first(tbcol1), last(tbcol1) from $mt where tbcol1 = 1 group by tgcol
if $rows != 2 then
  return -1
endi
sql select count(tbcol) from $mt where tbcol1 = 1 group by tgcol
if $rows != 2 then
  return -1
endi
print data00 = $data00
if $data00 != 5 then
H
Haojun Liao 已提交
226
  print expect 5, actual: $data00
S
slguan 已提交
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 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313
  return -1
endi
if $data10 != 5 then
  return -1
endi
sql_error select avg(tbcol) from $mt where tbcol1 = 1 group by tgcol
sql_error select sum(tbcol) from $mt where tbcol1 = 1 group by tgcol 
sql_error select min(tbcol) from $mt where tbcol1 = 1 group by tgcol 
sql_error select max(tbcol) from $mt where tbcol1 = 1 group by tgcol  
sql select first(tbcol) from $mt where tbcol1 = 1 group by tgcol 
if $rows != 2 then
  return -1
endi
if $data00 != 0 then 
  return -1
endi
if $data01 != 0 then
  return -1
endi
if $data10 != 1 then
  return -1
endi
if $data11 != 1 then
  return -1
endi
sql select last(tbcol) from $mt where tbcol1 = 1 group by tgcol
if $rows != 2 then
  return -1
endi
if $data00 != 0 then 
  return -1
endi
if $data01 != 0 then
  return -1
endi
if $data10 != 1 then
  return -1
endi
if $data11 != 1 then
  return -1
endi
 
sql create table stbb (ts timestamp, c1 nchar(5)) tags (t1 int)
sql create table tbb1 using stbb tags(1)
sql insert into tbb1 values ('2018-09-17 09:00:00', '涛思')
sql insert into tbb1 values ('2018-09-17 09:00:01', 'insrt')
sql select * from tbb1 order by ts asc
if $rows != 2 then
  return -1
endi
print data11 = $data11
if $data11 != insrt then
  return -1
endi

sql select * from stbb
if $rows != 2 then
  return -1
endi
if $data11 != insrt then
  return -1
endi

# nchar data column currently does not support filtering, 2018/09/27
# sql select * from $mt where tbcol = '0'
# if $rows != 100 then
#   return -1
# endi
# 
# sql select * from $mt where ts > now + 4m and tbcol = '1'
# if $rows != 75 then
#   return -1
# endi
# 
# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' group by tgcol
# 
# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where ts < now + 4m and tbcol = '1' group by tgcol 
# 
# sql_error select count(tbcol), avg(tbcol), sum(tbcol), min(tbcol), max(tbcol), first(tbcol), last(tbcol) from $mt where tbcol = '1' interval(1d) group by tgcol
#
# case: query_with_wildcard 
# print =============== clear
# sql drop database $db
# sql show databases
# if $rows != 0 then 
#   return -1
# endi
S
scripts  
Shengliang Guan 已提交
314 315

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