rsmaCreateInsertQuery.sim 3.0 KB
Newer Older
C
Cary Xu 已提交
1 2 3 4 5 6 7 8 9 10 11
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
sql create database d0 retentions 15s:7d,1m:21d,15m:365d;
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 32 33 34 35

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);


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


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

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

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

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

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

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

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


#==================== 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 已提交
90
if $rows > 2 then
C
Cary Xu 已提交
91
  print retention level 2 file rows $rows > 2
C
Cary Xu 已提交
92 93
  return -1
endi
C
Cary Xu 已提交
94 95 96 97

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

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

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

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 已提交
126 127

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

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