rsmaCreateInsertQuery.sim 4.4 KB
Newer Older
C
Cary Xu 已提交
1 2 3 4 5 6 7
system sh/stop_dnodes.sh
system sh/deploy.sh -n dnode1 -i 1
system sh/exec.sh -n dnode1 -s start
sleep 50
sql connect

print =============== create database with retentions
C
Cary Xu 已提交
8
sql create database d0 retentions 5s:7d,10s:21d,15s:365d;
C
Cary Xu 已提交
9 10 11
sql use d0

print =============== create super table and register rsma
X
Xiaoyu Wang 已提交
12
sql create table if not exists stb (ts timestamp, c1 int) tags (city binary(20),district binary(20)) rollup(min);
C
Cary Xu 已提交
13 14

sql show stables
G
Ganlin Zhao 已提交
15
if $rows != 1 then
C
Cary Xu 已提交
16 17 18 19 20 21 22
  return -1
endi

print =============== create child table
sql create table ct1 using stb tags("BeiJing", "ChaoYang");

sql show tables
G
Ganlin Zhao 已提交
23
if $rows != 1 then
C
Cary Xu 已提交
24 25 26 27 28 29 30 31
  return -1
endi

print =============== insert data and trigger rollup
sql insert into ct1 values(now, 10);
sql insert into ct1 values(now+1s, 1);
sql insert into ct1 values(now+2s, 100);

C
Cary Xu 已提交
32 33
print =============== wait maxdelay 15+2 seconds for results
sleep 17000
C
Cary Xu 已提交
34 35 36 37

print =============== select * from retention level 2 from memory
sql select * from ct1;
print $data00 $data01
C
Cary Xu 已提交
38
if $rows > 2 then
C
Cary Xu 已提交
39
  print retention level 2 file rows $rows > 2
C
Cary Xu 已提交
40 41
  return -1
endi
C
Cary Xu 已提交
42 43 44 45


if $data01 != 1 then
  if $data01 != 10 then
46
    print =============> $data01
C
Cary Xu 已提交
47
    print retention level 2 file result $data01 != 1 or 10
C
Cary Xu 已提交
48
  return -1
C
Cary Xu 已提交
49
  endi
C
Cary Xu 已提交
50
endi
C
Cary Xu 已提交
51

C
Cary Xu 已提交
52 53 54
print =============== select * from retention level 1 from memory
sql select * from ct1 where ts > now-8d;
print $data00 $data01
C
Cary Xu 已提交
55
if $rows > 2 then
C
Cary Xu 已提交
56
  print retention level 1 file rows $rows > 2
C
Cary Xu 已提交
57 58
  return -1
endi
C
Cary Xu 已提交
59 60 61 62

if $data01 != 1 then
  if $data01 != 10 then
    print retention level 1 file result $data01 != 1 or 10
C
Cary Xu 已提交
63
  return -1
C
Cary Xu 已提交
64
  endi
C
Cary Xu 已提交
65
endi
C
Cary Xu 已提交
66

C
Cary Xu 已提交
67 68 69 70 71
print =============== select * from retention level 0 from memory
sql select * from ct1 where ts > now-3d;
print $data00 $data01
print $data10 $data11
print $data20 $data21
C
Cary Xu 已提交
72

C
Cary Xu 已提交
73 74 75 76
if $rows < 1 then
  print retention level 0 file rows $rows < 1
  return -1
endi
C
Cary Xu 已提交
77 78

if $data01 != 10 then
C
Cary Xu 已提交
79 80 81
  print retention level 0 file result $data01 != 10
  return -1
endi
C
Cary Xu 已提交
82

C
Cary Xu 已提交
83
#===================================================================
84 85 86 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 128 129 130 131 132 133 134 135
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start
print =============== wait maxdelay 15+2 seconds for results after reboot
sleep 17000

print =============== select * from retention level 2 from memory after reboot
sql select * from ct1;
print $data00 $data01
if $rows > 2 then
  print retention level 2 file rows $rows > 2
  return -1
endi


if $data01 != 1 then
  if $data01 != 10 then
    print =============> $data01
    print retention level 2 file result $data01 != 1 or 10
  return -1
  endi
endi

print =============== select * from retention level 1 from memory after reboot
sql select * from ct1 where ts > now-8d;
print $data00 $data01
if $rows > 2 then
  print retention level 1 file rows $rows > 2
  return -1
endi

if $data01 != 1 then
  if $data01 != 10 then
    print retention level 1 file result $data01 != 1 or 10
  return -1
  endi
endi

print =============== select * from retention level 0 from memory after reboot
sql select * from ct1 where ts > now-3d;
print $data00 $data01
print $data10 $data11
print $data20 $data21

if $rows < 1 then
  print retention level 0 file rows $rows < 1
  return -1
endi

if $data01 != 10 then
  print retention level 0 file result $data01 != 10
  return -1
endi
C
Cary Xu 已提交
136

137
#==================== flush database to trigger commit data to file
138
sql flush database d0;
C
Cary Xu 已提交
139 140 141 142 143 144
system sh/exec.sh -n dnode1 -s stop -x SIGINT
system sh/exec.sh -n dnode1 -s start

print =============== select * from retention level 2 from file
sql select * from ct1;
print $data00 $data01
C
Cary Xu 已提交
145
if $rows > 2 then
C
Cary Xu 已提交
146
  print retention level 2 file rows $rows > 2
C
Cary Xu 已提交
147 148
  return -1
endi
C
Cary Xu 已提交
149 150 151 152

if $data01 != 1 then
  if $data01 != 10 then
    print retention level 2 file result $data01 != 1 or 10
C
Cary Xu 已提交
153
  return -1
C
Cary Xu 已提交
154
  endi
C
Cary Xu 已提交
155 156
endi

C
Cary Xu 已提交
157 158 159
print =============== select * from retention level 1 from file
sql select * from ct1 where ts > now-8d;
print $data00 $data01
C
Cary Xu 已提交
160
if $rows > 2 then
C
Cary Xu 已提交
161
  print retention level 1 file rows $rows > 2
C
Cary Xu 已提交
162 163
  return -1
endi
C
Cary Xu 已提交
164 165 166 167

if $data01 != 1 then
  if $data01 != 10 then
    print retention level 1 file result $data01 != 1 or 10
C
Cary Xu 已提交
168
  return -1
C
Cary Xu 已提交
169
  endi
C
Cary Xu 已提交
170
endi
C
Cary Xu 已提交
171 172 173

print =============== select * from retention level 0 from file
sql select * from ct1 where ts > now-3d;
G
Ganlin Zhao 已提交
174
print $data00 $data01
C
Cary Xu 已提交
175 176 177 178 179 180
print $data10 $data11
print $data20 $data21
if $rows < 1 then
  print retention level 0 file rows $rows < 1
  return -1
endi
C
Cary Xu 已提交
181 182

if $data01 != 10 then
C
Cary Xu 已提交
183 184 185
  print retention level 0 file result $data01 != 10
  return -1
endi
C
Cary Xu 已提交
186

G
Ganlin Zhao 已提交
187
system sh/exec.sh -n dnode1 -s stop -x SIGINT