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 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31

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

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

sql show tables
if $rows != 1 then 
  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+1 seconds for results
sleep 16000
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 46


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

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

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

C
Cary Xu 已提交
66 67 68 69 70
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 已提交
71

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

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

C
Cary Xu 已提交
82 83 84 85 86 87 88 89 90 91
#===================================================================


#==================== reboot to trigger commit data to file
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 已提交
92
if $rows > 2 then
C
Cary Xu 已提交
93
  print retention level 2 file rows $rows > 2
C
Cary Xu 已提交
94 95
  return -1
endi
C
Cary Xu 已提交
96 97 98 99

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

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

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

print =============== select * from retention level 0 from file
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
C
Cary Xu 已提交
128 129

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

C
Cary Xu 已提交
134
system sh/exec.sh -n dnode1 -s stop -x SIGINT