count.sim 7.3 KB
Newer Older
S
slguan 已提交
1
system sh/stop_dnodes.sh
S
slguan 已提交
2 3

system sh/deploy.sh -n dnode1 -i 1
S
slguan 已提交
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 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 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 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 161 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 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 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

system sh/cfg.sh -n dnode1 -c clog -v 0
system sh/cfg.sh -n dnode1 -c numOfMPeers -v 1
system sh/cfg.sh -n dnode1 -c mgmtEqualVnodeNum -v 4

print ========= start dnode1 as master
system sh/exec.sh -n dnode1 -s start
sleep 3000
sql connect

print ======== step1 
sql create database d1 replica 1 days 7 keep 50 
sql use d1
sql create table tb (ts timestamp, a int)
sql insert into tb values(now-28d, -28)
sql insert into tb values(now-27d, -27)
sql insert into tb values(now-26d, -26)
sql select count(a) from tb
if $data00 != 3 then
  return -1
endi

print ======== step2
sql alter table tb add column b smallint
sql insert into tb values(now-25d, -25, 0)
sql insert into tb values(now-24d, -24, 1)
sql insert into tb values(now-23d, -23, 2)
sql select count(b) from tb
if $data00 != 3 then
  return -1
endi

print ======== step3
# sql alter table tb(ts timestamp, a int, b smallint, c tinyint)
sql alter table tb add column c tinyint
sql insert into tb values(now-22d, -22, 3, 0)
sql insert into tb values(now-21d, -21, 4, 1)
sql insert into tb values(now-20d, -20, 5, 2)
sql select count(c) from tb
if $data00 != 3 then
  return -1
endi

print ======== step4
# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int)
sql alter table tb add column d int
sql insert into tb values(now-19d, -19, 6, 0, 0)
sql insert into tb values(now-18d, -18, 7, 1, 1)
sql insert into tb values(now-17d, -17, 8, 2, 2)
sql select count(d) from tb
if $data00 != 3 then
  return -1
endi

print ======== step5
# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint)
sql alter table tb add column e bigint
sql insert into tb values(now-16d, -16, 9, 0, 0, 0)
sql insert into tb values(now-15d, -15, 10, 1, 1, 1)
sql insert into tb values(now-14d, -14, 11, 2, 2, 2)
sql select count(e) from tb
if $data00 != 3 then
  return -1
endi

print ======== step6
# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float)
sql alter table tb add column f float
sql insert into tb values(now-13d, -13, 12, 0, 0, 0, 0)
sql insert into tb values(now-12d, -12, 13, 1, 1, 1, 1)
sql insert into tb values(now-11d, -11, 24, 2, 2, 2, 2)
sql select count(f) from tb
if $data00 != 3 then
  return -1
endi

print ======== step7
# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double)
sql alter table tb add column g double
sql insert into tb values(now-10d, -10, 15, 0, 0, 0, 0, 0)
sql insert into tb values(now-9d, -9, 16, 1, 1, 1, 1, 1)
sql insert into tb values(now-8d, -8, 17, 2, 2, 2, 2, 2)
sql select count(g) from tb
if $data00 != 3 then
  return -1
endi

print ======== step8
# sql alter table tb(ts timestamp, a int, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(10) ) 
sql alter table tb add column h binary(10)
sql insert into tb values(now-7d, -7, 18, 0, 0, 0, 0, 0, '0')
sql insert into tb values(now-6d, -6, 19, 1, 1, 1, 1, 1, '1')
sql insert into tb values(now-5d, -5, 20, 2, 2, 2, 2, 2, '2')
sql select count(h) from tb
if $data00 != 3 then
  return -1
endi

print ======== step9
sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data00 != 24 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data01 != 21 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data02 != 18 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data03 != 15 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data04 != 12 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data05 != 9 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data06 != 6 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data07 != 3 then
  return -1
endi

print ============= step10
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 5000
system sh/exec.sh -n dnode1 -s start
sleep 5000

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data00 != 24 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data01 != 21 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data02 != 18 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data03 != 15 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data04 != 12 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data05 != 9 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data06 != 6 then
  return -1
endi

sql select count(a), count(b), count(c), count(d), count(e), count(f), count(g), count(h) from tb
if $data07 != 3 then
  return -1
endi

print ======== step11
#sql alter table tb(ts timestamp, b smallint, c tinyint, d int, e bigint, f float, g double, h binary(20))
sql alter table tb drop column a
sql insert into tb values(now-4d, 1, 1, 1, 1, 1, 1, '1')
sql select count(g) from tb
if $data00 != 7 then
  return -1
endi

print ======== step12
#sql alter table tb(ts timestamp, c tinyint, d int, e bigint, f float, g double, h binary(20))
sql alter table tb drop column b
sql insert into tb values(now-3d, 1, 1, 1, 1, 1, '1')
sql select count(g) from tb
if $data00 != 8 then
  return -1
endi

print ======== step13
#sql alter table tb(ts timestamp, d int, e bigint, f float, g double, h binary(20))
sql alter table tb drop column c
sql insert into tb values(now-2d, 1, 1, 1, 1, '1')
sql select count(g) from tb
if $data00 != 9 then
  return -1
endi

print ======== step14
#sql alter table tb(ts timestamp, e bigint, f float, g double, h binary(20))
sql alter table tb drop column d
sql insert into tb values(now-1d, 1, 1, 1, '1')
sql select count(g) from tb
if $data00 != 10 then
  return -1
endi

print ======== step15
#sql alter table tb(ts timestamp, f float, g double, h binary(20))
sql alter table tb drop column e
sql insert into tb values(now, 1, 1, '1')
sql select count(g) from tb
if $data00 != 11 then
  return -1
endi

print ======== step16
#sql alter table tb(ts timestamp, g double, h binary(20))
sql alter table tb drop column f
sql insert into tb values(now+1d, 1, '1')
sql select count(g) from tb
if $data00 != 12 then
  return -1
endi

print ======== step17
#sql alter table tb(ts timestamp, h binary(20))
sql alter table tb drop column g
sql insert into tb values(now+2d, '1')
sql select count(h) from tb
if $data00 != 10 then
  return -1
endi

print ============== step18
system sh/exec.sh -n dnode1 -s stop -x SIGINT
sleep 5000
system sh/exec.sh -n dnode1 -s start
sleep 5000

#sql select count(g) from tb
#if $data00 != 12 then
#  return -1
#endi
sql select count(*) from tb
if $data00 != 31 then
  return -1
endi