rsmaCreateInsertQuery.sim 3.1 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
#===================================================================

#==================== reboot to trigger commit data to file
86
sql flush database d0;
C
Cary Xu 已提交
87 88 89 90 91 92
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 已提交
93
if $rows > 2 then
C
Cary Xu 已提交
94
  print retention level 2 file rows $rows > 2
C
Cary Xu 已提交
95 96
  return -1
endi
C
Cary Xu 已提交
97 98 99 100

if $data01 != 1 then
  if $data01 != 10 then
    print retention level 2 file result $data01 != 1 or 10
C
Cary Xu 已提交
101
  return -1
C
Cary Xu 已提交
102
  endi
C
Cary Xu 已提交
103 104
endi

C
Cary Xu 已提交
105 106 107
print =============== select * from retention level 1 from file
sql select * from ct1 where ts > now-8d;
print $data00 $data01
C
Cary Xu 已提交
108
if $rows > 2 then
C
Cary Xu 已提交
109
  print retention level 1 file rows $rows > 2
C
Cary Xu 已提交
110 111
  return -1
endi
C
Cary Xu 已提交
112 113 114 115

if $data01 != 1 then
  if $data01 != 10 then
    print retention level 1 file result $data01 != 1 or 10
C
Cary Xu 已提交
116
  return -1
C
Cary Xu 已提交
117
  endi
C
Cary Xu 已提交
118
endi
C
Cary Xu 已提交
119 120 121

print =============== select * from retention level 0 from file
sql select * from ct1 where ts > now-3d;
G
Ganlin Zhao 已提交
122
print $data00 $data01
C
Cary Xu 已提交
123 124 125 126 127 128
print $data10 $data11
print $data20 $data21
if $rows < 1 then
  print retention level 0 file rows $rows < 1
  return -1
endi
C
Cary Xu 已提交
129 130

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

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