basic1.sim 5.7 KB
Newer Older
1 2 3 4 5
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sql connect

P
plum-lihui 已提交
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
#=========== TD-14042 start
sql create database db1;
sql create database db2;
sql create database db3;

sql use db1;
sql create table st1 (ts timestamp, i int) tags (j int);
sql create table tb1 using st1 tags(1);

sql use db2;
sql create table st2 (ts timestamp, i int) tags (j int);
sql create table tb2 using st2 tags(1);

sql use db3;
sql create table st3 (ts timestamp, i int) tags (j int);
sql create table tb3 using st3 tags(1);

sql show tables
if $rows != 1 then 
  return -1
endi
#=========== TD-14042 end

29 30 31
print =============== create database
sql create database d1
sql show databases
P
plum-lihui 已提交
32
if $rows != 5 then 
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
  return -1
endi

print $data00 $data01 $data02

sql use d1

print =============== create super table
sql create table st (ts timestamp, i int) tags (j int)
sql create table if not exists st (ts timestamp, i int) tags (j int)
sql create table if not exists st (ts timestamp, i int) tags (j int)
sql show stables
if $rows != 1 then 
  return -1
endi

print $data00 $data01 $data02

sql create table st2 (ts timestamp, i float) tags (j int)
sql show stables
if $rows != 2 then 
  return -1
endi

print $data00 $data01 $data02
print $data10 $data11 $data12

sql drop table st2

sql show stables
if $rows != 1 then 
  return -1
endi

print $data00 $data01 $data02
print $data10 $data11 $data12

print =============== create child table
sql create table c1 using st tags(1)
sql create table c2 using st tags(2) 

sql show tables
if $rows != 2 then 
  return -1
endi

sql create table c3 using st tags(3) c4 using st tags(4) c5 using st tags(5) c6 using st tags(6) c7 using st tags(7)

sql show tables
if $rows != 7 then 
  return -1
endi

print $data00 $data01 $data02
P
plum-lihui 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
print $data10 $data11 $data12
print $data20 $data21 $data22

print =============== create normal table
sql create database ndb
sql use ndb
sql create table nt0 (ts timestamp, i int)
sql create table if not exists nt0 (ts timestamp, i int)
sql create table nt1 (ts timestamp, i int)
sql create table if not exists nt1 (ts timestamp, i int)
sql create table if not exists nt3 (ts timestamp, i int)

sql show tables
if $rows != 3 then 
  return -1
endi

sql insert into nt0 values(now+1s, 1)(now+2s, 2)(now+3s, 3)
sql insert into nt1 values(now+1s, 1)(now+2s, 2)(now+3s, 3)

sql select * from nt1
if $rows != 3 then 
  return -1
endi

print $data00 $data01
print $data10 $data11
print $data20 $data21

if $data01 != 1 then 
  return -1
endi

if $data11 != 2 then 
  return -1
endi

if $data21 != 3 then 
  return -1
endi

128 129

print =============== insert data
P
plum-lihui 已提交
130
sql use d1
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
sql insert into c1 values(now+1s, 1)
sql insert into c1 values(now+2s, 2)
sql insert into c1 values(now+3s, 3)
sql insert into c2 values(now+1s, 1)
sql insert into c2 values(now+2s, 2)
sql insert into c2 values(now+3s, 3)
sql insert into c3 values(now+1s, 1)
sql insert into c3 values(now+2s, 2)
sql insert into c3 values(now+3s, 3)
sql insert into c4 values(now+1s, 1)
sql insert into c4 values(now+2s, 2)
sql insert into c4 values(now+3s, 3)
sql insert into c5 values(now+1s, 1)
sql insert into c5 values(now+2s, 2)
sql insert into c5 values(now+3s, 3)
sql insert into c6 values(now+1s, 1)
sql insert into c6 values(now+2s, 2)
sql insert into c6 values(now+3s, 3)
sql insert into c7 values(now+1s, 1)
sql insert into c7 values(now+2s, 2)
sql insert into c7 values(now+3s, 3)

print =============== query data
sql select * from c1
if $rows != 3 then 
  return -1
endi

print $data00 $data01
print $data10 $data11
P
plum-lihui 已提交
161
print $data20 $data21
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

if $data01 != 1 then 
  return -1
endi

if $data11 != 2 then 
  return -1
endi

if $data21 != 3 then 
  return -1
endi

sql select * from c2
if $rows != 3 then 
  return -1
endi

sql select * from c3
if $rows != 3 then 
  return -1
endi

sql select * from c4
if $rows != 3 then 
  return -1
endi

sql select * from c5
if $rows != 3 then 
  return -1
endi

sql select * from c6
if $rows != 3 then 
  return -1
endi

sql select * from c7
if $rows != 3 then 
  return -1
endi

print =============== query data from st
H
Haojun Liao 已提交
206 207
print ==============select * against super will cause crash.
sql select ts from st
208 209 210 211
if $rows != 21 then 
  return -1
endi

P
plum-lihui 已提交
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start

$loop_cnt = 0
check_dnode_ready:
	$loop_cnt = $loop_cnt + 1
	sleep 200
	if $loop_cnt == 10 then
	  print ====> dnode not ready!
		return -1
	endi
sql show dnodes
print ===> $rows $data00 $data01 $data02 $data03 $data04 $data05
if $data00 != 1 then
  return -1
endi
if $data04 != ready then
  goto check_dnode_ready
endi
231 232 233 234 235 236 237 238 239 240

print =============== query data
sql select * from c1
if $rows != 3 then 
  print $rows
  return -1
endi

print $data00 $data01
print $data10 $data11
P
plum-lihui 已提交
241
print $data20 $data21
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

if $data01 != 1 then 
  return -1
endi

if $data11 != 2 then 
  return -1
endi

if $data21 != 3 then 
  return -1
endi

sql select * from c2
if $rows != 3 then 
  return -1
endi

sql select * from c3
if $rows != 3 then 
  return -1
endi

sql select * from c4
if $rows != 3 then 
  return -1
endi

sql select * from c5
if $rows != 3 then 
  return -1
endi

sql select * from c6
if $rows != 3 then 
  return -1
endi

sql select * from c7
if $rows != 3 then 
  return -1
endi

print =============== query data from st
H
Haojun Liao 已提交
286
sql select ts from st
287 288 289 290
if $rows != 21 then 
  return -1
endi

P
plum-lihui 已提交
291 292 293
print =============== query data from normal table after restart dnode
sql use ndb
sql select * from nt1
H
Haojun Liao 已提交
294 295
if $rows != 3 then
  print expect 3, actual: $rows
P
plum-lihui 已提交
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
  return -1
endi

print $data00 $data01
print $data10 $data11
print $data20 $data21

if $data01 != 1 then 
  return -1
endi

if $data11 != 2 then 
  return -1
endi

if $data21 != 3 then 
  return -1
endi

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